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 07-15-2017, 02:27 PM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default Random Race?

So I was looking around for a code to make npc's have a random race upon spawn. I know how to write it for the most part but im having trouble finding which command to use. Only one I see on wiki is

Code:
quest::npcrace(raceid) # Temporarily changes the NPC's race
however my concern is what is the limitations on the 'temporary' change? Would that be the best line to use for what im trying to do?

If anyone is unclear I simply want the npc to be a random race when spawning.

Would this actually work? (Dont have time to test atm)

Code:
Sub EVENT_SPAWN {
$rand = quest::ChooseRandom(1..12,522,130);
quest::npcrace($rand) # Temporarily changes the NPC's race
}
}
Reply With Quote
  #2  
Old 07-15-2017, 02:49 PM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

Well I tested it and it doesnt work, Not to sure what I did wrong lol
Reply With Quote
  #3  
Old 07-15-2017, 06:50 PM
atrayas
Hill Giant
 
Join Date: Jun 2010
Posts: 105
Default

havnt tested this but it should work.

Code:
@races = (464,466,469,458,467,454,367,420,);

sub EVENT_SPAWN
{
quest::npcrace(quest::ChooseRandom(@races));
}
Reply With Quote
  #4  
Old 07-15-2017, 07:03 PM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

Will give it a shot, will it work like that for gender as well?
Reply With Quote
  #5  
Old 07-15-2017, 09:08 PM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

So tested it and added line for gender as well, only question now is there a way to make the race picked have the correct size? Im getting giant gnomes and small ogres lol if not its no biggy but would like to have them scale size based on the race
Reply With Quote
  #6  
Old 07-15-2017, 11:53 PM
atrayas
Hill Giant
 
Join Date: Jun 2010
Posts: 105
Default

could create different arrays for big and small races then set the size in the script based on the model
Reply With Quote
  #7  
Old 07-16-2017, 07:29 AM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

Mind giving me an example to build off of? Sounds a bit out of my current skill set lol
Reply With Quote
  #8  
Old 07-17-2017, 12:51 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Replied to your PM, but, posting here all to see:

Code:
sub EVENT_SPAWN {
	## both arrays below should have same number of elements, in pairs
	my @npcraces = (367,	420,	454,	458,	464,	466,	467,	469);
	my @npcsizes = (5,		3,		7,		4,		6,		5,		5,		4);
	my $elementselected = quest::ChooseRandom(0..((scalar @npcraces) - 1));
	quest::npcrace($npcraces[$elementselected]);
	quest::npcsize($npcsizes[$elementselected]);
	quest::npcgender(quest::ChooseRandom(0..1));
}

## or

sub EVENT_SPAWN {
	# keys start at 1, add as many key/value pairs as you'd like, first element in array is race, second is size
	%SpawnHash = (
		1		=>	[367, 5],
		2		=>	[420, 3],
		3		=>	[454, 7],
		4		=>	[458, 4],
	);
	my $selectedkey = quest::ChooseRandom(1..(scalar keys %SpawnHash));
	quest::npcrace($SpawnHash[$selectedkey][0]);
	quest::npcsize($npcsizes[$selectedkey][1]);
	quest::npcgender(quest::ChooseRandom(0..1)); # in case you wouldn't want to deal with it in the hash
}

## or

sub EVENT_SPAWN {
	# keys start at 1, add as many key/value pairs as you'd like, first element in array is race, second is size, third is gender
	%SpawnHash = (
		1		=>	[367, 5, 0],
		2		=>	[420, 3, 1],
		3		=>	[454, 7, 1],
		4		=>	[458, 4, 0],
	);
	my $selectedkey = quest::ChooseRandom(1..(scalar keys %SpawnHash));
	quest::npcrace($SpawnHash[$selectedkey][0]);
	quest::npcsize($SpawnHash[$selectedkey][1]);
	quest::npcgender($SpawnHash[$selectedkey][2]);
}
Reply With Quote
  #9  
Old 07-17-2017, 05:16 PM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

Using the following code, checked all races sizes and gender options via GM commands, but all i keep getting are tiny humans.

Code:
sub EVENT_SPAWN {
	# keys start at 1, add as many key/value pairs as you'd like, first element in array is race, second is size, third is gender
	%SpawnHash = (
	1		=>	[1, 6, 0],
	2		=>	[2, 7, 1],
	3		=>	[3, 6, 1],
	4		=>	[4, 5, 1],
	5		=>	[5, 6, 0],
	6		=>	[6, 5, 1],
	7		=>	[7, 5.5, 0],
	8		=>	[8, 4, 1],
	9		=>	[9, 8, 0],
	10		=>	[10, 9, 1],
	11		=>	[11, 3.5, 1],
	12		=>	[12, 3, 0],
	13		=>	[130, 7, 1],
	14		=>	[522, 6, 0],
	15		=>	[128, 6, 0],
	16		=>	[330, 5, 1],
	);
	my $selectedkey = quest::ChooseRandom(1..(scalar keys %SpawnHash));
	quest::npcrace($SpawnHash[$selectedkey][0]);
	quest::npcgender($SpawnHash[$selectedkey][2]);
	quest::npcsize($SpawnHash[$selectedkey][1]);
}
Reply With Quote
  #10  
Old 07-17-2017, 06:43 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

As mentioned in your PM I just replied to, but will post if here. You're using a model not loading with the zone. You'll want to research how to modify your /resources/GlobalLoad.txt file based on your requirements/desires.

And yep, first time hearing about tiny humans (this could also be a gender issue, basically, the combination of race/gender doesnt match with what is loaded in the client either because of the globalload and/or because of wrong gender).
Reply With Quote
  #11  
Old 07-18-2017, 07:59 AM
Baelu
Sarnak
 
Join Date: Jun 2017
Posts: 30
Default

idk man only models im using are playable races, and the code I originally used worked fine, was just having a sizing issue. Here is the code im using now

Code:
sub EVENT_SPAWN {
	# keys start at 1, add as many key/value pairs as you'd like, first element in array is race, second is size, third is gender
	%SpawnHash = (
	1		=>	[1, 6, 0],
	2		=>	[2, 7, 1],
	3		=>	[3, 6, 1],
	4		=>	[4, 5, 1],
	5		=>	[5, 6, 0],
	6		=>	[6, 5, 1],
	7		=>	[7, 5.5, 0],
	8		=>	[8, 4, 1],
	9		=>	[9, 8, 0],
	10		=>	[10, 9, 1],
	11		=>	[11, 3.5, 1],
	12		=>	[12, 3, 0],
	13		=>	[130, 7, 1],
	14		=>	[522, 6, 0],
	15		=>	[128, 6, 0],
	16		=>	[330, 5, 1],
	);
	my $selectedkey = quest::ChooseRandom(1..(scalar keys %SpawnHash));
	quest::npcrace($SpawnHash[$selectedkey][0]);
	quest::npcsize($SpawnHash[$selectedkey][1]);
	quest::npcgender($SpawnHash[$selectedkey][2]);
}

And here is my first code,

Code:
@races = (1,2,3,4,5,6,7,8,);
@gender = (0,1);
sub EVENT_SPAWN
{
quest::npcrace(quest::ChooseRandom(@races));
quest::npcgender(quest::ChooseRandom(@gender));
}
The first code produces only tiny humans, the 2nd code changes the races and genders but you end up with giant sized gnomes and small ogres lol. Anyone have a suggestion?
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 10:58 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3