|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
|
|
|
12-22-2012, 01:22 AM
|
|
Sarnak
|
|
Join Date: Aug 2012
Location: work
Posts: 74
|
|
npc-addloot not working
it's real difficult. I was messing with it for a half hour and couldn't quite get it to do what I wanted it to do.
my $rands = quest::ChooseRandom(15270,15275,15075,15271,15279, 15212,15079,15274,15272);
my $randa = quest::ChooseRandom(2031,2036,2030,2034,2027,2038, 2026,2029,2025,2032,2028,2033);
my $randw = quest::ChooseRandom(5043,6032,6030,7022,7024,94155 ,6031);
sub EVENT_COMBAT {
my $NPCRace = $npc->GetRace();
if($combat_state == 1)
{
$npc->Heal();
if($NPCRace==54)
{
quest::say("your blood will spill.");
}
else {
quest::say("Time to die $name!");
}
}
}
sub EVENT_DEATH
{
my $rewardr = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10);
if($NPCRace!=54){
if($rewardr < 4)
{
quest::addloot($rands,1);
}
if($rewardr < 7 && $rewardr > 3)
{
quest::addloot($randw,1);
}
if($rewardr < 10 && $rewardar > 6)
{
quest::addloot($randa,1);
}
if($rewardr > 9)
{
quest::addloot($randw,1);
}
}
}
Kill Npc ---npc not loot
Help!!
__________________
To create the most beautiful server for "!!~[BP] PLARYBOT EQ~!" Welcome to our server
|
|
|
|
12-22-2012, 01:34 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Code:
my $rands = quest::ChooseRandom(15270,15275,15075,15271,15279, 15212,15079,15274,15272);
my $randa = quest::ChooseRandom(2031,2036,2030,2034,2027,2038, 2026,2029,2025,2032,2028,2033);
my $randw = quest::ChooseRandom(5043,6032,6030,7022,7024,94155 ,6031);
sub EVENT_COMBAT {
my $NPCRace = $npc->GetRace();
if($combat_state == 1)
{
$npc->Heal();
if($NPCRace==54)
{
quest::say("your blood will spill.");
}
else {
quest::say("Time to die $name!");
}
}
}
sub EVENT_DEATH
{
my $rewardr = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10);
if($NPCRace!=54){
if($rewardr < 4)
{
quest::addloot($rands,1);
}
if($rewardr < 7 && $rewardr > 3)
{
quest::addloot($randw,1);
}
if($rewardr < 10 && $rewardar > 6)
{
quest::addloot($randa,1);
}
if($rewardr > 9)
{
quest::addloot($randw,1);
}
}
}
http://www.perlmonks.org/index.pl?node_id=105446
|
12-22-2012, 01:45 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
I'd place the rands in an EVENT_SPAWN sub, and I'm not quite sure when EVENT_DEATH is called (from a server source stand point) at the moment (yes, common sense says after the NPC is dead, thus death but...).
|
12-22-2012, 02:02 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Code:
sub EVENT_SPAWN {
my $rands = quest::ChooseRandom(15270,15275,15075,15271,15279,15212,15079,15274,15272);
my $randa = quest::ChooseRandom(2031,2036,2030,2034,2027,2038,2026,2029,2025,2032,2028,2033);
my $randw = quest::ChooseRandom(5043,6032,6030,7022,7024,94155,6031);
my $rewardr = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10);
if($NPCRace!=54)
{
if($rewardr < 4) {quest::addloot($rands,1);}
if($rewardr < 7 && $rewardr > 3) {quest::addloot($randw,1);}
if($rewardr < 10 && $rewardr > 6) {quest::addloot($randa,1);}
if($rewardr > 9) {quest::addloot($randw,1);}
}
}
Really untested, didn't check your logic (besides the mistype of $rewardar instead of $rewardr in one instance), am on the laptop at the moment..
|
12-22-2012, 02:09 AM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
yeah, lexical scope is your issue.
add the following to the top of your scripts and run them from a command line to catch things like what you are experiencing.
you should be using if/ elsif/ else in logic chains, not just if. it won't stop looking for matches after the first one is found otherwise.
you can also use the range (..) and smart match (~~) operators to see if a value is in a range of numbers like this:
Code:
if($rewardr ~~ [7..9]) {
...;
}
|
12-22-2012, 05:04 AM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
Code:
use List::Util qw(first);
sub EVENT_COMBAT
{
return()unless($combat_state);
$npc->Heal();
quest::say(($npc->GetRace()==54?"Your blood will spill.":"Time to die, $name!"));
}
sub EVENT_DEATH
{
return()if($npc->GetRace()==54);
my($extra_loot)={
join(' ',1..3)=>[15270,15275,15075,15271,15279,15212,15079,15274,15272],
join(' ',4..6)=>[5043,6032,6030,7022,7024,94155,6031],
join(' ',7..9)=>[2031,2036,2030,2034,2027,2038,2026,2029,2025,2032,2028,2033]
};
$extra_loot->{'10 10'}=$extra_loot->{join(' ',4..6)};
my($roll)=quest::ChooseRandom(1..10);
quest::addloot(quest::ChooseRandom(@{$extra_loot->{first{$roll~~[split(' ',$_)]}keys(%$extra_loot)}}),1);
}
|
12-28-2012, 12:55 AM
|
|
Sarnak
|
|
Join Date: Aug 2012
Location: work
Posts: 74
|
|
Thank youR very much!!!
__________________
To create the most beautiful server for "!!~[BP] PLARYBOT EQ~!" Welcome to our server
|
01-04-2013, 11:48 PM
|
|
Sarnak
|
|
Join Date: Aug 2012
Location: work
Posts: 74
|
|
Quote:
Originally Posted by c0ncrete
Code:
use List::Util qw(first);
sub EVENT_COMBAT
{
return()unless($combat_state);
$npc->Heal();
quest::say(($npc->GetRace()==54?"Your blood will spill.":"Time to die, $name!"));
}
sub EVENT_DEATH
{
return()if($npc->GetRace()==54);
my($extra_loot)={
join(' ',1..3)=>[15270,15275,15075,15271,15279,15212,15079,15274,15272],
join(' ',4..6)=>[5043,6032,6030,7022,7024,94155,6031],
join(' ',7..9)=>[2031,2036,2030,2034,2027,2038,2026,2029,2025,2032,2028,2033]
};
$extra_loot->{'10 10'}=$extra_loot->{join(' ',4..6)};
my($roll)=quest::ChooseRandom(1..10);
quest::addloot(quest::ChooseRandom(@{$extra_loot->{first{$roll~~[split(' ',$_)]}keys(%$extra_loot)}}),1);
}
|
you's .pl no working no loot!
__________________
To create the most beautiful server for "!!~[BP] PLARYBOT EQ~!" Welcome to our server
|
|
|
|
01-04-2013, 11:58 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Quote:
Originally Posted by javewow
you's .pl no working no loot!
|
Code:
use warnings;
sub EVENT_SPAWN {
my $rands = quest::ChooseRandom(15270,15275,15075,15271,15279,15212,15079,15274,15272);
my $randa = quest::ChooseRandom(2031,2036,2030,2034,2027,2038,2026,2029,2025,2032,2028,2033);
my $randw = quest::ChooseRandom(5043,6032,6030,7022,7024,94155,6031);
my $rewardr = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10);
if($NPCRace!=54)
{
if($rewardr < 4) {
quest::addloot($rands,1);
}
elsif($rewardr ~~ [4..6]) {
quest::addloot($randw,1);
}
elsif($rewardr ~~ [7..9]) {
quest::addloot($randa,1);
}
elsif($rewardr > 9)
{quest::addloot($randw,1);
}
}
}
sub EVENT_COMBAT {
my $NPCRace = $npc->GetRace();
if($combat_state == 1) {
$npc->Heal();
}
if($NPCRace==54) {
quest::say("your blood will spill.");
}
else {
quest::say("Time to die $name!");
}
}
sub EVENT_DEATH
{
quest::say("Arrg defeated by a subroutine reversion!");
}
I did not test the above, give it a try, or, try changing:
to
To see if it returns more favorable results. Perl therefore quests are indeed working otherwise right?
*edited: excuse the odd code format, copy/pasted from a PM I sent and I see it retained it's odd format once again.. wierd.
|
|
|
|
|
|
|
01-05-2013, 12:02 AM
|
|
Sarnak
|
|
Join Date: Aug 2012
Location: work
Posts: 74
|
|
Below for random drop of class----loot
You can add more later in the class ???? HELP
%item = ("Warrior" => 76600,
"Rogue" => 76601,
"Monk" => 76602,
"Berserker" => 76603,
"Shadowknight" => 76604,
"Paladin" => 76605,
"Ranger" => 76607,
"Bard" => 76608,
"Beastlord" => 76609,
"Cleric" => 76610,
"Druid" => 76611,
"Shaman" => 76612,
"Wizard" => 76613,
"Magician" => 76614,
"Enchanter" => 76615,
"Necromancer" => 76616);
sub EVENT_AGGRO {
my $Phrase1 = "Your faithless devotion to a false god leaves me no choice.";
my $Phrase2 = "I shall rid the land of another infamous villain.";
my $Phrase3 = "Your foul deeds have earned my contempt.";
my $Phrase4 = "${class}s like you are better left dead than alive.";
my $Phrase5 = "It's ${race}s like you who have ruined your own lands, You'll not ruin mine!";
my $Phrase6 = "Heathen! Unbeliever! Norrath must be cleansed!";
my $Phrase7 = "Your beliefs are an insult to us all!";
my $Phrase8 = "Your actions and history are a personal affront to all I stand for.";
my $Phrase9 = "Your intolerable reputation insults all in this realm.";
my $Phrase10 = "It's time for you to take your blasphemy into the next realm.";
my $Phrase11 = "${race}s like you are better left dead than alive.";
my $class_item = $item{$class};
my $Phrase = quest::ChooseRandom($Phrase1,$Phrase2,$Phrase3,$Ph rase4,$Phrase5,$Phrase6,$Phrase7,$Phrase8,$Phrase9 ,$Phrase10,$Phrase11);
quest::say("Rrrrrrrrooooaaakkk!");
my $Chance = quest::ChooseRandom(1,2,3,4);
if ($Chance == '1') {
quest::say("$Phrase");
quest::addloot($class_item,1);
}
}
--------------------------------------------------------
%item = ("Warrior" => 76600, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Rogue" => 76601, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Monk" => 76602, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Berserker" => 76603, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Shadowknight" => 76604, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Paladin" => 76605, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Ranger" => 76607, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Bard" => 76608, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Beastlord" => 76609, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Cleric" => 76610, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Druid" => 76611, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Shaman" => 76612, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Wizard" => 76613, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Magician" => 76614, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Enchanter" => 76615, XXXX, XXXXX, XXXXXX, XXXX, XXXX,
"Necromancer" => 76616),XXXX, XXXXX, XXXXXX, XXXX, XXXX, ;
sub EVENT_AGGRO {
my $Phrase1 = "Your faithless devotion to a false god leaves me no choice.";
my $Phrase2 = "I shall rid the land of another infamous villain.";
my $Phrase3 = "Your foul deeds have earned my contempt.";
my $Phrase4 = "${class}s like you are better left dead than alive.";
my $Phrase5 = "It's ${race}s like you who have ruined your own lands, You'll not ruin mine!";
my $Phrase6 = "Heathen! Unbeliever! Norrath must be cleansed!";
my $Phrase7 = "Your beliefs are an insult to us all!";
my $Phrase8 = "Your actions and history are a personal affront to all I stand for.";
my $Phrase9 = "Your intolerable reputation insults all in this realm.";
my $Phrase10 = "It's time for you to take your blasphemy into the next realm.";
my $Phrase11 = "${race}s like you are better left dead than alive.";
my $class_item = $item{$class};
my $Phrase = quest::ChooseRandom($Phrase1,$Phrase2,$Phrase3,$Ph rase4,$Phrase5,$Phrase6,$Phrase7,$Phrase8,$Phrase9 ,$Phrase10,$Phrase11);
quest::say("Rrrrrrrrooooaaakkk!");
my $Chance = quest::ChooseRandom(1,2,3,4);
if ($Chance == '1') {
quest::say("$Phrase");
quest::addloot($class_item,1);
}
}
__________________
To create the most beautiful server for "!!~[BP] PLARYBOT EQ~!" Welcome to our server
|
|
|
|
01-05-2013, 12:09 AM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Edit that post and use the code blocks please. I left my ANSI terminal back in 1990. <grin>
|
01-05-2013, 12:36 AM
|
|
Sarnak
|
|
Join Date: Aug 2012
Location: work
Posts: 74
|
|
Quote:
Originally Posted by ghanja
Edit that post and use the code blocks please. I left my ANSI terminal back in 1990. <grin>
|
Please!
Help!
breakdown method! pleas
__________________
To create the most beautiful server for "!!~[BP] PLARYBOT EQ~!" Welcome to our server
|
01-05-2013, 12:37 AM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
Quote:
Originally Posted by javewow
you's .pl no working no loot!
|
sorry, it is quite possible that's because i changed when the events are run in my source. previously, they were fired off after the corpse was created and the npc in question was removed from the entity list, if i remember correctly. i moved the block that runs the events up to right before those things occur in my source.
you could also change it to where the loot is added in EVENT_COMBAT (where $combat_state is 1). then you could save the itemID that is added in an EntityVariable for that npc, then remove the item it in EVENT_COMBAT (where $combat_state is 0).
Last edited by c0ncrete; 01-05-2013 at 12:47 AM..
Reason: added suggestion
|
01-05-2013, 12:39 AM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
Quote:
Originally Posted by javewow
Please!
Help!
breakdown method! pleas
|
indent your scripts and post them inside of CODE tags (it's the # symbol) in the message toolbar.
|
01-05-2013, 01:40 AM
|
Demi-God
|
|
Join Date: Aug 2010
Posts: 1,743
|
|
Well, for sure, all the XXX aren't gonna work.
|
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 03:47 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|