Help with a script

A place where you can talk about anything Dawn of Light or DAOC related

Moderators: Project Admin, Support Team

Help with a script

Postby dargon » Wed Oct 30, 2013 5:03 pm

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
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby burfo » Thu Oct 31, 2013 4:52 am

You could probably register a handler on the GamePlayerEvent.Dying event. That uses DyingEventArgs which includes the killer.
Burfo
burfo
DOL Guest
 
Posts: 2
Joined: Thu Oct 20, 2011 2:20 am
Location: Wisconsin, USA

Re: Help with a script

Postby dargon » Thu Oct 31, 2013 5:01 pm

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
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby dargon » Wed Nov 06, 2013 8:25 pm

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
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby rdsandersjr » Thu Nov 07, 2013 3:04 am

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(); }
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

Re: Help with a script

Postby dargon » Thu Nov 07, 2013 3:41 am

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
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby rdsandersjr » Thu Nov 07, 2013 4:05 pm

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.
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

Re: Help with a script

Postby dargon » Thu Nov 07, 2013 4:19 pm

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 :)
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby dargon » Thu Nov 07, 2013 4:21 pm

and yes the spawn amount was = # Zombies Attacking but this new way works so im good, again thanks alot
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Help with a script

Postby rdsandersjr » Thu Nov 07, 2013 4:27 pm

lol i just edited my response to suggest Die(); and it looks like that is what you did =)
Thanks,
RDSandersJR
User avatar
rdsandersjr
Support Team
 
Posts: 1089
Joined: Fri Aug 01, 2008 3:01 pm
Location: Cincinnati, Ohio

Re: Help with a script

Postby dargon » Thu Nov 07, 2013 4:54 pm

haha yeah :) i tried it with gameplayer.cs before but i couldnt get things like the xyz working then i remembered the almighty this
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm


Return to “%s” General

Who is online

Users browsing this forum: No registered users and 0 guests