$mob->DoKnockback(?);
Code:
XS(XS_Mob_DoKnockback); /* prototype to pass -Wmissing-prototypes */ Code:
[02.14. - 06:09:54] Script error: qst1002524::EVENT_TIMER - Perl runtime error: Can't call method "DoKnockback" on an undefined value at quests/wood/northwind.pl line 45 (or 56). Code:
sub EVENT_SPAWN |
Here is the actual function from mob.cpp:
Code:
void Mob::DoKnockback(Mob *caster, uint32 pushback, uint32 pushup) $client->DoKnockback($npc, x, x); I don't know what the pushback and pushup should be set to, so I just used "x" in the example, but I imagine you can figure that part out with some simple testing once you have it basically working. I would suggest testing it with EVENT_SAY first to make sure you are using it properly. If you want to use it in EVENT_TIMER, then you are going to have a bit of an issue. The $npc variable is exported to EVENT_TIMER for npc scripts, but since it is a timer, there is no actual client triggering it, so there is no $client variable exported to EVENT_TIMER. If you want to use a client as a pointer like that from EVENT_TIMER, my best suggestion would be to save the entity ID of the client you want to knockback from one of the other sub events such as EVENT_COMBAT or whatever. Then, in the EVENT_TIMER, you can get the client by the entity ID and validate that you were able to get the client before trying to use it as a pointer. Otherwise, if you try to just save the client as a variable outside the sub and the client zoned or died or whatever, it can cause a zone crash if you don't validate it still exists first. Alternatively, you can just get the NPCs current target and check if it is a client, then knock it back. Or, you can do an entity list search through the client list and use knockback on any or all of the clients in the zone or within X distance from the NPC. The possibilities are endless. |
Ok thank you for clearing that up and for the tip on needing to validate, really I would have had assumed I had a corrupt perl file or something.
I think I already have a simple script of how to get $client into EVENT_TIMER as part of a climber, maybe it can be useful as a reference. |
a working version of the first script for comparison:
Code:
##northwind.pl Code:
elsif ($timer eq "windtwo") |
All times are GMT -4. The time now is 11:21 AM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.