Page 1 of 1
Help with a script
PostPosted: Wed Oct 30, 2013 5:03 pm
by dargon
I have a mob script that uses the
- Code: Select all
public override void EnemyKilled(GameLiving living)
to summon a mob when it kills something
It works just fine. But if say 2 mobs attack the same target and it dies.. it summons two mobs. I want it to only summon 1 mob. Could anyone help me with this? Ive gone through the triggers and looked but honestly.. im not good at understanding it
By that i mean more or less, that only the mob that gets the deathblow would summon a mob
Re: Help with a script
PostPosted: Thu Oct 31, 2013 4:52 am
by burfo
You could probably register a handler on the GamePlayerEvent.Dying event. That uses DyingEventArgs which includes the killer.
Re: Help with a script
PostPosted: Thu Oct 31, 2013 5:01 pm
by dargon
Ill take a look there thanks, i had an idea since its a "summon a zombie" script to just add it to the gameplayer.cs on death area, but it doesnt like to recompile afterwards if i change that it says it cant find gameserver.dll lol DX so ill go take a look at your suggestion now! thanks again
Re: Help with a script
PostPosted: Wed Nov 06, 2013 8:25 pm
by dargon
Couldnt figure it out, but thanks for the suggestion (im not very good with these kind of things)
Here is my script, if someone can help me make it so Only the killer spawns a mob, man i would love you! XD
- zombie.cs
- summons a zombie whenever it kills a target
- (2 KiB) Downloaded 17 times
Re: Help with a script
PostPosted: Thu Nov 07, 2013 3:04 am
by rdsandersjr
Why are you doing a for loop for one mob? If your only wanting to spawn one mob the below should work, I did not test it.
- Code: Select all
if (!living == null)
{
GameNPC mob = new Zombie();
mob.X = living.X;
mob.Y = living.Y;
mob.Z = living.Z + 20;
mob.CurrentRegion = living.CurrentRegion;
mob.Heading = living.Heading;
mob.Name = "Reanimated Corpse";
mob.GuildName = living.GuildName;
mob.Level = living.Level;
mob.Realm = 0;
mob.Model = 110;
mob.Strength = 500;
mob.Constitution = 400;
mob.Quickness = 200;
mob.Flags = (uint)0x0;
mob.RoamingRange = 500;
mob.MaxSpeedBase = 200;
mob.Size = 55;
mob.RespawnInterval = (int)999999999;
mob.AddToWorld();
mob.SetOwnBrain(new ZombieBrain());
Brain.Start();
}
Re: Help with a script
PostPosted: Thu Nov 07, 2013 3:41 am
by dargon
Thank you for the code.
Without the
- Code: Select all
ushort number = 1;
ushort radius = 1;
for (int i = 0; i < number; ++i)
part of the code it doesnt spawn though, you gave me some thoughts and im going to try some ways I wouldnt of thought of before
edit: I was wrong, it didnt need the loop, your code had
- Code: Select all
!living == null
so i removed the !, i added the ! as != and it summoned fine, but it still summons more than 1 zombie when more than 1 zombies were attacking you
Re: Help with a script
PostPosted: Thu Nov 07, 2013 4:05 pm
by rdsandersjr
So lets say I am fighting a zombie, and another one comes up and starts attacking me, and I die then it will spawn reanimated corpses * the amount of zombies attacking me?
If that is the case you need to re-think your logic, as it stands now, this is what your script is doing.
If one zombie is attacking the player and player dies, it works correct?
If two zombies is attacking the player and the player dies, it will summon two zombies?
Your script is working correctly. What you need to-do in my opinion is don't override enemykilled but to override dies in gameplayer.cs and do a check if the mob killing the player is a zombie, then spawn 1.
Each "attacker / zombie" that is killing the player is summoning one zombie because each because its enemeykilled events are firing.
Re: Help with a script
PostPosted: Thu Nov 07, 2013 4:19 pm
by dargon
Well I figured it out. Not my origional plan, but hey it works right? I just added zombie to the GameObjects and then inserted a new Die event for GamePlayer.cs (not sure if i explained myself well but oh well) so thank you all for the help

Re: Help with a script
PostPosted: Thu Nov 07, 2013 4:21 pm
by dargon
and yes the spawn amount was = # Zombies Attacking but this new way works so im good, again thanks alot
Re: Help with a script
PostPosted: Thu Nov 07, 2013 4:27 pm
by rdsandersjr
lol i just edited my response to suggest Die(); and it looks like that is what you did =)
Re: Help with a script
PostPosted: Thu Nov 07, 2013 4:54 pm
by dargon
haha yeah

i tried it with gameplayer.cs before but i couldnt get things like the xyz working then i remembered the almighty this