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

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2009, 02:40 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default Simulated AE Rampage code.

This code can be applied to any mob to simulate an AE Rampage effect that will look like like real rampage to the players. AE Rampage hits any melee's with "Rampage" within a certain radius of the mob. This code will work stand alone but can be modified to whatever you wish.

This works under sub EVENT_TIMER

How I set it up.

When mob is attacked, timer begins to set off the rampage code. Stores the mobs name, stores its max damage, then calculates what that damage would be with max shielding(can adjust this), then stores what half the max damage would be, and sets this as the min. rampage damage. Finally it finds the difference between the max and the min. More detailed bellow.

Quote:
if ($timer eq "getclientsRAMPAGE") {
$cmname = $npc->GetCleanName(); #Defines the mobs name
my $MaxDam = $npc->GetMaxDMG(); #Gets the mobs max damage
my $ShieldMaxDam = ($MaxDam * .65); #Adjust this to take account of whatever % of shielding you desire. On our server most melee are maxed so I set to 35% by default.
my $ShieldMinDam = $ShieldMaxDam / 2; #Half of max shield will be the min that can rampage can hit for
my $DamageVar = ($ShieldMaxDam - $ShieldMinDam); #Finds the difference between max and min to be used to calc. the actual rampage value.
$entity_list->MessageClose($npc, 1, 200, 13, "$cmname goes on a RAMPAGE"); #Displays exactly like a regular rampage message displays


Next we search the entity list for all clients in the zone, and it will run this loop for every client in zone. It will check the clients distance from the mob, if the distance is < then the defined value (here I choose 31), AND the player is not the mobs target they will get hit with rampage damage. Rampage damage is a random number between the max and min hit defined above. Therefore each player that is in the radius will get hit with a random amount of damage in the set range, and receive you have been rampaged message for that amount of damage.

my $list_check = 0;

for ($list_check = 0; $list_check < 2000; $list_check++) {

$client_search = $entity_list->GetClientByID($list_check);
#Above searches for every client in zone

if ($client_search) {
my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
#Calculates distance between client and mob
my $PLTarget = $npc->GetTarget();
#Finds the NPC's targets ID
my $TargID = $PLTarget->GetID();
#Finds the ID of the NPC target
my $ClID = $client_search->GetID();
#Finds the clients ID
my $RampDamageVar = (int(rand($DamageVar ))) + $ShieldMinDam;
#Calculates Rampage Damage.

if (($distanceCHK <= 31) && ($TargID != $ClID)) {
#Makes sure distance is within range and player is not target
$client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage" );
#Damages target and displays rampage message

So for example. If mobs max hit is 6000. This code would find a random number between 3000-6000 for each client in range and damage them with it.

Code:

Code:
sub EVENT_ATTACK {
quest::settimer(getclientsRAMPAGE, 8);
}

sub EVENT_TIMER {

#####################################
##########AE RAMPAGE##################
#####################################
  if ($timer eq "getclientsRAMPAGE") {
  $cmname = $npc->GetCleanName();
  my $MaxDam = $npc->GetMaxDMG();
  my $ShieldMaxDam = ($MaxDam * .65);
  my $ShieldMinDam = $ShieldMaxDam / 2;
  my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
  
  $entity_list->MessageClose($npc, 1, 200, 13, "$cmname  goes on a RAMPAGE");
   
  my $list_check = 0;

  for ($list_check = 0; $list_check < 2000; $list_check++) {

  $client_search = $entity_list->GetClientByID($list_check);
     
    if ($client_search) {
    my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
    my $PLTarget = $npc->GetTarget();
    my $TargID = $PLTarget->GetID();
    my $ClID = $client_search->GetID();
    my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
  
        if (($distanceCHK <= 31) && ($TargID != $ClID)) {
        $client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
        $client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage" );
                            }

}
}
}
}
Enjoy.

Kayen
GM Storm Haven

Last edited by trevius; 05-04-2009 at 03:05 PM..
Reply With Quote
  #2  
Old 04-12-2009, 08:09 PM
RichardoX
Hill Giant
 
Join Date: Dec 2004
Location: in your closet....
Posts: 169
Default

Very cool stuff.
__________________
a hill giant slashes YOU for 25 points of damage!
You have been slain!
LOADING, PLEASE WAIT...
Reply With Quote
  #3  
Old 04-14-2009, 03:37 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Thanks for the step by step explaination, that rocked!

One question though:

How would you mod this code to select a single random target(s) from the zone & then cast on them?

It's there, I'm just not good enough yet to see it.
Reply With Quote
  #4  
Old 04-14-2009, 07:02 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default Choosing a random player and casting on them.

It is actual not that simple.

Here is away to use this code to choose semi-random targets. It isn't truly random b/c the list always cycles in the same order so the players at top have a better chance of getting hit, however they will really never notice. It's not perfect but its functional.

The code basically searches the clients, and then for each client does a random 1-20(This can be changed to whatever you want, I'd recommend however many players are at the event). If the number is 18 the effect essentially goes off on that player and the cycle ends, if 20 is saves the players ID, then starts a 3 sec timer, then from that timer it casts a spell on that player. If you don't roll a 29, nothing happens. Here is the commented code.


Quote:
if ($timer eq "getclients") {
my $Stop = 0; #This decides if the script is on or off

my $list_check = 0;

for ($list_check = 0; $list_check < 2000; $list_check++) {

$client_search = $entity_list->GetClientByID($list_check);

if ($client_search) {
my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
if ($distanceCHK <= 300) { #Checks all players w/in 300 range
my $ChooseClient = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10,11,12,13, 14,15,16,17,18,19,20);
if (($ChooseClient == 20) && ($Stop == 0) ) { #So 1/20 chance to get spell cast on them, the $Stop == 0, turns this off once a player is choosen
$RandomSpellID = $client_search->GetID(); #Saves the Player's ID who was choose so the spell can target them
quest::stoptimer("getclients"); #Stops the loop, otherwise it cycles again till a client is selected
#$client_search->Message(13, "You were choosen at random $RandomSpellID" ); #Sends message to client they were selected
quest::settimer("CastRandomWither", 3); #Sets timer for spell cast
my $Stop = 1;
}
if ($ChooseClient <= 17) {
#$client_search->Message(13, "You were NOT choosen at random $ChooseClient" ); #Client is not choose (You don't need even really need this)
}
}

}
}
}

if ($timer eq "CastRandomWither") {
quest::stoptimer("CastRandomWither");
$npc->CastSpell(5120, $RandomSpellID); #Cast spell 5120, on client who was choose.
}

}


Code:
sub EVENT_TIMER {


#####################################
##########Random Cast##################
#####################################
if ($timer eq "getclients") {
my $Stop = 0;

my $list_check = 0;

for ($list_check = 0; $list_check < 2000; $list_check++) {

$client_search = $entity_list->GetClientByID($list_check);

if ($client_search) {
my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
if ($distanceCHK <= 300) {
my $ChooseClient = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
if (($ChooseClient == 18) && ($Stop == 0) ) {
$RandomSpellID = $client_search->GetID(); 
quest::stoptimer("getclients");
#$client_search->Message(13, "You were choosen at random $RandomSpellID" );
quest::settimer("CastRandomWither", 3);
my $Stop = 1;
}
if ($ChooseClient <= 17) {
#$client_search->Message(13, "You were NOT choosen at random $ChooseClient" );
}
}

}
}
}

if ($timer eq "CastRandomWither") {
quest::stoptimer("CastRandomWither");
$npc->CastSpell(5120, $RandomSpellID);
}

}

Last edited by trevius; 05-01-2009 at 03:29 PM..
Reply With Quote
  #5  
Old 04-14-2009, 09:11 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Perfect, thanks for the code man & for taking the time to respond!
Reply With Quote
  #6  
Old 04-29-2009, 09:37 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Been playing with this a bit on my server.. Can't seem to get the mob to do any actual Damage with the rampage...

I'm not that great with Perl.. Can you look this thing over and fix it for us ? Would rock !! NICE work btw on this... Have always wanted to have mobs AE Ramp..

King
Reply With Quote
  #7  
Old 05-01-2009, 07:01 AM
covou
Sarnak
 
Join Date: Jan 2006
Posts: 31
Default

Just thought i would point out for those using this coode that it is missing a paranthesis (sp?)...

Code:
sub EVENT_TIMER

#####################################
##########AE RAMPAGE##################
#####################################
  if ($timer eq "getclientsRAMPAGE") {
should be

Code:
sub EVENT_TIMER {

#####################################
##########AE RAMPAGE##################
#####################################
  if ($timer eq "getclientsRAMPAGE") {
Reply With Quote
  #8  
Old 05-01-2009, 07:30 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Thanks for pointing that out. I made the correction in the original post.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #9  
Old 05-01-2009, 02:35 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default

Maybe the syntax error was the problem Mort.

Let me know if your still having trouble.

I know it works, have it in place on SH a various mobs.
Reply With Quote
  #10  
Old 05-01-2009, 07:23 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Well can see the Message that it's rampaging but no one gets any damage .. I was invul tanking but those around were taking no damage at all...
Reply With Quote
  #11  
Old 05-01-2009, 11:10 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default

Mort,

Are you using a very large mob? The larger the mob the larger you need to make the rampage distance. Post the code your using I'll take a look, unless its exactly the same.

Here is a direct copy and paste of just a trash mob I have using it. Feel free to just use that and let me know.

Code:
sub EVENT_COMBAT {

  if ($combat_state == 1) {
quest::settimer("Rampage", 8);
}

if ($combat_state == 0) {
$npc->WipeHateList();
quest::stoptimer("Rampage");
quest::stoptimer("getclients");
#$npc->SetHP($npc->GetMaxHP() * 1);
}
}

sub EVENT_TIMER {
if ($timer eq "Rampage") {
quest::stoptimer("Rampage");
my $TimeRA = quest::ChooseRandom(8);
quest::settimer("getclientsRAMPAGE", $TimeRA);
  }

####################################
##########AE RAMPAGE##################
#####################################
  if ($timer eq "getclientsRAMPAGE") {
  $cmname = $npc->GetCleanName();
  my $MaxDam = $npc->GetMaxDMG();
  my $ShieldMaxDam = ($MaxDam * .65);
  my $ShieldMinDam = $ShieldMaxDam / 2;
  my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
  
  $entity_list->MessageClose($npc, 1, 200, 13, "$cmname  goes on a RAMPAGE");
   
  my $list_check = 0;

  for ($list_check = 0; $list_check < 2000; $list_check++) {

  $client_search = $entity_list->GetClientByID($list_check);
     
    if ($client_search) {
    my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
    my $PLTarget = $npc->GetTarget();
    my $TargID = $PLTarget->GetID();
    my $ClID = $client_search->GetID();
    my $RampDamageVar = (int(rand($DamageVar ))) + $ShieldMinDam;
  
        if (($distanceCHK <= 31) && ($TargID != $ClID)) {
        $client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
        $client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage" );
                            }

}
}
}
############################################################    
############################################################    
############################################################ 
}
Reply With Quote
  #12  
Old 05-02-2009, 04:53 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Alright well it is working but when it hits the player looks like this

NPC hits you for 21018.95 points damage

I imagine thats 21,018.95 damage but it sure does look weird.. any way to lose the damage after the decimal so it's just 21,019 (maybe rounding it up or something)

King
Reply With Quote
  #13  
Old 05-03-2009, 01:20 AM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default

Yeah, good catch actually here is what you need to change

old
Code:
my $RampDamageVar = (int(rand($DamageVar ))) + $ShieldMinDam;
New
Code:
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
Using int will remove decimals.

I'll apply this to my code too, I didn't catch it when I was testing cause prob was using easily divisable numbers
Reply With Quote
  #14  
Old 05-04-2009, 07:05 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I edited those changes into the code in the first post so people using this will get the finished code without having to do any edits.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #15  
Old 05-04-2009, 09:39 AM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Thanks again !
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 12:04 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