示例#1
0
            public override bool Think(edict_t self)
            {
                edict_t ent;
                float   points;

                float[]       v = new float[] { 0, 0, 0 };
                float         dist;
                EdictIterator edit = null;

                if (self.s.frame == 0)
                {
                    ent = null;
                    while ((edit = GameBase.Findradius(edit, self.s.origin, self.dmg_radius)) != null)
                    {
                        ent = edit.o;
                        if (ent.takedamage == 0)
                        {
                            continue;
                        }
                        if (ent == self.owner)
                        {
                            continue;
                        }
                        if (!GameCombat.CanDamage(ent, self))
                        {
                            continue;
                        }
                        if (!GameCombat.CanDamage(ent, self.owner))
                        {
                            continue;
                        }
                        Math3D.VectorAdd(ent.mins, ent.maxs, v);
                        Math3D.VectorMA(ent.s.origin, 0.5F, v, v);
                        Math3D.VectorSubtract(self.s.origin, v, v);
                        dist   = Math3D.VectorLength(v);
                        points = (float)(self.radius_dmg * (1 - Math.Sqrt(dist / self.dmg_radius)));
                        if (ent == self.owner)
                        {
                            points = points * 0.5F;
                        }
                        GameBase.gi.WriteByte(Defines.svc_temp_entity);
                        GameBase.gi.WriteByte(Defines.TE_BFG_EXPLOSION);
                        GameBase.gi.WritePosition(ent.s.origin);
                        GameBase.gi.Multicast(ent.s.origin, Defines.MULTICAST_PHS);
                        GameCombat.T_Damage(ent, self, self.owner, self.velocity, ent.s.origin, Globals.vec3_origin, (int)points, 0, Defines.DAMAGE_ENERGY, Defines.MOD_BFG_EFFECT);
                    }
                }

                self.nextthink = GameBase.level.time + Defines.FRAMETIME;
                self.s.frame++;
                if (self.s.frame == 5)
                {
                    self.think = GameUtil.G_FreeEdictA;
                }
                return(true);
            }
示例#2
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);
                    }
                }
            }
        }
示例#3
0
            public override bool Think(edict_t self)
            {
                edict_t ent;
                edict_t ignore;

                float[] point = new float[] { 0, 0, 0 };
                float[] dir   = new float[] { 0, 0, 0 };
                float[] start = new float[] { 0, 0, 0 };
                float[] end   = new float[] { 0, 0, 0 };
                int     dmg;
                trace_t tr;

                if (GameBase.deathmatch.value != 0)
                {
                    dmg = 5;
                }
                else
                {
                    dmg = 10;
                }
                EdictIterator edit = null;

                while ((edit = GameBase.Findradius(edit, self.s.origin, 256)) != null)
                {
                    ent = edit.o;
                    if (ent == self)
                    {
                        continue;
                    }
                    if (ent == self.owner)
                    {
                        continue;
                    }
                    if (ent.takedamage == 0)
                    {
                        continue;
                    }
                    if (0 == (ent.svflags & Defines.SVF_MONSTER) && (null == ent.client) && (Lib.Strcmp(ent.classname, "misc_explobox") != 0))
                    {
                        continue;
                    }
                    Math3D.VectorMA(ent.absmin, 0.5F, ent.size, point);
                    Math3D.VectorSubtract(point, self.s.origin, dir);
                    Math3D.VectorNormalize(dir);
                    ignore = self;
                    Math3D.VectorCopy(self.s.origin, start);
                    Math3D.VectorMA(start, 2048, dir, end);
                    while (true)
                    {
                        tr = GameBase.gi.Trace(start, null, null, end, ignore, Defines.CONTENTS_SOLID | Defines.CONTENTS_MONSTER | Defines.CONTENTS_DEADMONSTER);
                        if (null == tr.ent)
                        {
                            break;
                        }
                        if ((tr.ent.takedamage != 0) && 0 == (tr.ent.flags & Defines.FL_IMMUNE_LASER) && (tr.ent != self.owner))
                        {
                            GameCombat.T_Damage(tr.ent, self, self.owner, dir, tr.endpos, Globals.vec3_origin, dmg, 1, Defines.DAMAGE_ENERGY, Defines.MOD_BFG_LASER);
                        }
                        if (0 == (tr.ent.svflags & Defines.SVF_MONSTER) && (null == tr.ent.client))
                        {
                            GameBase.gi.WriteByte(Defines.svc_temp_entity);
                            GameBase.gi.WriteByte(Defines.TE_LASER_SPARKS);
                            GameBase.gi.WriteByte(4);
                            GameBase.gi.WritePosition(tr.endpos);
                            GameBase.gi.WriteDir(tr.plane.normal);
                            GameBase.gi.WriteByte(self.s.skinnum);
                            GameBase.gi.Multicast(tr.endpos, Defines.MULTICAST_PVS);
                            break;
                        }

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

                    GameBase.gi.WriteByte(Defines.svc_temp_entity);
                    GameBase.gi.WriteByte(Defines.TE_BFG_LASER);
                    GameBase.gi.WritePosition(self.s.origin);
                    GameBase.gi.WritePosition(tr.endpos);
                    GameBase.gi.Multicast(self.s.origin, Defines.MULTICAST_PHS);
                }

                self.nextthink = GameBase.level.time + Defines.FRAMETIME;
                return(true);
            }