I am using a nuke like explosion but when I call the /nuke command, players are not detected and only sometimes do other entities get detected. I also want to somehow implement this at the radtowns where the ExplosionFX goes off and damages entities in a radius.
So a little summary of my problems that I need help with.
Any and all help will be appreciated,
- Getting the /nuke command to work and damage players
- Damaging players when ExplosionFX is set off at radtown
Cheers
Here are snippits of the code that deal with this:
Code://variablesprivate float damage; private float radius; bool Multiplier=false; bool readyToCheck = false; Vector3 Nukepos = new Vector3(0,0,0); Vector3 Powerpos = new Vector3(0,0,0); Vector3 Plantpos = new Vector3(0,0,0); Vector3 Trainpos = new Vector3(0,0,0); Vector3 Radpos = new Vector3(0,0,0); void OnServerInitialized() { damage = 600f; radius = 1000f; }Code://Nuke command [ChatCommand("nuke")] void cmdNuke(BasePlayer player) { string id = rust.UserIDFromPlayer(player); if (!IsAllowed(player, "CanUseAdminshit")) return; Nukepos=player.transform.position; ExplosionFX(Nukepos); List<BaseCombatEntity> entities1 = new List<BaseCombatEntity>(); Vis.Entities<BaseCombatEntity>(Nukepos, radius, entities1); rust.BroadcastChat("Radius: "+radius*1.5); foreach (BaseCombatEntity e in entities1) { if rust.BroadcastChat(""+e); e.Hurt(damage, global::Rust.DamageType.Explosion, player, false); } }Code://ExplosionFX and finding rad towns etc. void ExplosionFX(Vector3 pos) { Effect.server.Run(prefabExplosion, pos + Vector3.zero); timer.Once(0.00f, () => ExplosionFXUP(pos)); timer.Once(0.1f, () => ExplosionFX10(pos)); timer.Once(0.2f, () => ExplosionFX20(pos)); timer.Once(0.5f, () => ExplosionFXDome20(pos)); timer.Once(0.3f, () => ExplosionFX30(pos)); timer.Once(0.6f, () => ExplosionFXDome30(pos)); } private void findNukeZone() { var allobjects = UnityEngine.Object.FindObjectsOfType<GameObject>(); foreach (var gobject in allobjects) { if (gobject.name.ToLower().Contains("powerplant_1")) { Vector3 Powerpos = gobject.transform.position; } if (gobject.name.ToLower().Contains("large/water_treatment_plant_1")) { Vector3 Waterpos = gobject.transform.position; } if (gobject.name.ToLower().Contains("large/trainyard_1")) { Vector3 Trainpos = gobject.transform.position; } if (gobject.name.ToLower().Contains("small/radtown_small_3")) { Vector3 Radpos = gobject.transform.position; } } }
Hurting/damaging players in a radius?
Discussion in 'Rust Development' started by spleen, Mar 15, 2016.
-
Look at my plugin Boobytraps to see how to deal radius damage
-
My code looks the same other than the fact that you are using 3 different damage zones and a null attacker, but other than that it is the same. Any idea as to why players don't get hurt or don't die in mine?
-
Off the top of my head I think I searched the surrounding area for entities, put them in a list and dealt the damage to everything in the list.
It looks like you are searching for entities but only dealing damage to the player using the chat command, but that may just be you testing? -
I looked at your booby trap code my code looked the same, for this iteration I changed it slightly but animals or players don't get hurt in the radius
[DOUBLEPOST=1458105243][/DOUBLEPOST]Alright I fixed it, it just turned out the radius and the damage was set too high so I set the damage to the max health for each entityCode:[ChatCommand("nuke")] void cmdNuke(BasePlayer player) { string id = rust.UserIDFromPlayer(player); if (!IsAllowed(player, "CanUseAdminshit")) return; Nukepos=player.transform.position; ExplosionFX(Nukepos); List<BaseCombatEntity> entities1 = new List<BaseCombatEntity>(); Vis.Entities<BaseCombatEntity>(Nukepos, radius, entities1); rust.BroadcastChat("Radius: "+radius*1.5); foreach (BaseCombatEntity e in entities1) { rust.BroadcastChat(""+e); e.Hurt(damage, global::Rust.DamageType.Explosion, null, true); } }
Code:foreach(BaseCombatEntity e in entities){ damage = e.MaxHealth(); e.Hurt(damage, radius, null, true); }
