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!! |
Code:
my $rands = quest::ChooseRandom(15270,15275,15075,15271,15279, 15212,15079,15274,15272); |
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...). :)
|
Code:
sub EVENT_SPAWN { |
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. Code:
use warnings; 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]) { |
Code:
use List::Util qw(first); |
Thank youR very much!!!
|
Quote:
|
Quote:
Code:
use warnings; Code:
sub EVENT_DEATH Code:
sub EVENT_SPAWN *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. |
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); } } |
Edit that post and use the code blocks please. I left my ANSI terminal back in 1990. <grin>
|
Quote:
Help! breakdown method! pleas |
Quote:
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). |
Quote:
|
Well, for sure, all the XXX aren't gonna work.
|
Quote:
For example: 69800,69801,69802,69803,69804...... is ok? |
I'm afraid I don't understand what you want the script to do. The original thread was about adding random loot to a mob. I'm not sure what the classes have to do with that.
|
are you trying to add random loot to the npc based on the class(es) of the character(s) involved in the encounter?
|
All times are GMT -4. The time now is 05:43 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.