|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
|
|
|
01-06-2009, 07:02 AM
|
Sarnak
|
|
Join Date: Oct 2008
Location: AZ
Posts: 58
|
|
How do I get $mob->SetHP($mob->GetHP()*85); to work right?
This is what I am trying to do, but cant seem to get it right is to get the mob to spawn with a lower percentage of health, in this case it would be 85% and every 15% there on after. the text in red is what I want to get to work and then proceed to copy that for each health percentage. This way I can change this mob's HP and not have to worry about changing the script each time just to adjust the HP I want the mob to be at, at each of these globals.
Code:
sub EVENT_SPAWN
{
if(defined($qglobals{yar})){ #spawn at lower % of health
if ($qglobals{yar} == 1)
{
quest::shout ("RAWR 1"); #was used to test if the script ws working
}
elsif ($qglobals{yar} == 2)
{
quest::shout ("RAWR 2");
$mob->SetHP($mob->GetHP()*85);
}
elsif ($qglobals{yar} == 3)
{
$npc->SetHP(7000);
}
elsif ($qglobals{yar} == 4)
{
$npc->SetHP(5500);
}
elsif ($qglobals{yar} == 5)
{
$npc->SetHP(4000);
}
elsif ($qglobals{yar} == 6)
{
$npc->SetHP(2500);
}
elsif ($qglobals{yar} == 7)
{
$npc->SetHP(1000);
}
}
}
I hate searching the forums for hours on end for posts similair to what I want so I can use it in my own scripts. This one has been bugging me the last few days. If I can get this one snipet to work, I think it would make for an awesome mob encounter (im going to use it for sure). I will even post it in the quest custom section of the forums for all who would like to use it or some form of it or alter it to their own needs.
I am going to bed since its 4am and I need to get up in a few hours to deal with RL stuff.
TIA!!!!!
|
|
|
|
01-06-2009, 07:33 AM
|
|
Developer
|
|
Join Date: Mar 2003
Posts: 1,497
|
|
Did you try 0.85?
|
01-06-2009, 08:06 AM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Something like this should work. If it doesn't, lemme know.
Code:
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.85);
$npc->SetHP($set_hps);
|
|
|
|
01-06-2009, 01:39 PM
|
Sarnak
|
|
Join Date: Oct 2008
Location: AZ
Posts: 58
|
|
Trev, you are awesome.
Ya that worked perfectly. Thanks a ton for the help. Ill post the full script here, and in the custom quests for all who would like it have it.
This is how it works. Give the furious sentry an item. This spawns Yar`lir's first form and sets the qglobal.
at 85% health the this will depop the first form and choose another 1 of 4 forms of the same mob randomly, then 5% health lower (80% health) adds will spawn based off of which form was previously chosen.
This will repeat at 70/65%, then at 55/50%, then 40/35%, then 25/20% and finally at 10/9%. upon death adds will despawn and a chest will appear with loot inside.
I tested this script 3 times all with different amounts of HP of the main mobs, just to make sure it worked.
I have trevius to thank for help on completing the script. Thanks alot!!
Code:
#Furious Sentry
sub EVENT_SAY
{
if($text =~/Hail/i)
{
quest::say ("?"); #can make this say what ever you want.
}
}
sub EVENT_ITEM
{
if (plugin::check_handin(\%itemcount, 57206 => 1))
{
quest::say("Yar = 1");
quest::delglobal("yar");
quest::setglobal("yar", 1, 3, "F");
quest::spawn2(999483, 0, 0, -3491, 3142, 302, 58);
}
}
Code:
#Yar`lir encounter
sub EVENT_SPAWN
{
if(defined($qglobals{yar})){ #spawn at lower % of health
if ($qglobals{yar} == 1)
{
quest::shout ("RAWR 1");
}
elsif ($qglobals{yar} == 2)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.85);
$npc->SetHP($set_hps);
}
elsif ($qglobals{yar} == 3)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.70);
$npc->SetHP($set_hps); }
elsif ($qglobals{yar} == 4)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.55);
$npc->SetHP($set_hps); }
elsif ($qglobals{yar} == 5)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.40);
$npc->SetHP($set_hps); }
elsif ($qglobals{yar} == 6)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.25);
$npc->SetHP($set_hps); }
elsif ($qglobals{yar} == 7)
{
my $max_hps = $npc->GetMaxHP();
my $set_hps = ($max_hps * 0.10);
$npc->SetHP($set_hps);
}
}
}
sub EVENT_COMBAT
{
if($combat_state == 1)
{
if(defined($qglobals{yar})){
if ($qglobals{yar} == 1)
{
quest::setnexthpevent(85);
}
elsif ($qglobals{yar} == 2)
{
quest::setnexthpevent(80);
}
elsif ($qglobals{yar} == 3)
{
quest::setnexthpevent(65);
}
elsif ($qglobals{yar} == 4)
{
quest::setnexthpevent(50);
}
elsif ($qglobals{yar} == 5)
{
quest::setnexthpevent(35);
}
elsif ($qglobals{yar} == 6)
{
quest::setnexthpevent(20);
}
elsif ($qglobals{yar} == 7)
{
quest::setnexthpevent(9);
}
}
}
if($combat_state == 0) #depop adds if all players die
{
quest::signalwith(999488, 2, 0);
quest::signalwith(999489, 2, 0);
quest::signalwith(999021, 2, 0);
}
}
sub EVENT_HP
{
if($hpevent == 85) # change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 2, 3, "F");
quest::depop();
}
elsif($hpevent == 80) #spawn adds
{
quest::setnexthpevent(70);
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
elsif($hpevent == 70) #change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 3, 3, "F");
quest::depop();
}
elsif($hpevent == 65) #spawn adds
{
quest::setnexthpevent(55);
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
elsif($hpevent == 55) #change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 4, 3, "F");
quest::depop();
}
elsif($hpevent == 50) #spawn adds
{
quest::setnexthpevent(40);
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
elsif($hpevent == 40) #change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 5, 3, "F");
quest::depop();
}
elsif($hpevent == 35) #spawn adds
{
quest::setnexthpevent(25);
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
elsif($hpevent == 25) #change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 6, 3, "F");
quest::depop();
}
elsif($hpevent == 20) #spawn adds
{
quest::setnexthpevent(10);
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
elsif($hpevent == 10) #change form randomly
{
my $x;
my $y;
my $z;
my $h;
my $a = int(rand(4)+1);
if ($a == 1) { #matriarch
quest::spawn2(1242,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 1, 3, "F");
}
elsif ($a == 2) { #winds
quest::spawn2(1244,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 2, 3, "F");
}
elsif ($a == 3) { #hurricane
quest::spawn2(1245,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 3, 3, "F");
}
elsif ($a == 4) { #storm NO ADDS
quest::spawn2(999483,0,0,-3491,3142,302,58);
quest::delglobal("yaradds");
quest::setglobal("yaradds", 4, 3, "F");
}
quest::delglobal("yar");
quest::setglobal("yar", 7, 3, "F");
quest::depop();
}
elsif($hpevent == 9) #spawn adds
{
if(defined($qglobals{yaradds})){
if ($qglobals{yaradds} == 1) # Drake Adds
{
quest::spawn2(999021,0,0,-3467,3197,302,77);
quest::spawn2(999021,0,0,-3500,3198,302,116);
quest::spawn2(999021,0,0,-3537,3158,302,74);
quest::spawn2(999021,0,0,-3539,3128,302,56);
quest::spawn2(999021,0,0,-3502,3091,302,10);
quest::spawn2(999021,0,0,-3470,3090,302,50);
}
elsif ($qglobals{yaradds} == 2) # Wind Dervish Adds
{
quest::spawn2(999488,0,0,-3484,3089,302,0);
quest::spawn2(999488,0,0,-3484,3198,302,129);
}
elsif ($qglobals{yaradds} == 3) # Water Dervish Adds
{
quest::spawn2(999489,0,0,-3484,3089,302,0);
quest::spawn2(999489,0,0,-3484,3198,302,129);
quest::spawn2(999489,0,0,-3541,3145,302,65);
quest::spawn2(999489,0,0,-3427,3144,302,192);
}
}
}
}
sub EVENT_DEATH #depop adds and spawn chest with loot
{
quest::delglobal("yar");
quest::signalwith(999488, 1, 0);
quest::signalwith(999489, 1, 0);
quest::signalwith(999021, 1, 0);
quest::spawn2(999480,0,0,$x-20,$y+20,$z+10,$h);
}
|
|
|
|
|
|
|
01-06-2009, 05:24 PM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Unless you needed to respawn the quest mob through the fight as part of the effect, you probably could have saved yourself some time by using some of the new quest commands that let you adjust an NPC in almost any way you could want. Using quest::modifynpcstat(), you can adjust almost any NPC stat, which means very dynamic events are possible from a single boss that doesn't have to repop to change forms. You can also use quest::npcrace/gender/size/texture() to modify the looks to any look you want. The only thing I think that can't be changed on the fly now that is important is the name of the NPC.
Here is the wiki explaining those commands. You may already know about this, but if not, it is very helpful and more current than any of the other stuff like the Lexicon or the sticky post in the quest sections:
http://www.eqemulator.net/wiki/wikka...=QuestTutorial
BTW, your script looks like fun. We have a couple similar ones on Storm Haven. Some of them are pretty complex.
|
|
|
|
01-06-2009, 07:41 PM
|
Sarnak
|
|
Join Date: Oct 2008
Location: AZ
Posts: 58
|
|
I figured the name couldn't be changed, so thats why I did it the way I did, I have 4 mobs, they all have a different name and spells, but they all look the same, just with a different surname title.
I already looked over quest tutorial page, that's why I posted about the $mob->HP thing, just couldn't get it working right.
I hope my players like the encounter, been working on it for a few days now, the only snag is what you helped me fix. that was a wonderful thing you showed me, I will prolly end up using that again, just in a different manner. Im still pretty new at using perl. I learned HTML and Javascript about 8 years ago, I use it every know and than, but nothing major.
Thanks again. I really appreciated your help.
|
01-06-2009, 10:24 PM
|
Hill Giant
|
|
Join Date: May 2008
Location: Colorado
Posts: 238
|
|
Quote:
you probably could have saved yourself some time by using some of the new quest commands that let you adjust an NPC in almost any way you could want
|
Question on this: Do these new commands automatically work, or do I need to download a new build of perl? The reason I ask is because I tried the quest::we("Text") function and it does not work for me.
|
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 02:09 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|