Script for a Buff bot
I copied the translocator script from Trev and modified it to allow a player to request a buff, then pay/donate for the buff, then get the buff.
There are probably a lot of scripts in the forums that do this type of stuff, but I like this way, because you can change 3 lines and it will work for about any type of caster bot. I use 3 arrays for the buffs, one is the name of the buff, one is the cost of the buff, and one is the spell id to cast. I also use a qglobal variable for the npc to remember the spell to cast. The beauty of scripting like this is that once this is working for a few spells it will be easily modifiable for any other buff bot type npc. My idea is to have an npc for each class that can provide buffs or ports. I then want them to randomly appear and after a while to leave. This is a step in the direction of imitating live with players that would buff for donations. One final note: I am not really a perl programmer, like I said I just copied Trev's code and modified it some. If there is a way to make this better or a more proper way, please let me know. Code:
#A buff bot script. |
I just realized there was an error, I changed the word All to List but I didn't change it everywhere. Danged ole bugs.
Code:
#A buff bot script. |
I thought I'd post the 'final' version. With this version all I have to do is change the SpellList, SpellCost, and SpellId Arrays and I'll have a seperate npc for casting buffs or ports. In this script they are up for 20 minutes then down for 20 minutes. The respawn time in the database is responsible for respawning after 20 minutes.
This will simulate the players in pok that would buff for donations. One other change is that you can list all the spells, buffs only, or the ports only. Code:
#A buff bot script. |
KEI bot help
I copied the bot script and made some changes for other classes. The issue I'm having with the Enchanter bot is the KEI group buff. I know for the druid bot, the port spells are set to selfcast. If someone with coding skills could help me out, I'm hoping its possible to add a line that if spellid=2570 then selfcast 2570. Otherwise the npc just casts the group buff on itself. Once I see the added code, I can adjust the cleric bot too. Thank you much. And thanks for writing the quest in the first place. fits in my world perfectly.
Code: #A buff bot script. #Buffs a player for pp. #SpellList Is the array containing the names of the spells. SpellCost Is the amount in pp for each spell. SpellID Is the spell that Is cast by the npc. #Note these are 3 arrays. each position in the array corosponds to the same position in the other arrays. #So I have this set so that if you say 'Spirit of Wolf' and pay 2 pp, then the npc will cast spell 278 on you. #I am setting the amounts to pp just because they can be any amount you wish, this requires changing the EVENT_ITEM Function to handle the other money types. @SpellList = ("Bind Affinity","”See Invisible","Serpent Sight","Intellectual Advancement","Rune I","Breeze","Quickness","Intellectual Superiority","Alacrity","Rune II","Clarity","Augmentation","Ward of Alendar","Radiant Visage","Clarity II","Rune III","Gift of Magic","Insight","Celerity","Rune IV","Brilliance","Guard of Alendar","Adorning Grace","Swift Like the wind","Improved Invisibility","Rune V","Aanya's Quickening","Gift of Insight","Protection of Alendar","Overwhelming Splendor","Augment","Wonderous Rapidity","Gift of Brilliance","KEI"); @SpellCost = ("2","2","1","2","3","3","2","3","5","6","5","7"," 4","5","7","9","5","5","5","12","7","6","8","8","1 0","15","10","8","10","10","10","12","12","25") ; @SpellID = ("35","80","276","2561","481","697","39","2562","1 70","482","174","10","4073","646","1693","483","14 08","175","171","184","33","4074","647","172","140 6","1689","1708","1403","4075","1701","1729","1709 ","1410","2570"); sub EVENT_SPAWN { quest::settimer("buffy", 90); quest::ooc("Mind buffs behind Main bank"); quest::settimer("despawnbuffy", 1300) } sub EVENT_TIMER { #$npc->SetAppearance(1); if($timer eq "buffy") { my $random_number = int(rand(4)); if ($random_number == 0) { quest::shout("I have the buffs you're looking for..."); } elsif ($random_number == 1) { quest::shout("Clarity, Clarity II, KEI, and Haste behind Main Bank"); } elsif ($random_number == 2) { quest::shout("Buffing for Platinum! Proceedes go to Arcane Scholarship funds"); } elsif ($random_number == 3) { quest::say("Terran, Please stop touching me."); } $npc->SetAppearance(int(rand(2))); } if($timer eq "despawnbuffy") { quest::say ("I'm off to shower. This place makes my skin crawl"); quest::depop(); } } sub EVENT_SAY { my $all = quest::saylink("List", 1); my $buffs = quest::saylink("Buffs",1); #Spacer between Text messages to make them easier to read $client->Message(7, "-"); my $NPCName = $npc->GetCleanName(); if ($text =~/Hail/i) { $npc->SetAppearance(0); $client->Message(315, "$NPCName whispers to you, 'Please let me know what [$buffs] you'd like, or I can list them [$all] for you. '"); } #Counts each row for the while my $count = 1; #Counts each element in the Array for the while my $n = 0; if ($text !~ /Hail/i) { while ($SpellList[$n]) { #This searches the list to find possible matches. The lc() command makes all text lowercase. #It Is easier to make all text lower case for comparison, if the user types uppercase it will still match. if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || ($text =~ /^List$/i)) { my $SpellList = quest::saylink($SpellList[$n]); my $SpellCost = $SpellCost[$n]; $client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp"); } if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || (($text =~ /Buffs/i) && ($SpellList[$n] !~ /Port to/i))) { my $SpellList = quest::saylink($SpellList[$n]); my $SpellCost = $SpellCost[$n]; $client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp"); } if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || (($text =~ /Ports/i) && ($SpellList[$n] =~ /Port to/i)) ) { my $SpellList = quest::saylink($SpellList[$n]); my $SpellCost = $SpellCost[$n]; $client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp"); } #This Is the command that Is executed when a the user enters a spell. if (lc($SpellList[$n]) eq lc($text) && $text !~ /^List$/i) { #Creates a global variable. You must set the qgolbal field in the npc_types table to 1 for each npc you wish to handle global variables. #buff Is the name, $text Is what the varible should be eq too, 0 only this npc, char, And zone apply to the variable, M5 Is 5 minutes. quest::setglobal("buff", $text, 0, "M5"); #I'm not sure why I need the next line, the line above should set the $qglobals{buff}, but it wouldn't work for me. $qglobals{buff} = $text; $client->Message(315, "Please give me $SpellCost[$n]pp, and I'll cast $qglobals{buff} for you!"); } $n++; $count++; } } } sub EVENT_ITEM { my $correctmoney = 0; #Counts each row for the while my $count = 1; #Counts each element in the Array for the while my $n = 0; #Cycles through each spell in the array until it matches the requested spell, And the amount pp required. while ($SpellList[$n]) { if(($SpellList[$n] eq $qglobals{buff}) && ($platinum == $SpellCost[$n])) { $client->Message(315, "Thank you for the $SpellCost[$n]pp, prepare for $qglobals{buff}!"); if ($SpellList[$n] =~ /Port to/i) { quest::selfcast($SpellID[$n]) } else { $npc->CastSpell($SpellID[$n], $userid); } #set this to 1 so that we don't return money we shouldn't. $correctmoney = 1; } $n++; $count++; } #Returns the money if it Is Not the correct amount. if ($correctmoney == 0 ) { if(($copper > 0) || ($silver > 0) || ($gold > 0) || ($platinum > 0)) { $client->Message(315, "I don't need these coins, you may have them back."); quest::givecash($copper,$silver,$gold,$platinum); } } #deletes the $qglobals{buff} variable. quest::delglobal("buff"); } |
Nevermind. I changed the "/Port to/ part to KEI. Worked like a charm. Thanks again. Now I just need to slow down the shout spam. Wouldn't be so bad if the zone were populated... Awesome script!
|
Quote:
IE: Code:
sub EVENT_SAY { |
I Like the suggestions. Maybe have one shout, which would be every 40 mins. That way new people to my PoK would find out they're there, do the rest with whispers and proximity. Nice....
|
Would it also be possible to Tweak the range the npc would have for casting? As it is now, you need to stand very close to the npc for the quest/spell to work. Doubling the range would make it Ideal...
Thank you. |
Quote:
Almost anything can be changed, if you had the knowledge to do so. (Except client side, of course.) |
By the way, I wanted to point out that this script for the paid buff feature looks like it has the potential to be exploited. For example, it is storing data in memory that someone paid, but it does not store who. A simple fix for this would be to use quest globals, instead of storing it in a var. After they receive the buff, delete the quest global.
Right now, it seems to me that someone can pay - then someone else could steal the buffs that the other player paid for. I guess it wouldn't matter if this was a private server, but it could cause issues on a public server. Just heads up! (Also, I may have read it wrong since I haven't tested this exact script myself - it is just what it appeared to me.) |
Actually, here is my exact script to charge money on the user level for buffs. I don't have a feature to automatically shout or anything (as I have the tag "buffs" under it's name). But this is how my script works:
Code:
sub EVENT_SAY{ Enjoy! |
Very Nice! I do like some minimal Chatter in PoK, feels a bit more home like, but I might change some of the shouts to whispers and says. I like your buff script for npc buff bots I plan to add to zones with some of the more difficult mobs. I don't want to nerf any mobs or add crazy weapon damage, but I do want it so a single group can take on a solid mob if they have the strategy and tactics. This will do that I believe. Give an edge, but not tip the scale. Thank you!
|
I would like to add the ability for the buff bot to do a random MGB and have it call out with minute warnings, like 5 minutes, 4, 3, 2, 1 just like a player would do. Players could still pay immediately and get what they want but they would occasionally zone in and be able to get a free MGB.
I am getting stuck on the 5 minute warning. There seems to be no way to pause for 60 seconds or is there ? |
Persistence is the key. I think I have it now.
|
Quote:
|
All times are GMT -4. The time now is 08:45 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.