Beispiel #1
0
        public static edict_t PickNext(edict_t self)
        {
            int marker;
            int n;

            if (!trail_active)
            {
                return(null);
            }
            for (marker = trail_head, n = PlayerTrail.TRAIL_LENGTH; n > 0; n--)
            {
                if (PlayerTrail.trail[marker].timestamp <= self.monsterinfo.trail_time)
                {
                    marker = NEXT(marker);
                }
                else
                {
                    break;
                }
            }

            return(PlayerTrail.trail[marker]);
        }
Beispiel #2
0
        public static void G_RunEntity(edict_t ent)
        {
            if (ent.prethink != null)
            {
                ent.prethink.Think(ent);
            }
            switch ((int)ent.movetype)
            {
            case Defines.MOVETYPE_PUSH:
            case Defines.MOVETYPE_STOP:
                SV.SV_Physics_Pusher(ent);
                break;

            case Defines.MOVETYPE_NONE:
                SV.SV_Physics_None(ent);
                break;

            case Defines.MOVETYPE_NOCLIP:
                SV.SV_Physics_Noclip(ent);
                break;

            case Defines.MOVETYPE_STEP:
                SV.SV_Physics_Step(ent);
                break;

            case Defines.MOVETYPE_TOSS:
            case Defines.MOVETYPE_BOUNCE:
            case Defines.MOVETYPE_FLY:
            case Defines.MOVETYPE_FLYMISSILE:
                SV.SV_Physics_Toss(ent);
                break;

            default:
                gi.Error("SV_Physics: bad movetype " + (int)ent.movetype);
                break;
            }
        }
Beispiel #3
0
            public override void Use(edict_t self, edict_t other, edict_t activator)
            {
                if (self.enemy == null)
                {
                    edict_t e;
                    e = null;
                    EdictIterator es = null;
                    while (true)
                    {
                        es = GameBase.G_Find(es, GameBase.findByTarget, self.target);
                        if (es == null)
                        {
                            break;
                        }
                        e = es.o;
                        if (Lib.Strcmp(e.classname, "light") != 0)
                        {
                            GameBase.gi.Dprintf(self.classname + " at " + Lib.Vtos(self.s.origin));
                            GameBase.gi.Dprintf("target " + self.target + " (" + e.classname + " at " + Lib.Vtos(e.s.origin) + ") is not a light\\n");
                        }
                        else
                        {
                            self.enemy = e;
                        }
                    }

                    if (null == self.enemy)
                    {
                        GameBase.gi.Dprintf(self.classname + " target " + self.target + " not found at " + Lib.Vtos(self.s.origin) + "\\n");
                        GameUtil.G_FreeEdict(self);
                        return;
                    }
                }

                self.timestamp = GameBase.level.time;
                target_lightramp_think.Think(self);
            }
Beispiel #4
0
        public static void G_TouchTriggers(edict_t ent)
        {
            int     i, num;
            edict_t hit;

            if ((ent.client != null || (ent.svflags & Defines.SVF_MONSTER) != 0) && (ent.health <= 0))
            {
                return;
            }
            num = gi.BoxEdicts(ent.absmin, ent.absmax, touch, Defines.MAX_EDICTS, Defines.AREA_TRIGGERS);
            for (i = 0; i < num; i++)
            {
                hit = touch[i];
                if (!hit.inuse)
                {
                    continue;
                }
                if (hit.touch == null)
                {
                    continue;
                }
                hit.touch.Touch(hit, ent, dummyplane, null);
            }
        }
Beispiel #5
0
        public static void T_RadiusDamage(edict_t inflictor, edict_t attacker, float damage, edict_t ignore, float radius, int mod)
        {
            float         points;
            EdictIterator edictit = null;

            float[] v   = new float[] { 0, 0, 0 };
            float[] dir = new float[] { 0, 0, 0 };
            while ((edictit = GameBase.Findradius(edictit, inflictor.s.origin, radius)) != null)
            {
                edict_t ent = edictit.o;
                if (ent == ignore)
                {
                    continue;
                }
                if (ent.takedamage == 0)
                {
                    continue;
                }
                Math3D.VectorAdd(ent.mins, ent.maxs, v);
                Math3D.VectorMA(ent.s.origin, 0.5F, v, v);
                Math3D.VectorSubtract(inflictor.s.origin, v, v);
                points = damage - 0.5F * Math3D.VectorLength(v);
                if (ent == attacker)
                {
                    points = points * 0.5F;
                }
                if (points > 0)
                {
                    if (CanDamage(ent, inflictor))
                    {
                        Math3D.VectorSubtract(ent.s.origin, inflictor.s.origin, dir);
                        T_Damage(ent, inflictor, attacker, dir, inflictor.s.origin, Globals.vec3_origin, (int)points, (int)points, Defines.DAMAGE_RADIUS, mod);
                    }
                }
            }
        }
Beispiel #6
0
        public static void WeapPrev_f(edict_t ent)
        {
            gclient_t cl;
            Int32     i, index;
            gitem_t   it;
            Int32     selected_weapon;

            cl = ent.client;
            if (cl.pers.weapon == null)
            {
                return;
            }
            selected_weapon = GameItems.ITEM_INDEX(cl.pers.weapon);
            for (i = 1; i <= Defines.MAX_ITEMS; i++)
            {
                index = (selected_weapon + i) % Defines.MAX_ITEMS;
                if (0 == cl.pers.inventory[index])
                {
                    continue;
                }
                it = GameItemList.itemlist[index];
                if (it.use == null)
                {
                    continue;
                }
                if (0 == (it.flags & Defines.IT_WEAPON))
                {
                    continue;
                }
                it.use.Use(ent, it);
                if (cl.pers.weapon == it)
                {
                    return;
                }
            }
        }
Beispiel #7
0
            public override void Touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf)
            {
                if (other == ent.owner)
                {
                    return;
                }
                if (surf != null && 0 != (surf.flags & Defines.SURF_SKY))
                {
                    GameUtil.G_FreeEdict(ent);
                    return;
                }

                if (other.takedamage == 0)
                {
                    if ((ent.spawnflags & 1) != 0)
                    {
                        if (Lib.Random() > 0.5F)
                        {
                            GameBase.gi.Sound(ent, Defines.CHAN_VOICE, GameBase.gi.Soundindex("weapons/hgrenb1a.wav"), 1, Defines.ATTN_NORM, 0);
                        }
                        else
                        {
                            GameBase.gi.Sound(ent, Defines.CHAN_VOICE, GameBase.gi.Soundindex("weapons/hgrenb2a.wav"), 1, Defines.ATTN_NORM, 0);
                        }
                    }
                    else
                    {
                        GameBase.gi.Sound(ent, Defines.CHAN_VOICE, GameBase.gi.Soundindex("weapons/grenlb1b.wav"), 1, Defines.ATTN_NORM, 0);
                    }

                    return;
                }

                ent.enemy = other;
                Grenade_Explode.Think(ent);
            }
Beispiel #8
0
 public static void SP_turret_breach(edict_t self)
 {
     self.solid    = Defines.SOLID_BSP;
     self.movetype = Defines.MOVETYPE_PUSH;
     GameBase.gi.Setmodel(self, self.model);
     if (self.speed == 0)
     {
         self.speed = 50;
     }
     if (self.dmg == 0)
     {
         self.dmg = 10;
     }
     if (GameBase.st.minpitch == 0)
     {
         GameBase.st.minpitch = -30;
     }
     if (GameBase.st.maxpitch == 0)
     {
         GameBase.st.maxpitch = 30;
     }
     if (GameBase.st.maxyaw == 0)
     {
         GameBase.st.maxyaw = 360;
     }
     self.pos1[Defines.PITCH]      = -1 * GameBase.st.minpitch;
     self.pos1[Defines.YAW]        = GameBase.st.minyaw;
     self.pos2[Defines.PITCH]      = -1 * GameBase.st.maxpitch;
     self.pos2[Defines.YAW]        = GameBase.st.maxyaw;
     self.ideal_yaw                = self.s.angles[Defines.YAW];
     self.move_angles[Defines.YAW] = self.ideal_yaw;
     self.blocked   = turret_blocked;
     self.think     = turret_breach_finish_init;
     self.nextthink = GameBase.level.time + Defines.FRAMETIME;
     GameBase.gi.Linkentity(self);
 }
Beispiel #9
0
        static void Check_dodge(edict_t self, float[] start, float[] dir, int speed)
        {
            float[] end = new float[] { 0, 0, 0 };
            float[] v   = new float[] { 0, 0, 0 };
            trace_t tr;
            float   eta;

            if (GameBase.skill.value == 0)
            {
                if (Lib.Random() > 0.25)
                {
                    return;
                }
            }

            Math3D.VectorMA(start, 8192, dir, end);
            tr = GameBase.gi.Trace(start, null, null, end, self, Defines.MASK_SHOT);
            if ((tr.ent != null) && (tr.ent.svflags & Defines.SVF_MONSTER) != 0 && (tr.ent.health > 0) && (null != tr.ent.monsterinfo.dodge) && GameUtil.Infront(tr.ent, self))
            {
                Math3D.VectorSubtract(tr.endpos, start, v);
                eta = (Math3D.VectorLength(v) - tr.ent.maxs[0]) / speed;
                tr.ent.monsterinfo.dodge.Dodge(tr.ent, self, eta);
            }
        }
Beispiel #10
0
 public static void SP_target_explosion(edict_t ent)
 {
     ent.use     = use_target_explosion;
     ent.svflags = Defines.SVF_NOCLIENT;
 }
Beispiel #11
0
 public static void SP_target_temp_entity(edict_t ent)
 {
     ent.use = Use_Target_Tent;
 }
Beispiel #12
0
 public virtual void Setmodel(edict_t ent, string name)
 {
     SV_GAME.PF_setmodel(ent, name);
 }
 public abstract void Blocked(edict_t self, edict_t other);
Beispiel #14
0
 public virtual void Sound(edict_t ent, int channel, int soundindex, float volume, float attenuation, float timeofs)
 {
     SV_GAME.PF_StartSound(ent, channel, soundindex, volume, attenuation, timeofs);
 }
Beispiel #15
0
 public virtual void Cprintf(edict_t ent, int printlevel, string s)
 {
     SV_GAME.PF_cprintf(ent, printlevel, s);
 }
Beispiel #16
0
 public virtual void Unlinkentity(edict_t ent)
 {
     SV_WORLD.SV_UnlinkEdict(ent);
 }
Beispiel #17
0
 public abstract void Ai(edict_t self, float dist);
Beispiel #18
0
 public static void PutAway_f(edict_t ent)
 {
     ent.client.showscores    = false;
     ent.client.showhelp      = false;
     ent.client.showinventory = false;
 }
Beispiel #19
0
 public virtual void Unicast(edict_t ent, bool reliable)
 {
     SV_GAME.PF_Unicast(ent, reliable);
 }
Beispiel #20
0
 public static void SP_target_crosslevel_trigger(edict_t self)
 {
     self.svflags = Defines.SVF_NOCLIENT;
     self.use     = trigger_crosslevel_trigger_use;
 }
Beispiel #21
0
 public virtual void Centerprintf(edict_t ent, string s)
 {
     SV_GAME.PF_centerprintf(ent, s);
 }
Beispiel #22
0
 public static void Target_laser_off(edict_t self)
 {
     self.spawnflags &= ~1;
     self.svflags    |= Defines.SVF_NOCLIENT;
     self.nextthink   = 0;
 }
Beispiel #23
0
 public virtual void Positioned_sound(float[] origin, edict_t ent, int channel, int soundinedex, float volume, float attenuation, float timeofs)
 {
     SV_SEND.SV_StartSound(origin, ent, channel, soundinedex, volume, attenuation, timeofs);
 }
Beispiel #24
0
 public static void SP_target_laser(edict_t self)
 {
     self.think     = target_laser_start;
     self.nextthink = GameBase.level.time + 1;
 }
Beispiel #25
0
 public virtual trace_t Trace(float[] start, float[] mins, float[] maxs, float[] end, edict_t passent, int contentmask)
 {
     return(SV_WORLD.SV_Trace(start, mins, maxs, end, passent, contentmask));
 }
Beispiel #26
0
 public override void Use(edict_t self, edict_t other, edict_t activator)
 {
     GameBase.game.serverflags |= self.spawnflags;
     GameUtil.G_FreeEdict(self);
 }
Beispiel #27
0
            public override bool Think(edict_t self)
            {
                edict_t ent;

                float[] current_angles = new float[] { 0, 0, 0 };
                float[] delta          = new float[] { 0, 0, 0 };
                Math3D.VectorCopy(self.s.angles, current_angles);
                AnglesNormalize(current_angles);
                AnglesNormalize(self.move_angles);
                if (self.move_angles[Defines.PITCH] > 180)
                {
                    self.move_angles[Defines.PITCH] -= 360;
                }
                if (self.move_angles[Defines.PITCH] > self.pos1[Defines.PITCH])
                {
                    self.move_angles[Defines.PITCH] = self.pos1[Defines.PITCH];
                }
                else if (self.move_angles[Defines.PITCH] < self.pos2[Defines.PITCH])
                {
                    self.move_angles[Defines.PITCH] = self.pos2[Defines.PITCH];
                }
                if ((self.move_angles[Defines.YAW] < self.pos1[Defines.YAW]) || (self.move_angles[Defines.YAW] > self.pos2[Defines.YAW]))
                {
                    float dmin, dmax;
                    dmin = Math.Abs(self.pos1[Defines.YAW] - self.move_angles[Defines.YAW]);
                    if (dmin < -180)
                    {
                        dmin += 360;
                    }
                    else if (dmin > 180)
                    {
                        dmin -= 360;
                    }
                    dmax = Math.Abs(self.pos2[Defines.YAW] - self.move_angles[Defines.YAW]);
                    if (dmax < -180)
                    {
                        dmax += 360;
                    }
                    else if (dmax > 180)
                    {
                        dmax -= 360;
                    }
                    if (Math.Abs(dmin) < Math.Abs(dmax))
                    {
                        self.move_angles[Defines.YAW] = self.pos1[Defines.YAW];
                    }
                    else
                    {
                        self.move_angles[Defines.YAW] = self.pos2[Defines.YAW];
                    }
                }

                Math3D.VectorSubtract(self.move_angles, current_angles, delta);
                if (delta[0] < -180)
                {
                    delta[0] += 360;
                }
                else if (delta[0] > 180)
                {
                    delta[0] -= 360;
                }
                if (delta[1] < -180)
                {
                    delta[1] += 360;
                }
                else if (delta[1] > 180)
                {
                    delta[1] -= 360;
                }
                delta[2] = 0;
                if (delta[0] > self.speed * Defines.FRAMETIME)
                {
                    delta[0] = self.speed * Defines.FRAMETIME;
                }
                if (delta[0] < -1 * self.speed * Defines.FRAMETIME)
                {
                    delta[0] = -1 * self.speed * Defines.FRAMETIME;
                }
                if (delta[1] > self.speed * Defines.FRAMETIME)
                {
                    delta[1] = self.speed * Defines.FRAMETIME;
                }
                if (delta[1] < -1 * self.speed * Defines.FRAMETIME)
                {
                    delta[1] = -1 * self.speed * Defines.FRAMETIME;
                }
                Math3D.VectorScale(delta, 1F / Defines.FRAMETIME, self.avelocity);
                self.nextthink = GameBase.level.time + Defines.FRAMETIME;
                for (ent = self.teammaster; ent != null; ent = ent.teamchain)
                {
                    ent.avelocity[1] = self.avelocity[1];
                }
                if (self.owner != null)
                {
                    float   angle;
                    float   target_z;
                    float   diff;
                    float[] target = new float[] { 0, 0, 0 };
                    float[] dir    = new float[] { 0, 0, 0 };
                    self.owner.avelocity[0] = self.avelocity[0];
                    self.owner.avelocity[1] = self.avelocity[1];
                    angle     = self.s.angles[1] + self.owner.move_origin[1];
                    angle    *= (float)(Math.PI * 2 / 360);
                    target[0] = GameTurret.SnapToEights((float)(self.s.origin[0] + Math.Cos(angle) * self.owner.move_origin[0]));
                    target[1] = GameTurret.SnapToEights((float)(self.s.origin[1] + Math.Sin(angle) * self.owner.move_origin[0]));
                    target[2] = self.owner.s.origin[2];
                    Math3D.VectorSubtract(target, self.owner.s.origin, dir);
                    self.owner.velocity[0] = dir[0] * 1F / Defines.FRAMETIME;
                    self.owner.velocity[1] = dir[1] * 1F / Defines.FRAMETIME;
                    angle    = self.s.angles[Defines.PITCH] * (float)(Math.PI * 2F / 360F);
                    target_z = GameTurret.SnapToEights((float)(self.s.origin[2] + self.owner.move_origin[0] * Math.Tan(angle) + self.owner.move_origin[2]));
                    diff     = target_z - self.owner.s.origin[2];
                    self.owner.velocity[2] = diff * 1F / Defines.FRAMETIME;
                    if ((self.spawnflags & 65536) != 0)
                    {
                        Turret_breach_fire(self);
                        self.spawnflags &= ~65536;
                    }
                }

                return(true);
            }
Beispiel #28
0
            public override Boolean Think(edict_t self)
            {
                edict_t ignore;

                Single[] start = new Single[] { 0, 0, 0 };
                Single[] end   = new Single[] { 0, 0, 0 };
                trace_t  tr;

                Single[] point        = new Single[] { 0, 0, 0 };
                Single[] last_movedir = new Single[] { 0, 0, 0 };
                Int32    count;

                if ((self.spawnflags & 0x80000000) != 0)
                {
                    count = 8;
                }
                else
                {
                    count = 4;
                }
                if (self.enemy != null)
                {
                    Math3D.VectorCopy(self.movedir, last_movedir);
                    Math3D.VectorMA(self.enemy.absmin, 0.5F, self.enemy.size, point);
                    Math3D.VectorSubtract(point, self.s.origin, self.movedir);
                    Math3D.VectorNormalize(self.movedir);
                    if (!Math3D.VectorEquals(self.movedir, last_movedir))
                    {
                        self.spawnflags = ( Int32 )(self.spawnflags | 0x80000000);
                    }
                }

                ignore = self;
                Math3D.VectorCopy(self.s.origin, start);
                Math3D.VectorMA(start, 2048, self.movedir, end);
                while (true)
                {
                    tr = GameBase.gi.Trace(start, null, null, end, ignore, Defines.CONTENTS_SOLID | Defines.CONTENTS_MONSTER | Defines.CONTENTS_DEADMONSTER);
                    if (tr.ent == null)
                    {
                        break;
                    }
                    if ((tr.ent.takedamage != 0) && 0 == (tr.ent.flags & Defines.FL_IMMUNE_LASER))
                    {
                        GameCombat.T_Damage(tr.ent, self, self.activator, self.movedir, tr.endpos, Globals.vec3_origin, self.dmg, 1, Defines.DAMAGE_ENERGY, Defines.MOD_TARGET_LASER);
                    }
                    if (0 == (tr.ent.svflags & Defines.SVF_MONSTER) && (null == tr.ent.client))
                    {
                        if ((self.spawnflags & 0x80000000) != 0)
                        {
                            self.spawnflags = ( Int32 )(self.spawnflags & ~0x80000000);
                            GameBase.gi.WriteByte(Defines.svc_temp_entity);
                            GameBase.gi.WriteByte(Defines.TE_LASER_SPARKS);
                            GameBase.gi.WriteByte(count);
                            GameBase.gi.WritePosition(tr.endpos);
                            GameBase.gi.WriteDir(tr.plane.normal);
                            GameBase.gi.WriteByte(( Int32 )self.s.skinnum);                                // This cast might break something
                            GameBase.gi.Multicast(tr.endpos, Defines.MULTICAST_PVS);
                        }

                        break;
                    }

                    ignore = tr.ent;
                    Math3D.VectorCopy(tr.endpos, start);
                }

                Math3D.VectorCopy(tr.endpos, self.s.old_origin);
                self.nextthink = GameBase.level.time + Defines.FRAMETIME;
                return(true);
            }
Beispiel #29
0
 public abstract void Use(edict_t self, edict_t other, edict_t activator);
Beispiel #30
0
            public override Boolean Think(edict_t self)
            {
                self.movetype     = Defines.MOVETYPE_NONE;
                self.solid        = Defines.SOLID_NOT;
                self.s.renderfx  |= Defines.RF_BEAM | Defines.RF_TRANSLUCENT;
                self.s.modelindex = 1;
                if ((self.spawnflags & 64) != 0)
                {
                    self.s.frame = 16;
                }
                else
                {
                    self.s.frame = 4;
                }
                if ((self.spawnflags & 2) != 0)
                {
                    self.s.skinnum = unchecked (( Int32 )0xf2f2f0f0);
                }
                else if ((self.spawnflags & 4) != 0)
                {
                    self.s.skinnum = unchecked (( Int32 )0xd0d1d2d3);
                }
                else if ((self.spawnflags & 8) != 0)
                {
                    self.s.skinnum = unchecked (( Int32 )0xf3f3f1f1);
                }
                else if ((self.spawnflags & 16) != 0)
                {
                    self.s.skinnum = unchecked (( Int32 )0xdcdddedf);
                }
                else if ((self.spawnflags & 32) != 0)
                {
                    self.s.skinnum = unchecked (( Int32 )0xe0e1e2e3);
                }
                if (null == self.enemy)
                {
                    if (self.target != null)
                    {
                        EdictIterator edit = GameBase.G_Find(null, GameBase.findByTarget, self.target);
                        if (edit == null)
                        {
                            GameBase.gi.Dprintf(self.classname + " at " + Lib.Vtos(self.s.origin) + ": " + self.target + " is a bad target\\n");
                        }
                        self.enemy = edit.o;
                    }
                    else
                    {
                        GameBase.G_SetMovedir(self.s.angles, self.movedir);
                    }
                }

                self.use   = target_laser_use;
                self.think = target_laser_think;
                if (0 == self.dmg)
                {
                    self.dmg = 1;
                }
                Math3D.VectorSet(self.mins, -8, -8, -8);
                Math3D.VectorSet(self.maxs, 8, 8, 8);
                GameBase.gi.Linkentity(self);
                if ((self.spawnflags & 1) != 0)
                {
                    Target_laser_on(self);
                }
                else
                {
                    Target_laser_off(self);
                }
                return(true);
            }