NPC and Player Flags Code Fix for Perl
Here are the code snippets for getting both player and npc flag functions working correctly. Since it looks like our perl functions can't return a value (or at least I don't know how to!) we need to add a new exported variable: returnflag. This will allow flagcheck to retrieve the flag's value.
In parser.cpp replace the "flagnpc" if-block with: Code:
else if (!strcmp(strlwr(command),"flagnpc")) { Code:
else if (!strcmp(strlwr(command),"flagclient")) {//Valdain - fixed command name Code:
else if (!strcmp(strlwr(command),"flagcheck")) { Code:
bool CombatRange(Mob* other); In embparser.cpp in PerlembParser::Event: Code:
if (npcmob) flagnpc and flagclient work the same: Code:
quest::flagnpc(flag_number, flag_value); flag_number can be from 0 to 59 flag_value can be from 0 to 255 flagcheck now works! Code:
quest::flagcheck(flag_number, flag_type); flag_number can be 0 to 59 flag_type = 0 to check the player's flag or 1 to check the NPC's flags Getting the results Now that flagcheck works, we can get the results by getting the $returnflag variable. Example: Code:
sub EVENT_SAY() { One limitation I've noticed in testing is that you can't set or check a flag early in the event, then use flagcheck or returnflag to get that value later on in the event. You must follow the example and pre-get the value for next time. Incorrect Example: Code:
sub EVENT_SAY() { Update flagcheck isn't working as well as I would have hoped. It appears that the perl-side variables aren't being update as quickly as they should be. I'm still working on a fix for it, but I'm still learning how the script system works. flagnpc and flagclient are working just as they should. Hope that helps all you QuestBuilders out there! -Valdain |
Nice work! I just added a link to this thread from my perl howto.
when I get some free time I'll test this out. |
Valdain, you should go into IRC and chat with Lethal/devn00b about developer access... You're code fixes are starting to get to long for my simple mind to merge in...
|
Quote:
BTW, I have lastname in NPC_types working and NPCs behaving better (less cases of it being to far away to attack when you are standing over it and/or vanishing). I am going to sit on the NPC one until its right, but if you're interested I can post the lastname fix. |
You're another one that needs to just suck it up and request developer access!
Merge your own damn changes! |
Quote:
|
All times are GMT -4. The time now is 06:39 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.