bool DefaultEffects()
        {
            BarrelEffect eff = new BarrelEffect();

            eff.name = "PropaneExplosion";
            eff.damageMap["Blunt"]     = 50f;
            eff.damageMap["Heat"]      = 25f;
            eff.damageMap["Explosion"] = 25f;
            eff.minRadius = 0f;
            eff.maxRadius = 10f;
            eff.delay     = 3.5f;
            eff.chance    = 15f;
            eff.effects.Add("assets/prefabs/weapons/rocketlauncher/effects/rocket_explosion_incendiary.prefab");
            eff.effects.Add("assets/bundled/prefabs/fx/gas_explosion_small.prefab");
            eff.triggerEffect            = "assets/bundled/Prefabs/fx/weapons/landmine/landmine_trigger.prefab";
            eff.killInventory            = true;
            data.barrelEffects[eff.name] = eff;

            return(true);
        }
Beispiel #2
0
        // Explode barrel
        void explodeBarrel(LootContainer entity, Vector3 position)
        {
            BarrelEffect effect = data.barrelEffects[barrels[entity.net.ID]];

            if (effect.killInventory)
            {
                entity.inventory.Kill();                 // destroy inventory
            }
            barrels.Remove(entity.net.ID);
            Effect.server.Run(effect.triggerEffect, position);

            timer.Once(effect.delay, delegate() {
                // run effects
                foreach (object eff in effect.effects)
                {
                    Effect.server.Run(eff.ToString(), position);
                }
                // damage nearby entities
                doDamage(entity, position, effect);
            });
        }
Beispiel #3
0
        void doDamage(BaseCombatEntity entity, Vector3 position, BarrelEffect effect)
        {
            List <DamageTypeEntry> damage = new List <DamageTypeEntry>();

            foreach (KeyValuePair <string, float> entry in effect.damageMap)
            {
                if (!Enum.IsDefined(typeof(DamageType), entry.Key))
                {
                    PrintWarning(String.Format(GetMessage("Warning_InvalidDamageType"), entry.Key));
                    continue;
                }
                if (entry.Value == null || entry.Value < 0.0f)
                {
                    PrintWarning(String.Format(GetMessage("Warning_InvalidDamageValue"), new object[] { entry.Key, entry.Value }));
                    continue;
                }
                DamageTypeEntry d = new DamageTypeEntry();
                d.type   = (DamageType)Enum.Parse(typeof(DamageType), entry.Key);
                d.amount = entry.Value;
                damage.Add(d);
            }

            DamageUtil.RadiusDamage(entity, null, position, effect.minRadius, effect.maxRadius, damage, -1, false);
        }