For instance:
I am fighting a high level mob that enrages and when the mob casts I want to slam or bash it. There will be event text generated like so:
"Soandso begins to cast a spell."
"Soandso has become ENRAGED!"
"Soandso is no longer enraged."
If you tried to set up an event "begins to cast a spell" your script would react if any player or npc within range of you started casting.
With this it should narrow it down to the mob you are fighting, unless the mob is named something like "An orc pawn" and there are multiple mobs with "An" as the beginning of the name within the radius value that you provide.
It isn't perfect but it is about as good as it gets.
Anyways.. here is the code and with a few event examples. Please let me know how this works out for you and if there is anything I need to correct. (I tested this mostly against player characters so hopefully when I switched it to npc everything works out.)
Code: Select all
#Event Enraged "has become ENRAGED"
#Event Offrage "is no longer enraged"
#Event Bash "begins to cast a spell"
Sub Main
:Loop
/delay 1
/doevents
/goto :Loop
/return
Sub Event_Enraged(OnRageText)
/if $target()=="TRUE" {
/call FindEvtNPC "@OnRageText" 150
/if $return==FOUND {
/varset EnrageVar 1
/attack off
}
}
/return
Sub Event_Offrage(OffRageText)
/if $target()=="TRUE" {
/call FindEvtNPC "@OffRageText" 150
/if $return==FOUND {
/varset EnrageVar 0
/attack on
}
}
/return
Sub Event_Bash(BashText)
/if $target()=="TRUE" {
/call FindEvtNPC "@BashText" 150
/if $return==FOUND /doability "Slam"
}
/return
Sub FindEvtNPC(MsgText,SrchRadius)
/declare MobName local
/declare MobID local
/declare LastID local
/varset MobName $arg(1,"@MsgText")
/varset MobID 0
/varset LastID 0
/if $target()=="TRUE" {
/varset MobID $searchspawn("@MobName",npc,radius:@SrchRadius)
:GetID
/if n @MobID!=0 {
/varset LastID @MobID
/if n $target(id)==@MobID {
/return FOUND
} else {
/varset MobID $searchspawn("@MobName",npc,id:@LastID,radius:@SrchRadius,next)
/if n @LastID==@MobID /return NOTFOUND
/goto :GetID
}
}
}
/return NOTFOUND
