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