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

08-05-2010, 03:43 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
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)
|

08-05-2010, 05:34 PM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
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.
|

08-05-2010, 05:34 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
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
|

08-05-2010, 05:40 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
Quote:
Originally Posted by joligario
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?
|

08-05-2010, 05:40 PM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
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.
|

08-05-2010, 05:45 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
Quote:
Originally Posted by joligario
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.
|

08-05-2010, 05:48 PM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
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.
|

08-05-2010, 05:49 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
Quote:
Originally Posted by joligario
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.
|

08-05-2010, 05:57 PM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
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);
}
}
|

08-05-2010, 10:32 PM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
FYI: Now that I am awake and rereading this, I missed a closing ) on line 2
|
 |
|
 |

08-06-2010, 08:20 AM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
Quote:
Originally Posted by joligario
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
|
 |
|
 |

08-06-2010, 09:25 AM
|
 |
Developer
|
|
Join Date: Mar 2003
Posts: 1,498
|
|
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.
|

08-06-2010, 11:10 AM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
Quote:
Originally Posted by joligario
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
|

08-16-2010, 10:18 PM
|
Hill Giant
|
|
Join Date: Jul 2007
Posts: 111
|
|
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
|

08-17-2010, 12:41 AM
|
Dragon
|
|
Join Date: May 2009
Location: Milky Way
Posts: 539
|
|
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);
}
}
|
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:31 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |