Buff Bot re-creation NPC getclass() Help
There is a post on here for an awsome buff bot
http://www.eqemulator.org/forums/showthread.php?t=29401 I am trying to take this a step further but my still growing limit script knowledge is leaving me in the dust. I have a spawngroup cycle that spawns my buff bot. Sometimes it spawns as different classes, so when It spawns I want it to be able to only cast spells from the class it spawned as and with a player(not npc) level check so a level 1 player cannot get clarity 2 because he is too low lvl. I am posting what I have done so far and hoping im on the right track lol. Code:
#Credit goes to Sylaei for the original creation of this buff bot! Thank you Sylaei 08-31-2009 I do not have the level checks placed anywhere because honestly i have no clue where to put the check lol. As always any and all feedback and suggestions appreciated :) Edit: Its having a problem calling the correct spell list. I am pretty sure I cannot call Code:
my $Ench = ($npc->GetClass() == 'Enchanter'); Code:
If ($npc->GetClass() == 'Enchanter') || ($npc->GetClass() == 'Enchanter') |
Why'd you do this?: Shouldn't it be elsif? Just try using the syntax checker, errors below. I pasted exactly what you posted and got those errors, nothing extra, nothing less.
Code:
else ($npc->GetClass == 'Necromancer') { Code:
syntax error at Test.pl line 12, near "else (" Code:
else |
No syntax error with this, haven't tested it in the game, but here you go:
Code:
sub EVENT_SPAWN { |
[QUOTE=Zamthos;218075]Why'd you do this?: Shouldn't it be elsif? Just try using the syntax checker, errors below. I pasted exactly what you posted and got those errors, nothing extra, nothing less.
Code:
else ($npc->GetClass == 'Necromancer') { I tested it with elsif and if neither worked, the NPC doesnt talk so I think im missing a link calling the proper list somewhere down in sub EVENT_SAY but im still tryen to find it lol Here is with 3 class options for more clarification. Code:
sub EVENT_SPAWN { |
Hiya Fig,
Related post about dealing with class types: http://www.eqemulator.org/forums/showthread.php?t=35970 |
Quote:
My problem currently is Having the EVENT_SAY check what class the buffnpc spawned as, then selecting the correct spelllist based on the class. Then all in all, the correct syntax so it works. I am reading your post thoroughly to see if I typed something wrong on calling the classes. TY!!! |
Code:
use 5.012; Code:
I can cast Clarity [174] on you for 50 platinum. |
Awsome c0ncrete!!! I am going to test that out right now! Here is the script me and Ghanja was working on as well. I got the npcs to respond to hail's with the proper class response but calling the correct spell list was not working... lol. Here is that script of a mess.
Code:
use strict; |
No no, ghanja wasn't working on that one bud.
Code:
my $buffs = { Now using the above and the references I pointed out the other night, tie it all together. |
Cool, thanks very much guys, ill work on it for a few days and then update!
|
Code:
use 5.012; change $param{_class} to whatever class you want the npc to be. nyquil is kicking in. you're on your own for a bit... |
Quote:
The NPC is in a spawngroup of multiple classes. So when it dies or respawns, the script will determine which class it spawned as and set the spell list for that class.... $param{_class} = $npc->GetClass(); ? Now by your comment, are you suggesting that I need to change it manually in the script to force a spell list, by the way you have coded it. This is the 1st time I have seen packages and some syntax you are using, I am googling and researching all I can to understand what you have given. Going to need some time to learn all of this lol. Edit: And hash tables |
there is a reason i put the comments about ignoring what was above and below a certain point....
the code within those areas was just put there to emulate the behavior of the script being run via the server. if you were to run this script as it is written from a command prompt, you will see a near identical example of how it would work from inside the game. i was letting you know the things you would need to change if you were running it outside of the game so you could see the different results, depending upon a given scenario (client said / npc class is). to get it to work in the game, you'd remove the lines that are inside the areas designated for you to ignore and change the remaining say lines to quest::say(), $client->Message(), or whatever other message delivery function you would want to use. |
Thank you for explaining, i understand. I have not done any perl outside of eqemu rofl
|
the script you're trying to modify is one of the most convoluted ones i've seen.
also, there's lots of good (and free) reading to be found here: http://www.perl.org/books/library.html |
tested for syntax, not functionality.
Code:
# array of playable class long names |
I am trying, i cannot get it to work in game. I cannot see where sub EVENT_SAY calls the class specification to know which list to call. I am looking for another $npcClass to do the trick but obviously theres something i do not understand. Currently the NPC does not respond to a hail.
Edit: I dunno what I did, but I just got a response from a hail. It is blank, it is not pulling my $greeting = $data->{$npcClass}->{greet}; but its a start. Going to work on it some more, will update. Edit2: I know what i did to fix, I took out the use 5.012 and use warnings ,I read you needed to use those for the given and when statements if thats the correct term. But noticed you took those out as well. |
everything that sets the class specific info for the current npc happens here (outside of any subroutine):
Code:
# get class-specific stuff for this npc nevermind. just saw your update. :) |
oops.
change this Code:
# if client gave the correct amount of money, cast the spell Code:
# if client gave the correct amount of money, cast the spell |
Ok change done. Still does not pull the greet. I am reading on arrays from the one of the books off the perl site you linked. lol light reading :)
Edit: But the npc is definately responding to the hail, he turns and does the Buffbot says. " |
probably something to do with that saylink quirkiness. looking at the source for that now.
|
Lol I changed
Code:
Necromancer => { Now the npc responds on hail and says Souls and Buffs(broke link) and on a 2nd line also still says the blank. Edit: Getting closer! :) |
Well when I had only changed the necro greet, it worked, then i changed the ench also and repopped the zone to spawn the buffbot as ench, zone.exe crashes. had to take the quest::say out.
|
that syntax is wrong, but it was good effort. this moves all of the calls to quest::saylink into EVENT_SAY per notes here:
http://www.eqemulator.net/wiki/wikka.php?wakka=SayLink Code:
# array of playable class long names |
Use of uninitliazed value $greeting in sprintf line 51
|
that'll happen when the NPC is of a class that isn't covered in the hash ref.
to cover those issues, change this Code:
my $greeting = $data->{$npcClass}->{greet}; Code:
my $greeting = $data->{$npcClass}->{greet} || "Got %s?"; |
I only test the script on enchanter and necro bc that is the only 2 with a spelllist. I added what you suggested and i still get the error.
|
copy and paste the whole script you have now.
|
Code:
# array of playable class long names |
hrm... did you #repop after #reloadpl?
|
yes, #reloadpl and #repop and #repop force
|
this works.
i think it might have had something to do with scope and assigning a value to $npcClass by way of the constant. it was an empty string until i moved the declarations of that and $buffList inside of the scopes they were used. the same does not apply to $data, however. Code:
use 5.012; |
:( 1st attempt isnt working, looking into it now though.
|
i had it running on an enchanter npc. if it's not casting the buff, make sure the npc has qglobals enabled.
|
qglobals is 1, i am checking everything tho. I will update in a few. If it works for u, i obviously missing something.
|
I dunno.... My npc is enchanter class 14, it has a enchanter spell list assigned(even though i dont think that matters since it pulls the clientside buffs from script), qglobal is 1, i copied ur script verbatim, I deleted everything inside of mine to make sure it was empty before i pasted. I #reloadpl and #repop force and #repop.
Edit: I wish I knew more to help better, lol. Although you have shined a lot of light on this for me, I am definately going to keep learning this. much fun :) |
haven't the faintest on that one. have 160135.pl in tutoriala and popped the npc with #dbspawn 160135 and everything is working for me here.
|
Ill get some fresh eyes on it tomorrow. Thanks for helpen me today c0ncrete.
|
Hmmm what about maybe a version of perl issue? Commands missing maybe? My server is ran off an old winxp 32bit machine currently. Active Perl 5.10.1 and Mysql server 5.1. I dunno lol Tryen to troubleshoot every angle.
|
try removing the first three lines then.
|
All times are GMT -4. The time now is 08:58 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.