예제 #1
0
        public static void FoundTarget(edict_t self)
        {
            if (self.enemy.client != null)
            {
                GameBase.level.sight_entity             = self;
                GameBase.level.sight_entity_framenum    = GameBase.level.framenum;
                GameBase.level.sight_entity.light_level = 128;
            }

            self.show_hostile = (int)GameBase.level.time + 1;
            Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting);
            self.monsterinfo.trail_time = GameBase.level.time;
            if (self.combattarget == null)
            {
                GameAI.HuntTarget(self);
                return;
            }

            self.goalentity = self.movetarget = GameBase.G_PickTarget(self.combattarget);
            if (self.movetarget == null)
            {
                self.goalentity = self.movetarget = self.enemy;
                GameAI.HuntTarget(self);
                GameBase.gi.Dprintf("" + self.classname + "at " + Lib.Vtos(self.s.origin) + ", combattarget " + self.combattarget + " not found\\n");
                return;
            }

            self.combattarget          = null;
            self.monsterinfo.aiflags  |= Defines.AI_COMBAT_POINT;
            self.movetarget.targetname = null;
            self.monsterinfo.pausetime = 0;
            self.monsterinfo.run.Think(self);
        }
예제 #2
0
            public override bool Think(edict_t self)
            {
                if (self.target == null)
                {
                    GameBase.gi.Dprintf(self.classname + " at " + Lib.Vtos(self.s.origin) + " needs a target\\n");
                }
                else
                {
                    self.target_ent = GameBase.G_PickTarget(self.target);
                    Math3D.VectorSubtract(self.target_ent.s.origin, self.s.origin, self.move_origin);
                    GameUtil.G_FreeEdict(self.target_ent);
                }

                self.teammaster.dmg = self.dmg;
                self.think          = turret_breach_think;
                self.think.Think(self);
                return(true);
            }
예제 #3
0
            public override bool Think(edict_t self)
            {
                float[] vec = new float[] { 0, 0, 0 };
                self.think                       = turret_driver_think;
                self.nextthink                   = GameBase.level.time + Defines.FRAMETIME;
                self.target_ent                  = GameBase.G_PickTarget(self.target);
                self.target_ent.owner            = self;
                self.target_ent.teammaster.owner = self;
                Math3D.VectorCopy(self.target_ent.s.angles, self.s.angles);
                vec[0] = self.target_ent.s.origin[0] - self.s.origin[0];
                vec[1] = self.target_ent.s.origin[1] - self.s.origin[1];
                vec[2] = 0;
                self.move_origin[0] = Math3D.VectorLength(vec);
                Math3D.VectorSubtract(self.s.origin, self.target_ent.s.origin, vec);
                Math3D.Vectoangles(vec, vec);
                AnglesNormalize(vec);
                self.move_origin[1] = vec[1];
                self.move_origin[2] = self.s.origin[2] - self.target_ent.s.origin[2];

                self.teammaster = self.target_ent.teammaster;
                self.flags     |= Defines.FL_TEAMSLAVE;
                return(true);
            }
예제 #4
0
        public static void Monster_start_go(edict_t self)
        {
            float[] v = new float[] { 0, 0, 0 };
            if (self.health <= 0)
            {
                return;
            }
            if (self.target != null)
            {
                bool    notcombat;
                bool    fixup;
                edict_t target = null;
                notcombat = false;
                fixup     = false;
                EdictIterator edit = null;
                while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.target)) != null)
                {
                    target = edit.o;
                    if (Lib.Strcmp(target.classname, "point_combat") == 0)
                    {
                        self.combattarget = self.target;
                        fixup             = true;
                    }
                    else
                    {
                        notcombat = true;
                    }
                }

                if (notcombat && self.combattarget != null)
                {
                    GameBase.gi.Dprintf(self.classname + " at " + Lib.Vtos(self.s.origin) + " has target with mixed types\\n");
                }
                if (fixup)
                {
                    self.target = null;
                }
            }

            if (self.combattarget != null)
            {
                edict_t       target = null;
                EdictIterator edit   = null;
                while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.combattarget)) != null)
                {
                    target = edit.o;
                    if (Lib.Strcmp(target.classname, "point_combat") != 0)
                    {
                        GameBase.gi.Dprintf(self.classname + " at " + Lib.Vtos(self.s.origin) + " has bad combattarget " + self.combattarget + " : " + target.classname + " at " + Lib.Vtos(target.s.origin));
                    }
                }
            }

            if (self.target != null)
            {
                self.goalentity = self.movetarget = GameBase.G_PickTarget(self.target);
                if (null == self.movetarget)
                {
                    GameBase.gi.Dprintf(self.classname + " can't find target " + self.target + " at " + Lib.Vtos(self.s.origin) + "\\n");
                    self.target = null;
                    self.monsterinfo.pausetime = 100000000;
                    self.monsterinfo.stand.Think(self);
                }
                else if (Lib.Strcmp(self.movetarget.classname, "path_corner") == 0)
                {
                    Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v);
                    self.ideal_yaw = self.s.angles[Defines.YAW] = Math3D.Vectoyaw(v);
                    self.monsterinfo.walk.Think(self);
                    self.target = null;
                }
                else
                {
                    self.goalentity            = self.movetarget = null;
                    self.monsterinfo.pausetime = 100000000;
                    self.monsterinfo.stand.Think(self);
                }
            }
            else
            {
                self.monsterinfo.pausetime = 100000000;
                self.monsterinfo.stand.Think(self);
            }

            self.think     = Monster.monster_think;
            self.nextthink = GameBase.level.time + Defines.FRAMETIME;
        }