EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   Set Race of NPC based on owner of instance? (https://www.eqemulator.org/forums/showthread.php?t=32483)

Templus 11-14-2010 09:14 PM

Set Race of NPC based on owner of instance?
 
Is there any way to set the race of an NPC based on the owner of an instance? (without having to keep crazy kinds of track of that kind of thing using global variables) .. I guess it can be done with some sort of global variable system though ... hmm

Templus 11-15-2010 11:56 AM

I can't seem to set a global variable...

Code:

quest::setglobal("newbrace_$instanceID", $raceid, 7,"H2");

quest::say("Global Set");

my $glob = $qglobals{"newbrace_$instanceID"};

quest::say("Global: ".$glob);

the output for Global: is empty. . just "Global: " .. that's it .. as if the global hasn't been set

joligario 11-15-2010 12:12 PM

. conjunctions don't work in this system. Try "Global: $glob"

Templus 11-15-2010 12:16 PM

still not working

Code:


quest::setglobal("newbrace_$instanceID", $raceid, 7,"H2");

quest::say("Global Set");

my $glob = $qglobals{"newbrace_$instanceID"};

quest::say("Global: $glob");

my output is:
instanceID: 39
raceid: 5
global:

=\

joligario 11-15-2010 10:21 PM

And don't use quotes in global values: $qglobals{global_name}

Now that I'm reading your post better... I think you are overthinking this by using globals. You can create different versions of the zone, and then just use the quest system to determine the proper version based upon race.

Templus 11-15-2010 10:30 PM

interesting idea.. but then I'd have to make a ton of copies of the zone with all the spawns/npcs in them .. hmm .. not sure how to do that either .. lol =\

i'll try it without the quotes .. is it ok though that a variable makes up part of the variable name?

edit:

looks like i found my answer .. this doesn't work.. crashes the perl script:
Code:

my glob = $qglobals{newbrace_$instanceID};

joligario 11-15-2010 11:12 PM

That wouldn't work anyways with just glob ... it should be a variable $glob

Templus 11-15-2010 11:14 PM

errrr .. yeah it is $glob .. I just messed up retyping it in the post here

the problem is with using $instanceID as part of the variable name

joligario 11-15-2010 11:15 PM

Yes, I understand. You are right, it would not work with a variable like that.

joligario 11-15-2010 11:36 PM

However, you can set the value before hand like this:
Code:

sub EVENT_SAY {
  if ($text=~/set/i) {
    $test_value = 5;
    $test_global = "glob_test$test_value";
    quest::setglobal($test_global,1,5,"M1");
    quest::say("Global set.");
  }
  if ($text=~/get/i) {
    $glob_value = $qglobals{$test_global};
    quest::say("The global $test_global has a value of $glob_value");
  }
}


Akkadius 11-16-2010 12:06 AM

Quote:

Originally Posted by Templus (Post 194225)
errrr .. yeah it is $glob .. I just messed up retyping it in the post here

the problem is with using $instanceID as part of the variable name

Situationally, what exactly are you trying to achieve. I know you are trying to set the race of something based on instance but could you give a little more detail and perhaps there would be a better way to approach it. Is it one npc? multiple npcs? Reason behind it?

Templus 11-16-2010 02:40 AM

noob enters the world, goes to the loading zone, is immediately transferred to a new private instance created for them where they are welcomed by 2 NPCs that are of their same race.. they then go through kind of a trial.. so it could be annoying to write X different zone instances for each race.. unless there's some way to automate it / copy 1 instance to several..

so using global variables.. I figure that when I create the instance I save out the user's race and after I spawn the 2 welcoming NPCs I set their races based on the global variable I saved when creating the instance.. it should work? except I can't seem to save/read these global variables =\

joligario 11-16-2010 02:45 AM

The NPC must have qglobal set to 1 in the npc_types table in order for them to read the qglobal.

If you are only going to set 2 NPCs, you wouldn't need to do any of this. I would set up a player.pl file in the zone which modifies the race of the 2 NPCs based upon the player's race...

Templus 11-16-2010 02:56 AM

Quote:

Originally Posted by joligario (Post 194232)
The NPC must have qglobal set to 1 in the npc_types table in order for them to read the qglobal.

If you are only going to set 2 NPCs, you wouldn't need to do any of this. I would set up a player.pl file in the zone which modifies the race of the 2 NPCs based upon the player's race...

interesting .. how would you set something like that up in player.pl? I didn't realize you could do that..

edit:

hmm .. perhaps something as simple as using a proximity event on the mob?

joligario 11-16-2010 03:45 AM

An example may be to do something like this:

player.pl
Code:

sub EVENT_ENTERZONE {
  quest::signalwith(1001,$client->GetBaseRace(),0);
  quest::signalwith(1002,$client->GetBaseRace(),0);
}

1001.pl and 1002.pl
Code:

sub EVENT_SIGNAL {
  quest::npcrace($signal);
}

EDIT: Yes, a proximity would work just fine. BTW, questions like this should go under a quests forum rather than windows server forum.


All times are GMT -4. The time now is 10:22 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.