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

Quests::Custom Custom Quests here

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-20-2018, 02:52 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default "a_brave_rat" AKA: make the static more dynamic

This is an unfinished example of how you can easily add a lot of flavor to any generic NPC with scripting alone. I wrote it years ago and never did much with it, so I thought I'd share to maybe help spark some creativity.

(a_cave_rat.pl @ tutorialb)

Code:
my %instance = ();


sub AI_YellForHelp
{
	my $npc_num	= substr($npc->GetName(),-3);
	my $signal	= scalar 911 . scalar 0 . scalar $instance{$npc_num} . scalar 0 . scalar $npc_num;

	# tell a_cave_rat which variant is yelling for help.
	quest::signalwith(189453,$signal);
}


sub EVENT_SPAWN
{

	# ==== HIDDEN (GENDER) NPC VARIATION ==== #

	# 0 = female
	# 1 = male
	# 2 = adolescent
	my $variant = int(rand(3));
	my $npc_num = substr($npc->GetName(),-3);

	$instance{$npc_num} = $variant;

	# ==== VISIBLE (SIZE) NPC VARIATION ==== #
	
        my $SizeMult = sub { .01 * ( $_[0] + int rand $_[1] - $_[0] ) };
        # randomly changes size by percentage mutiples in range provided
        # (example below is between 75% to 125% of original size)
	$npc->ChangeSize( $npc->GetSize() * $SizeMult->(75, 125) );

}


sub EVENT_ATTACK
{
	$client->Message(7, "You have a strange feeling this might not end well...");
	quest::setnexthpevent(50);
}


sub EVENT_HP
{

	if($hpevent == 50)
	{
		# 25% chance to call for help
		if(int(rand(100) >= 75)
		{
			quest::emote("squeaks loudly.");
			AI_YellForHelp();
		}
	}

}

sub EVENT_SIGNAL
{

	my $strSignal = scalar $signal;

	if (length $strSignal == 9 && substr($strSignal, 0, 3) == 911)
	{
		my $otherType   = int(substr($strSignal, 4, 1));
		my $otherNumber =     substr($strSignal, 6, 3);
	
		my $myNumber = substr($npc->GetName(),-3);
		my $myType   = $instance{$myNumber};

		# TO DO: implement range/LOS check.

		if($npc->IsEngaged())
		{
			quest::shout("DEBUG: $myNumber is busy and can't help $");
		}
		# we got a request for help from variant 0 (female)
		elsif($otherType == 0 && $myType == 1)
		{
			# TO DO: assist if male (%75).
			quest::shout("DEBUG: $myNumber is thinking about helping (0->1 @ 75%)");
		}
		# we got a request for help from variant 1 (male)
		elsif($otherType == 1 && $myType == 1)
		{
			# TO DO: assist if male (50%).
			quest::shout("DEBUG: $myNumber is thinking about helping (1->1 @ 50%)");
		}
		# we got a request for help from variant 2 (adolescent)
		elsif($otherType == 2)
		{
			if($myType == 0)
			{
				# TO DO: assist if female (100%).
				quest::shout("DEBUG: $myNumber is thinking about helping (2->0 @ 100%)");
			}
			elsif($myType == 2)
			{
				# TO DO: assist if adolescent (25%).
				quest::shout("DEBUG: $myNumber is thinking about helping (2->2 @ 25%)");
			}
		}
	}

}

sub EVENT_DEATH
{

	# delete dead rat's instance data
	my $npc_num = substr($npc->GetName(),-3);
	delete($instance{$npc_num});

}
__________________
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; 02-20-2018 at 05:49 PM.. Reason: corrected SizeMult subroutine... wat
Reply With Quote
 


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 04:13 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