NPC / Mob Variable
Is there a variable that would returns the name of the npc that triggered the Event?
Like for example. If one of the guard attack a newbie mob (a large rat). Guard would say "Time to die a large rat!". So far I haven't been able to find the right variable to script it. I thought maybe $mname would do it but instead it returns the name of the npc instead of the mob that triggered it. Something like "Time to die Guard_Soyler0001!" instead of the actual "Time to die a large rat!" |
Looks like $targetname would do it. Sometime the name does not show up and sometime it shows up as a_large_rat000. Be cool if that underscore and zeros were left out. lol. I could probably try to pause the npc to give it time to target or put in $combatstate==0.
|
$npc->GetHateTop()->GetName();
or GetCleanName() should strip the _000 I didn't test it, but something close to this. |
yeah I test it with getcleanname() and doesn't take out the _000. Perhaps I don't have it arrange in right. $targetname works half the time tho. better than none at all. quest::pause() doesn't really work. it just pause the npc after the kill.
|
GetCleanName()
I ran into that a long time ago with $targetname, and I can't remember what my workaround was. I'll look for it again later and let you know what I did. quest::pause() What did you expect it to do? |
I was hoping that it would pause the npc long enough to give itself some time to target the mob instead of prematurely before the quest::say.
|
I'm not at my system to check, but I thought pause was for the grids/waypoints system. You could always use a timer to introduce a pause.
|
right, it is fun to learn the perl questing and to experiment with them. I managed to make the south qeynos campfire event where npcs would stand near the fire at night then make it move during the day. So livelike, I'm loving it. Anyway if you find getcleanname() and how I would use it, that would be great. I can probably dig up something in the quests folder to see if I can find something.
|
Hmm I haven't had much luck with this kind of coding. Any thing wrong with this code? Guard doesn't say anything at all when in combat.
sub EVENT_COMBAT { if($combat_state == 1){ my $cur_target = $npc->GetHateTop()->GetTarget(); if($cur_target) { my $target_name = $cur_target->GetCleanName(); quest::say("Time to die $target_name!"); } } } |
my $cur_target = $npc->GetHateTop();
should be good enough. If you then do GetTarget() it probly just goes points back to npc. |
wow, that works like a charm. this code works like it should for those that had trouble:
sub EVENT_COMBAT { if($combat_state == 1){ my $cur_target = $npc->GetHateTop(); if($cur_target) { my $target_name = $cur_target->GetCleanName(); quest::say("Time to die $target_name!"); } } } Thanks Congdar!!! |
All times are GMT -4. The time now is 10:34 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.