Jump to content
  • 0

Event that is triggered when a specific mob attack or get attacked?


Question

Posted (edited)

Is there any src or script that is triggered when a specific mob (specified by GID) is being attacked(received any kind of damage physical or magic type) ? or is attacking(attack players)?

Edited by Lord Ganja

11 answers to this question

Recommended Posts

  • 0
Posted (edited)

I suppose you already know how to get a monster GID, so, you can try to use this method for specific monsters after it's summoned.

Damn. Haven't think of that. Thanks.

 

Anyway it uses Timer before comparing the current hp of the monster.

I was thinking about creating an event "OnMobDamaged" and insert it on mob.c under mob_damage  which is called when a mob received damage,

but I don't want it to be triggered on all mobs. So I came up with an idea to filter the mob's attached event(e.g strnpcinfo(0)+"::OnThisMob)..

All mobs that has an event label of "OnThisMob" will ONLY trigger the script. The thing is, I don't know how to filter the event name that is currently attached to a monster.

 

I was trying to do it like this, but I knew it that it will fail since im noob at src. :mellow:  :mellow:  :mellow:

mob.c under mob_damage

if( compare(npc_event,"OnThisMob") )
	npc_script_event( md, NPCE_MOBDAMAGED );

can you help me how to filter and compare the event attached to the mob?  /hmm

Thanks in advance! /thx  /thx

Edited by Lord Ganja
  • 0
Posted

 

<map name>,<x>,<y>,<xs>,<ys>%TAB%monster%TAB%<monster name>%TAB%<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}

See the <event> field, that's what you are looking for.

 

Hi. clydelion, I was trying to filter the EVENT NAME that is currently attached to the monster but Idk how to do it. :(

I was about to create an npcevent that is triggered when a mob received damage. OnMobDamagedEvent, just like OnNPCKillEvent but this time when the mob only receive damage.

 

And I don't want all mobs to trigger it coz it might cause server lag. So I was trying to create that event to only trigger to the monsters that has attached

OnThisMob event label to trigger OnMobDamagedEvent..

 

e.g

monster "prontera",150,150,"Poring",1002,1,"Test::OnThisMob";

when this poring received any damage, the OnMobDamagedEvent will be triggered.

but for the normal porings without OnThisMob event label, it won't be triggered.

 

Can you give me ideas how to make this work?

  • 0
Posted
<map name>,<x>,<y>,<xs>,<ys>%TAB%monster%TAB%<monster name>%TAB%<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}
See the <event> field, that's what you are looking for.

Hi. clydelion, I was trying to filter the EVENT NAME that is currently attached to the monster but Idk how to do it. :(

I was about to create an npcevent that is triggered when a mob received damage. OnMobDamagedEvent, just like OnNPCKillEvent but this time when the mob only receive damage.

And I don't want all mobs to trigger it coz it might cause server lag. So I was trying to create that event to only trigger to the monsters that has attached

OnThisMob event label to trigger OnMobDamagedEvent..

e.g

monster "prontera",150,150,"Poring",1002,1,"Test::OnThisMob";

^ when this poring received any damage, the OnMobDamagedEvent will be triggered.

but for the normal porings without OnThisMob event label, it won't be triggered.

Can you give me ideas how to make this work?

You would have to replace all your proings with ones that have this label its not hard

  • 0
Posted

disable mob spawns for poring and add versions that have your event label attached..

I mean, the event will be triggered after the poring is killed right? I need an event npc that is triggered when the mob received damage or got hit/attacked(physical or magical damage)

  • 0
Posted

Clue:

npc_event(mvp_sd,md->npc_event,0);

What I would do if I were you:

 

1. Make a new scriptcommand so you don't have to edit every script that uses *monster script command.

 

2. Add a new char in mob_data struct, or just a flag to indicate that it is a OnMobAttacked event.

 

3. Look into battle.c to force run the script everytime it encounters a flagged attack.

  • 0
Posted

Clue:

npc_event(mvp_sd,md->npc_event,0);

What I would do if I were you:

 

1. Make a new scriptcommand so you don't have to edit every script that uses *monster script command.

 

2. Add a new char in mob_data struct, or just a flag to indicate that it is a OnMobAttacked event.

 

3. Look into battle.c to force run the script everytime it encounters a flagged attack.

Can you give me more clue about this? /hmm

I'm just actually bad at src. I can create some scripts but just based from other scripts. So kinda like copy paste stuff XD

Thanks btw.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...