|
|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
| Quests::Q&A This is the quest support section |

02-14-2013, 03:25 PM
|
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Cool, thanks very much guys, ill work on it for a few days and then update!
__________________
|
 |
|
 |

02-14-2013, 03:31 PM
|
 |
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
Code:
use 5.012;
no strict 'vars';
use warnings;
### IGNORE EVERYTHING BELOW HERE ###
package NPC;
sub new {
my ( $class, %param ) = ( shift, @_ );
$param{_class} = 14;
return bless \%param, $class;
}
sub GetClass {
shift->{_class};
}
package main;
my $npc = NPC->new();
sub quest::saylink {
shift;
}
sub quest::say {
say shift;
}
# this is what the client said (used to search available buffs)
my $text = "Clarity II";
### IGNORE EVERYTHING ABOVE HERE ###
# array of playable class long names
use constant CLASS_L => qw(
Unknown Warrior Cleric Paladin Ranger Shadowknight Druid Monk Bard Rogue
Shaman Necromancer Wizard Magician Enchanter Beastlord Berserker
);
# saylink
my $buffs = quest::saylink( "buffs", 1 );
# hashref containing buffs offered depening on the class of the npc
my $data = {
Enchanter => {
greet => "I have the $buffs for your mind.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Breeze", 697, 25 ],
[ "Clarity", 174, 50 ],
[ "Clarity II", 1693, 200 ],
[ "Alacrity", 170, 10 ],
[ "Augment", 1729, 30 ],
[ "Aanya's Quickening", 1708, 100 ],
[ "Rune I", 481, 5 ],
],
},
Necromancer => {
greet => "Souls and $buffs.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Dead Men Floating", 1391, 10 ],
],
},
};
# get class-specific stuff for this npc
my $npcClass = (CLASS_L)[ $npc->GetClass() ];
my $greeting = $data->{$npcClass}->{greet};
my $buffList = $data->{$npcClass}->{buffs};
sub EVENT_SAY {
if ( $text =~ /hail/i ) {
quest::say($greeting);
return;
}
given ( [ grep { ${$_}[0] =~ /$text/i } @{$buffList} ] ) {
# one exact match (probably clicked on saylink in list)
when ( @{$_} == 1 && $text eq ${$_}[0][0] ) {
say "That will be ${$_}[0][2]pp for ${$_}[0][0].";
}
# client typed targeted text that did not match hail and
# more than one available spell name matched recieved text
# TODO: create saylinks
when ( @{$_} > 1 ) {
foreach my $spell ( @{$_} ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
say "I can cast $spellName on you for ${spellCost}pp.";
}
}
}
}
### IGNORE EVERYTHING BELOW HERE ###
EVENT_SAY();
you can change the value of $text in this and run it outside of the emulator to see the results.
change $param{_class} to whatever class you want the npc to be.
nyquil is kicking in. you're on your own for a bit...
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
 |
|
 |

02-14-2013, 04:32 PM
|
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Quote:
Originally Posted by c0ncrete
change $param{_class} to whatever class you want the npc to be.
|
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
__________________
Last edited by Figback65; 02-14-2013 at 04:34 PM..
Reason: Hash
|
 |
|
 |

02-14-2013, 04:54 PM
|
 |
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
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.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
 |
|
 |
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 10:09 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |