Beispiel #1
0
        public void AddObjectTo_MobSearchGroup(int team)
        {
            SimSet MobSearchGroup = "MobSearchGroup_" + team;

            if (!MobSearchGroup.isObject())
            {
                MobSearchGroup = new ObjectCreator("SimSet", "MobSearchGroup_" + team).Create();
            }
            MobSearchGroup.add(this);
        }
Beispiel #2
0
        public virtual int GetNearestPlayerTarget()
        {
            if (!isObject())
            {
                return(-1);
            }

            if ((this["CurrentTarget"] != "") && (this["CurrentTarget"] != "-1"))
            {
                if (this["CurrentTarget"].isObject())
                {
                    if (((Player)this["CurrentTarget"]).getState() != "Dead")
                    {
                        if (TargetIsInLos(this["CurrentTarget"]))
                        {
                            return(this["CurrentTarget"].AsInt());
                        }
                    }
                }

                this["CurrentTarget"] = "";
            }

            SimSet mobSearchGroup = this["aiteam"] == "1" ? "MobSearchGroup_2" : "MobSearchGroup_1";

            SimSet mobSearchGroupResult = "MobSearchGroupResult";

            if (!mobSearchGroupResult.isObject())
            {
                mobSearchGroupResult = new ObjectCreator("SimSet", "MobSearchGroupResult").Create();
            }

            AISearchSimSet(180, 50, mobSearchGroup, mobSearchGroupResult);

            int   closesttarget = -1;
            float closestdist   = 51;

            for (uint i = 0; i < mobSearchGroupResult.getCount(); i++)
            {
                Player target = mobSearchGroupResult.getObject(i);
                if (!target.isObject())
                {
                    continue;
                }
                if (target.getState() == "Dead")
                {
                    continue;
                }
                float dist = GetTargetDistance(target);
                if (dist >= closestdist)
                {
                    continue;
                }
                closestdist   = dist;
                closesttarget = target;
            }
            mobSearchGroupResult.clear();

            this["CurrentTarget"] = closesttarget.AsString();

            return(closesttarget);
        }
        public virtual void FollowPath(SimSet path, int node)
        {
            stopThread(0);

            if (!path.isObject() || !isObject())
                {
                this["path"] = "";
                return;
                }

            if (node > path.getCount() - 1)
                this["targetNode"] = (path.getCount() - 1).AsString();
            else
                this["targetNode"] = node.AsString();

            if ((this["path"]) == path)
                MoveToNode(this["currentNode"].AsUint());

            else
                {
                this["path"] = path;
                MoveToNode(0);
                }
        }