Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2010, 03:43 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default Can you make a custom local type variable for quests?

Say kills or somthing and then once it hits 4 have an npc spawn.

if some can someone tell me how you define variables in perl?


How does this look?

Code:
$orcmysticsdead = 0;

sub EVENT_DEATH {
	$orcmysticsdead = $orcmysticsdead + 1
	
	if ($orcmysticsdead = 4){
	quest::unique_spawn(999149,0,0,1652,1535,-9,heading=69)
	}
}
is that the correct usage of

quest::unique_spawn(npc_type,grid,guildwarset,x,y, z,heading=0)
Reply With Quote
  #2  
Old 08-05-2010, 05:34 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

The only way that counter would work is if there are several of those NPCs spawned already and no new NPCs of the same version spawn in between kills. If that is the case, then yes, the variable declaration is correct. Otherwise it seems you might be better off using quest globals. Also, the spawn definition is incorrect. The reason it says heading=0 is to let you either use a number or use nothing at all which will default to 0. And don't forget your condition check and semicolons..

$orcmysticsdead = $orcmysticsdead + 1;

if ($orcmysticsdead == 4){

quest::unique_spawn(999149,0,0,1652,1535,-9,69);

FYI: I am just basing off your script, not your title. The title asked for local variables. Remember, that local means only in your scope. This method "bleeds" over multiple scripts making it more global. Not the preferred method, but it can work.
Reply With Quote
  #3  
Old 08-05-2010, 05:34 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Ok it works if i just use

Code:
sub EVENT_DEATH {
	
	quest::spawn2(999147,0,0,1652,1535,-9,69)
	
}


ahh ok i have my orcs respawning fast for testing purposes. Thats probably why. Hmmm im not too firmiliar with qglobals. I guess ill have to try that
Reply With Quote
  #4  
Old 08-05-2010, 05:40 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Quote:
Originally Posted by joligario View Post
The only way that counter would work is if there are several of those NPCs spawned already and no new NPCs of the same version spawn in between kills. If that is the case, then yes, the variable declaration is correct. Otherwise it seems you might be better off using quest globals. Also, the spawn definition is incorrect. The reason it says heading=0 is to let you either use a number or use nothing at all which will default to 0. And don't forget your condition check and semicolons..

$orcmysticsdead = $orcmysticsdead + 1;

if ($orcmysticsdead == 4){

quest::unique_spawn(999149,0,0,1652,1535,-9,69);

FYI: I am just basing off your script, not your title. The title asked for local variables. Remember, that local means only in your scope. This method "bleeds" over multiple scripts making it more global. Not the preferred method, but it can work.
how do i make it local?
Reply With Quote
  #5  
Old 08-05-2010, 05:40 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Oh, it also seems I was editing my post while you were replying. Don't forget to check the update above.

EDIT: To make it local, you declare it in the scope you want to use it. To make it private, add the "my" identifier.

sub whatever {
my $localvariable = 0;

$localvariable = 25;
}

Using it that way makes a variable available to only this sub. Looking at what you are doing above, you do not want a local variable.
Reply With Quote
  #6  
Old 08-05-2010, 05:45 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Quote:
Originally Posted by joligario View Post
Oh, it also seems I was editing my post while you were replying. Don't forget to check the update above.

EDIT: To make it local, you declare it in the scope you want to use it. To make it private, add the "my" identifier.

sub whatever {
my $localvariable = 0;

$localvariable = 25;
}

Using it that way makes a variable available to only this sub. Looking at what you are doing above, you do not want a local variable.
oh ok

yeah i know declaring in the sub would reset it when the events triggered. I dunno it seems kind of buggy the way im doing it. I mean id need it to trigger correctly for each player. I think that means i have to do q globals right?

I tried that once and gave up cause i could never make it work lol.
Reply With Quote
  #7  
Old 08-05-2010, 05:48 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

If you want it for each player, you have 2 options. Qglobals or tasks

If you want to use qglobals, ensure the NPC has quest globals enabled in the npc_types table.
Reply With Quote
  #8  
Old 08-05-2010, 05:49 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Quote:
Originally Posted by joligario View Post
If you want it for each player, you have 2 options. Qglobals or tasks

If you want to use qglobals, ensure the NPC has quest globals enabled in the npc_types table.
but can you spawn an NPC with tasks? I guess when that step is complete huh?

I forgot about that, thats much easier.
Reply With Quote
  #9  
Old 08-05-2010, 05:57 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Yes, you would spawn it in perl upon task completion.

If you want to use globals, this might be what you are trying to do:

(untested)
Code:
sub EVENT_DEATH {
  if (defined($qglobals{orcpawndeath}) {
    quest::setglobal("orcpawndeath",$qglobals{orcpawndeath}+1,0,"F");
  }
  else {
    quest::setglobal("orcpawndeath",1,0,"F");
  }
  if ($qglobals{orcpawndeath} == 4) {
    quest::setglobal("orcpawndeath",0,0,"F");
    quest::unique_spawn(999149,0,0,1652,1535,-9,69);
  }
}
Reply With Quote
  #10  
Old 08-05-2010, 10:32 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

FYI: Now that I am awake and rereading this, I missed a closing ) on line 2
Reply With Quote
  #11  
Old 08-06-2010, 08:20 AM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Quote:
Originally Posted by joligario View Post
Yes, you would spawn it in perl upon task completion.

If you want to use globals, this might be what you are trying to do:

(untested)
Code:
sub EVENT_DEATH {
  if (defined($qglobals{orcpawndeath}) {
    quest::setglobal("orcpawndeath",$qglobals{orcpawndeath}+1,0,"F");
  }
  else {
    quest::setglobal("orcpawndeath",1,0,"F");
  }
  if ($qglobals{orcpawndeath} == 4) {
    quest::setglobal("orcpawndeath",0,0,"F");
    quest::unique_spawn(999149,0,0,1652,1535,-9,69);
  }
}
Ill give it a try and see if i can get it to work. I just realized i dont need it to be for each player, just server wide so whenever all 4 orcs are dead at the same time the mob spawns.

Lemme see if i understand what your doing here so i actually learn and dont have to beg people to write scripts for me lol.

If its defined you set it to orcpawndeath +1, if its not defined you just set it to 1, when it hits 4, you reset it and spawn the mob. Do i have to enter this variable in to the database at all or just enable the qglobals on the mob like you said before
Reply With Quote
  #12  
Old 08-06-2010, 09:25 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Yup, you are reading this correct. You don't enter variables into the database. Just enable the qglobals for the npc. If you don't want it per player, then just change the options from 0 to 2.
Reply With Quote
  #13  
Old 08-06-2010, 11:10 AM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Quote:
Originally Posted by joligario View Post
Yup, you are reading this correct. You don't enter variables into the database. Just enable the qglobals for the npc. If you don't want it per player, then just change the options from 0 to 2.
thats pretty simple, maybe it was character flags i was having trouble with lol, thanks man
Reply With Quote
  #14  
Old 08-16-2010, 10:18 PM
Bellos
Hill Giant
 
Join Date: Jul 2007
Posts: 111
Default

Ok this is no longer working. I also tried to do the same thing with a different quest, different variable ect.. it doesnt work.

Can anyone help me fix it or either write it for me?

All i need is

Somthing to keep track of how many of a certain mob the player has killed.

If the player has killed 4, spawn another mob then reset so if the player kills 4 more it will respawn again.


Actually if any player in the zone kills 4 of the mob id like it to spawn so it doesnt get messed up by other people stealing mobs
Reply With Quote
  #15  
Old 08-17-2010, 12:41 AM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

Here is a script I use for similar situations that doesnt require globals. This assumes that you want the NPCs to respawn when the last is dead(regardless of kill credit), however the mobs can still respawn normally as well.

You would have an invis controller NPC with this script...

Code:
sub EVENT_SPAWN
{
	quest::settimer("start", 6);
}

sub EVENT_TIMER
{
	if ($timer eq "start") {
		quest::stoptimer("start");
		my $counter = 0;
		## Get all NPCs in zone
		my @npcList = $entity_list->GetNPCList();
		foreach $npcs(@npcList) {
			## NPC ID you want to be all dead
			if($npcs->GetNPCTypeID() == 999999) {
				$counter = 1;
			}
		}
		if($counter == 0) {
			## NPCs to respawn
			quest::spawn2(888888,0,0,x,y,z,h);
			quest::spawn2(888888,0,0,x,y,z,h);
			quest::spawn2(888888,0,0,x,y,z,h);
			quest::spawn2(888888,0,0,x,y,z,h);
		}
		quest::settimer("start", 6);
	}
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:31 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3