Example #1
0
        public static void SP_target_secret(edict_t ent)
        {
            if (GameBase.deathmatch.value != 0)
            {
                // auto-remove for deathmatch
                GameUtil.G_FreeEdict(ent);

                return;
            }

            ent.use = GameTarget.use_target_secret;

            if (GameBase.st.noise == null)
            {
                GameBase.st.noise = "misc/secret.wav";
            }

            ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise);
            ent.svflags     = Defines.SVF_NOCLIENT;
            GameBase.level.total_secrets++;

            // map bug hack
            if (0 == Lib.Q_stricmp(GameBase.level.mapname, "mine3") && ent.s.origin[0] == 280 && ent.s.origin[1] == -2048 && ent.s.origin[2] == -624)
            {
                ent.message = "You have found a secret area.";
            }
        }
Example #2
0
        public static void SP_trigger_gravity(edict_t self)
        {
            if (GameBase.st.gravity == null)
            {
                GameBase.gi.dprintf("trigger_gravity without gravity set at " + Lib.vtos(self.s.origin) + "\n");
                GameUtil.G_FreeEdict(self);

                return;
            }

            GameTrigger.InitTrigger(self);
            self.gravity = Lib.atoi(GameBase.st.gravity);
            self.touch   = GameTrigger.trigger_gravity_touch;
        }
Example #3
0
        public static void SP_turret_driver(edict_t self)
        {
            if (GameBase.deathmatch.value != 0)
            {
                GameUtil.G_FreeEdict(self);

                return;
            }

            self.movetype     = Defines.MOVETYPE_PUSH;
            self.solid        = Defines.SOLID_BBOX;
            self.s.modelindex = GameBase.gi.modelindex("models/monsters/infantry/tris.md2");
            Math3D.VectorSet(self.mins, -16, -16, -24);
            Math3D.VectorSet(self.maxs, 16, 16, 32);

            self.health     = 100;
            self.gib_health = 0;
            self.mass       = 200;
            self.viewheight = 24;

            self.die = GameTurret.turret_driver_die;
            self.monsterinfo.stand = M_Infantry.infantry_stand;

            self.flags |= Defines.FL_NO_KNOCKBACK;

            GameBase.level.total_monsters++;

            self.svflags    |= Defines.SVF_MONSTER;
            self.s.renderfx |= Defines.RF_FRAMELERP;
            self.takedamage  = Defines.DAMAGE_AIM;
            self.use         = GameUtil.monster_use;
            self.clipmask    = Defines.MASK_MONSTERSOLID;
            Math3D.VectorCopy(self.s.origin, self.s.old_origin);
            self.monsterinfo.aiflags |= Defines.AI_STAND_GROUND | Defines.AI_DUCKED;

            if (GameBase.st.item != null)
            {
                self.item = GameItems.FindItemByClassname(GameBase.st.item);

                if (self.item == null)
                {
                    GameBase.gi.dprintf(self.classname + " at " + Lib.vtos(self.s.origin) + " has bad item: " + GameBase.st.item + "\n");
                }
            }

            self.think     = GameTurret.turret_driver_link;
            self.nextthink = GameBase.level.time + Defines.FRAMETIME;

            GameBase.gi.linkentity(self);
        }
Example #4
0
        public static void SP_target_changelevel(edict_t ent)
        {
            if (ent.map == null)
            {
                GameBase.gi.dprintf("target_changelevel with no map at " + Lib.vtos(ent.s.origin) + "\n");
                GameUtil.G_FreeEdict(ent);

                return;
            }

            // ugly hack because *SOMEBODY* screwed up their map
            if (Lib.Q_stricmp(GameBase.level.mapname, "fact1") == 0 && Lib.Q_stricmp(ent.map, "fact3") == 0)
            {
                ent.map = "fact3$secret1";
            }

            ent.use     = GameTarget.use_target_changelevel;
            ent.svflags = Defines.SVF_NOCLIENT;
        }
Example #5
0
        /**
         * QUAKED target_help (1 0 1) (-16 -16 -24) (16 16 24) help1 When fired, the
         * "message" key becomes the current personal computer string, and the
         * message light will be set on all clients status bars.
         */
        public static void SP_target_help(edict_t ent)
        {
            if (GameBase.deathmatch.value != 0)
            {
                // auto-remove for deathmatch
                GameUtil.G_FreeEdict(ent);

                return;
            }

            if (ent.message == null)
            {
                GameBase.gi.dprintf(ent.classname + " with no message at " + Lib.vtos(ent.s.origin) + "\n");
                GameUtil.G_FreeEdict(ent);

                return;
            }

            ent.use = GameTarget.Use_Target_Help;
        }
Example #6
0
        public static void SP_target_goal(edict_t ent)
        {
            if (GameBase.deathmatch.value != 0)
            {
                // auto-remove for deathmatch
                GameUtil.G_FreeEdict(ent);

                return;
            }

            ent.use = GameTarget.use_target_goal;

            if (GameBase.st.noise == null)
            {
                GameBase.st.noise = "misc/secret.wav";
            }

            ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise);
            ent.svflags     = Defines.SVF_NOCLIENT;
            GameBase.level.total_goals++;
        }
Example #7
0
        public static void SP_target_lightramp(edict_t self)
        {
            if (self.message == null ||
                self.message.Length != 2 ||
                self.message[0] < 'a' ||
                self.message[0] > 'z' ||
                self.message[1] < 'a' ||
                self.message[1] > 'z' ||
                self.message[0] == self.message[1])
            {
                GameBase.gi.dprintf("target_lightramp has bad ramp (" + self.message + ") at " + Lib.vtos(self.s.origin) + "\n");
                GameUtil.G_FreeEdict(self);

                return;
            }

            if (GameBase.deathmatch.value != 0)
            {
                GameUtil.G_FreeEdict(self);

                return;
            }

            if (self.target == null)
            {
                GameBase.gi.dprintf(self.classname + " with no target at " + Lib.vtos(self.s.origin) + "\n");
                GameUtil.G_FreeEdict(self);

                return;
            }

            self.svflags |= Defines.SVF_NOCLIENT;
            self.use      = GameTarget.target_lightramp_use;
            self.think    = GameTarget.target_lightramp_think;

            self.movedir[0] = self.message[0] - 'a';
            self.movedir[1] = self.message[1] - 'a';
            self.movedir[2] = (self.movedir[1] - self.movedir[0]) / (self.speed / Defines.FRAMETIME);
        }
Example #8
0
        /**
         * Cmd_Give_f
         *
         * Give items to a client.
         */
        public static void Give_f(edict_t ent)
        {
            string  name;
            gitem_t it;
            int     index;
            int     i;
            bool    give_all;
            edict_t it_ent;

            if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
            {
                SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\n");

                return;
            }

            name = Cmd.Args();

            if (0 == Lib.Q_stricmp(name, "all"))
            {
                give_all = true;
            }
            else
            {
                give_all = false;
            }

            if (give_all || 0 == Lib.Q_stricmp(Cmd.Argv(1), "health"))
            {
                if (Cmd.Argc() == 3)
                {
                    ent.health = Lib.atoi(Cmd.Argv(2));
                }
                else
                {
                    ent.health = ent.max_health;
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || 0 == Lib.Q_stricmp(name, "weapons"))
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (null == it.pickup)
                    {
                        continue;
                    }

                    if (0 == (it.flags & Defines.IT_WEAPON))
                    {
                        continue;
                    }

                    ent.client.pers.inventory[i] += 1;
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || 0 == Lib.Q_stricmp(name, "ammo"))
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (null == it.pickup)
                    {
                        continue;
                    }

                    if (0 == (it.flags & Defines.IT_AMMO))
                    {
                        continue;
                    }

                    GameItems.Add_Ammo(ent, it, 1000);
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || Lib.Q_stricmp(name, "armor") == 0)
            {
                gitem_armor_t info;

                it = GameItems.FindItem("Jacket Armor");
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;

                it = GameItems.FindItem("Combat Armor");
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;

                it   = GameItems.FindItem("Body Armor");
                info = (gitem_armor_t)it.info;
                ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = info.max_count;

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0)
            {
                it               = GameItems.FindItem("Power Shield");
                it_ent           = GameUtil.G_Spawn();
                it_ent.classname = it.classname;
                GameItems.SpawnItem(it_ent, it);
                GameItems.Touch_Item.touch(it_ent, ent, GameBase.dummyplane, null);

                if (it_ent.inuse)
                {
                    GameUtil.G_FreeEdict(it_ent);
                }

                if (!give_all)
                {
                    return;
                }
            }

            if (give_all)
            {
                for (i = 1; i < GameBase.game.num_items; i++)
                {
                    it = GameItemList.itemlist[i];

                    if (it.pickup != null)
                    {
                        continue;
                    }

                    if ((it.flags & (Defines.IT_ARMOR | Defines.IT_WEAPON | Defines.IT_AMMO)) != 0)
                    {
                        continue;
                    }

                    ent.client.pers.inventory[i] = 1;
                }

                return;
            }

            it = GameItems.FindItem(name);

            if (it == null)
            {
                name = Cmd.Argv(1);
                it   = GameItems.FindItem(name);

                if (it == null)
                {
                    SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item\n");

                    return;
                }
            }

            if (it.pickup == null)
            {
                SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\n");

                return;
            }

            index = GameItems.ITEM_INDEX(it);

            if ((it.flags & Defines.IT_AMMO) != 0)
            {
                if (Cmd.Argc() == 3)
                {
                    ent.client.pers.inventory[index] = Lib.atoi(Cmd.Argv(2));
                }
                else
                {
                    ent.client.pers.inventory[index] += it.quantity;
                }
            }
            else
            {
                it_ent           = GameUtil.G_Spawn();
                it_ent.classname = it.classname;
                GameItems.SpawnItem(it_ent, it);
                GameItems.Touch_Item.touch(it_ent, ent, GameBase.dummyplane, null);

                if (it_ent.inuse)
                {
                    GameUtil.G_FreeEdict(it_ent);
                }
            }
        }
Example #9
0
        // ============================================================================
        public static bool monster_start(edict_t self)
        {
            if (GameBase.deathmatch.value != 0)
            {
                GameUtil.G_FreeEdict(self);

                return(false);
            }

            if ((self.spawnflags & 4) != 0 && 0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY))
            {
                self.spawnflags &= ~4;
                self.spawnflags |= 1;

                //		 gi.dprintf("fixed spawnflags on %s at %s\n", self.classname,
                // vtos(self.s.origin));
            }

            if (0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY))
            {
                GameBase.level.total_monsters++;
            }

            self.nextthink    = GameBase.level.time + Defines.FRAMETIME;
            self.svflags     |= Defines.SVF_MONSTER;
            self.s.renderfx  |= Defines.RF_FRAMELERP;
            self.takedamage   = Defines.DAMAGE_AIM;
            self.air_finished = GameBase.level.time + 12;
            self.use          = GameUtil.monster_use;
            self.max_health   = self.health;
            self.clipmask     = Defines.MASK_MONSTERSOLID;

            self.s.skinnum = 0;
            self.deadflag  = Defines.DEAD_NO;
            self.svflags  &= ~Defines.SVF_DEADMONSTER;

            if (null == self.monsterinfo.checkattack)
            {
                self.monsterinfo.checkattack = GameUtil.M_CheckAttack;
            }

            Math3D.VectorCopy(self.s.origin, self.s.old_origin);

            if (GameBase.st.item != null && GameBase.st.item.Length > 0)
            {
                self.item = GameItems.FindItemByClassname(GameBase.st.item);

                if (self.item == null)
                {
                    GameBase.gi.dprintf("monster_start:" + self.classname + " at " + Lib.vtos(self.s.origin) + " has bad item: " + GameBase.st.item + "\n");
                }
            }

            // randomize what frame they start on
            if (self.monsterinfo.currentmove != null)
            {
                self.s.frame = self.monsterinfo.currentmove.firstframe
                               + Lib.rand() % (self.monsterinfo.currentmove.lastframe - self.monsterinfo.currentmove.firstframe + 1);
            }

            return(true);
        }
Example #10
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;
                    }
                }
            }
        }