Ejemplo n.º 1
0
        public static void SP_target_blaster(edict_t self)
        {
            self.use = GameTarget.use_target_blaster;
            GameBase.G_SetMovedir(self.s.angles, self.movedir);
            self.noise_index = GameBase.gi.soundindex("weapons/laser2.wav");

            if (0 == self.dmg)
            {
                self.dmg = 15;
            }

            if (0 == self.speed)
            {
                self.speed = 1000;
            }

            self.svflags = Defines.SVF_NOCLIENT;
        }
Ejemplo n.º 2
0
        public static void SP_trigger_multiple(edict_t ent)
        {
            if (ent.sounds == 1)
            {
                ent.noise_index = GameBase.gi.soundindex("misc/secret.wav");
            }
            else if (ent.sounds == 2)
            {
                ent.noise_index = GameBase.gi.soundindex("misc/talk.wav");
            }
            else if (ent.sounds == 3)
            {
                ent.noise_index = GameBase.gi.soundindex("misc/trigger1.wav");
            }

            if (ent.wait == 0)
            {
                ent.wait = 0.2f;
            }

            ent.touch    = GameTrigger.Touch_Multi;
            ent.movetype = Defines.MOVETYPE_NONE;
            ent.svflags |= Defines.SVF_NOCLIENT;

            if ((ent.spawnflags & 4) != 0)
            {
                ent.solid = Defines.SOLID_NOT;
                ent.use   = GameTrigger.trigger_enable;
            }
            else
            {
                ent.solid = Defines.SOLID_TRIGGER;
                ent.use   = GameTrigger.Use_Multi;
            }

            if (!Math3D.VectorEquals(ent.s.angles, Globals.vec3_origin))
            {
                GameBase.G_SetMovedir(ent.s.angles, ent.movedir);
            }

            GameBase.gi.setmodel(ent, ent.model);
            GameBase.gi.linkentity(ent);
        }
Ejemplo n.º 3
0
        public static void BeginIntermission(edict_t targ)
        {
            int     i, n;
            edict_t ent, client;

            if (GameBase.level.intermissiontime != 0)
            {
                return;                 // already activated
            }
            GameBase.game.autosaved = false;

            // respawn any dead clients
            for (i = 0; i < GameBase.maxclients.value; i++)
            {
                client = GameBase.g_edicts[1 + i];

                if (!client.inuse)
                {
                    continue;
                }

                if (client.health <= 0)
                {
                    PlayerClient.respawn(client);
                }
            }

            GameBase.level.intermissiontime = GameBase.level.time;
            GameBase.level.changemap        = targ.map;

            if (GameBase.level.changemap.IndexOf('*') > -1)
            {
                if (GameBase.coop.value != 0)
                {
                    for (i = 0; i < GameBase.maxclients.value; i++)
                    {
                        client = GameBase.g_edicts[1 + i];

                        if (!client.inuse)
                        {
                            continue;
                        }

                        // strip players of all keys between units
                        for (n = 1; n < GameItemList.itemlist.Length; n++)
                        {
                            // null pointer exception fixed. (RST)
                            if (GameItemList.itemlist[n] != null)
                            {
                                if ((GameItemList.itemlist[n].flags & Defines.IT_KEY) != 0)
                                {
                                    client.client.pers.inventory[n] = 0;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (0 == GameBase.deathmatch.value)
                {
                    GameBase.level.exitintermission = true;                     // go immediately to the

                    // next level
                    return;
                }
            }

            GameBase.level.exitintermission = false;

            // find an intermission spot
            ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_intermission");

            if (ent == null)
            {
                // the map creator forgot to put in an intermission
                // point...
                ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_start");

                if (ent == null)
                {
                    ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_deathmatch");
                }
            }
            else
            {
                // chose one of four spots
                i = Lib.rand() & 3;
                EdictIterator es = null;

                while (i-- > 0)
                {
                    es = GameBase.G_Find(es, GameBase.findByClass, "info_player_intermission");

                    if (es == null)                     // wrap around the list
                    {
                        continue;
                    }

                    ent = es.o;
                }
            }

            Math3D.VectorCopy(ent.s.origin, GameBase.level.intermission_origin);
            Math3D.VectorCopy(ent.s.angles, GameBase.level.intermission_angle);

            // move all clients to the intermission point
            for (i = 0; i < GameBase.maxclients.value; i++)
            {
                client = GameBase.g_edicts[1 + i];

                if (!client.inuse)
                {
                    continue;
                }

                PlayerHud.MoveClientToIntermission(client);
            }
        }
Ejemplo n.º 4
0
        public static void monster_start_go(edict_t self)
        {
            float[] v = { 0, 0, 0 };

            if (self.health <= 0)
            {
                return;
            }

            // check for target to combat_point and change to combattarget
            if (self.target != null)
            {
                bool    notcombat;
                bool    fixup;
                edict_t target = null;
                notcombat = false;
                fixup     = false;

                /*
                 * if (true) { Com.Printf("all entities:\n");
                 *
                 * for (int n = 0; n < Game.globals.num_edicts; n++) { edict_t ent =
                 * GameBase.g_edicts[n]; Com.Printf( "|%4i | %25s
                 * |%8.2f|%8.2f|%8.2f||%8.2f|%8.2f|%8.2f||%8.2f|%8.2f|%8.2f|\n", new
                 * Vargs().add(n).add(ent.classname).
                 * add(ent.s.origin[0]).add(ent.s.origin[1]).add(ent.s.origin[2])
                 * .add(ent.mins[0]).add(ent.mins[1]).add(ent.mins[2])
                 * .add(ent.maxs[0]).add(ent.maxs[1]).add(ent.maxs[2])); }
                 * sleep(10); }
                 */

                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;
                }
            }

            // validate combattarget
            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;
        }
Ejemplo n.º 5
0
        /**
         * Use the targets.
         *
         * The global "activator" should be set to the entity that initiated the
         * firing.
         *
         * If self.delay is set, a DelayedUse entity will be created that will
         * actually do the SUB_UseTargets after that many seconds have passed.
         *
         * Centerprints any self.message to the activator.
         *
         * Search for (string)targetname in all entities that match
         * (string)self.target and call their .use function
         */
        public static void G_UseTargets(edict_t ent, edict_t activator)
        {
            edict_t t;

            GameUtil.checkClassname(ent);

            // check for a delay
            if (ent.delay != 0)
            {
                // create a temp object to fire at a later time
                t           = GameUtil.G_Spawn();
                t.classname = "DelayedUse";
                t.nextthink = GameBase.level.time + ent.delay;
                t.think     = GameUtil.Think_Delay;
                t.activator = activator;

                if (activator == null)
                {
                    GameBase.gi.dprintf("Think_Delay with no activator\n");
                }

                t.message    = ent.message;
                t.target     = ent.target;
                t.killtarget = ent.killtarget;

                return;
            }

            // print the message
            if (ent.message != null && (activator.svflags & Defines.SVF_MONSTER) == 0)
            {
                GameBase.gi.centerprintf(activator, "" + ent.message);

                if (ent.noise_index != 0)
                {
                    GameBase.gi.sound(activator, Defines.CHAN_AUTO, ent.noise_index, 1, Defines.ATTN_NORM, 0);
                }
                else
                {
                    GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0);
                }
            }

            // kill killtargets
            EdictIterator edit = null;

            if (ent.killtarget != null)
            {
                while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, ent.killtarget)) != null)
                {
                    t = edit.o;
                    GameUtil.G_FreeEdict(t);

                    if (!ent.inuse)
                    {
                        GameBase.gi.dprintf("entity was removed while using killtargets\n");

                        return;
                    }
                }
            }

            // fire targets
            if (ent.target != null)
            {
                edit = null;

                while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, ent.target)) != null)
                {
                    t = edit.o;

                    // doors fire area portals in a specific way
                    if (Lib.Q_stricmp("func_areaportal", t.classname) == 0 &&
                        (Lib.Q_stricmp("func_door", ent.classname) == 0 || Lib.Q_stricmp("func_door_rotating", ent.classname) == 0))
                    {
                        continue;
                    }

                    if (t == ent)
                    {
                        GameBase.gi.dprintf("WARNING: Entity used itself.\n");
                    }
                    else
                    {
                        if (t.use != null)
                        {
                            t.use.use(t, ent, activator);
                        }
                    }

                    if (!ent.inuse)
                    {
                        GameBase.gi.dprintf("entity was removed while using targets\n");

                        return;
                    }
                }
            }
        }