Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2018, 04:35 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default Individually Randomized Stat Scaling Method

Code:
# ============

# aliasing via typeglobs
# https://perldoc.perl.org/perldata.html#Typeglobs-and-Filehandles
*randRange = \*plugin::RandomRange;

# ============

# hash of stuff we want to possibly randomize, and by how much.
# this setup allows you to tweak chances of and ranges of scaling each stat
# it also allows you to keep the logic below a little cleaner.
my $target = {
	# strength
	str => {
		# chance at randomization defined here (25%)
		randomize => do { rand 100 > 75 },
		# 'normal' scaling is a range of 110-130% at a 75% chance
		# 'critical' scaling is a range of 130-200% at a 25% chance
		modifier  => do { rand 100 > 75 ? randRange(10, 25) : randRange(25, 75) },
		# workaround since each stat has its own method of retrieval
		accessor  => do { $npc->GetSTR() },
		# arbitrary here, but it's a good idea to have the ones below
		cleanup   => do { $npc->Emote("snarls menacingly...") },
	},
	# intelligence
	_int => {
		randomize => do { rand 100 > 75 },
		modifier  => do { rand 100 > 75 ? randRange(10, 30) : randRange(30, 100) },
		accessor  => do { $npc->GetINT() },
		cleanup   => do { $npc->SetMana($npc->GetMaxMana()) },
	},
	# wisdom
	wis => {
		randomize => do { rand 100 > 75 },
		modifier  => do { rand 100 > 75 ? randRange(10, 30) : randRange(30, 100) },
		accessor  => do { $npc->GetWIS() },
		cleanup   => do { $npc->SetMana($npc->GetMaxMana()) },
	},
	# stamina
	sta => {
		randomize => do { rand 100 > 75 },
		modifier  => do { rand 100 > 75 ? randRange(10, 30) : randRange(30, 100) },
		accessor  => do { $npc->GetSTA() },
		cleanup   => do { $npc->Heal() },
	},
};

# for each stat listed in the table of targets...
foreach my $stat (keys %$target)
{
	# skip stat if we don't roll a chance to randomize it
	# TODO: further modify chances based on race/class
	next unless $target->{$stat}->{randomize};

	# get the current value of the stat we are looking at
	my $current = $target->{$stat}->{accessor};

	# roll for and retrieve the modifier to use to scale the stat
	my $scale = $target->{$stat}->{modifier};
	
	# stat scaling calculation happens here
	my $modified = $current + int($current*(rand $scale/100));
	
	# change applied
	$npc->ModifyNPCStat($stat, $modified);
	
	# do any cleanup defined for the current stat
	$target->{$stat}->{cleanup} if defined $target->{$stat}->{cleanup};
};
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;

Last edited by c0ncrete; 03-13-2018 at 04:39 AM.. Reason: i had stamina listed as charisma...
Reply With Quote
  #2  
Old 03-13-2018, 08:31 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

annnnnd if you put this in your global_npc.pl
Code:
*Mob::Blast = sub {
	my $self = shift;
	$self->SetMana($self->GetMaxMana());
	$self->Emote("shimmers slightly.");
};
you can do this
Code:
$mob->Blast()
when you want the equivalent of this for mana
Code:
$mob->Heal()
which is currently this
Code:
$mob->SetMana($mob->GetMaxMana())
it will work for any object that is derived from the Mob class.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
Reply

Thread Tools
Display Modes

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