Displaying Damage above Mobs on POL 095/096

Open discussion forum. For topics that do not fit anywhere else.
Post Reply
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Displaying Damage above Mobs on POL 095/096

Post by MuadDib »

Displaying Damage Dealt Above Mobs In AOS Clients
Pre-ML Style in 095!
After a 4 page post on the old forums, I decided to make this quick and simple guide. This is based of 095 Distro, so be sure to change where you put this as needed (if you are not using distro, you should know where it goes then).

Remember, this is based off the older AOS method for displaying damage, and the 095 core's way of handling this. Hope to post a 096 version, with the new style method for displaying damages soon!

In the file /pkg/systems/combat/hitScriptInc.inc add these 2 functions:

Code: Select all

// ***************************************************


function DisplayDamage(attacker, damaged, dmg)


  if(dmg <= 255)
    var pkt := "BF000B002201SSSSSSSSDD";
    pkt["SSSSSSSS"] := fixPacketLength( (Hex(damaged.serial)-"0x"), 4) ;
    pkt["DD"] := fixPacketLength( (Hex(dmg)-"0x"), 1);
  if(attacker.acct)
    SendPacket(attacker, pkt);
  endif
  if(damaged.acct)
    SendPacket(damaged, pkt);
  endif


endfunction


///////////////////////////////////////////////////////////////
//Pads a string with a "0" prefix, until it is of proper length
//  packetString   value to pad.
//  byteLength     number of bytes. Byte counted as two chars.
///////////////////////////////////////////////////////////////
function fixPacketLength( packetString, byteLength )
    if( !packetString || packetString == error )
        packetString := 0;
    endif
    packetString := cStr(packetString);


    if( packetString[1,2] == "0x" )
        packetString := cStr(packetString[3,len(packetString)]);
    endif


    if( len(packetString) > byteLength * 2 )
//      var extraBytes := (byteLength*2) - len(packetString);
      var extraBytes := len(packetString) - (byteLength*2) + 1;
      return cStr(packetString[extraBytes,len(packetString)]);
    endif


    while( len(packetString) < byteLength * 2 )
        packetString := "0" + packetString;
    endwhile


    return packetString;
endfunction


// ***************************************************
Now, in the function DealDamage, after the line that Sends the ApplyRawDamage, add the following:

Code: Select all

// ***************************************************

set_critical(1); 
DisplayDamage(attacker, defender, rawdamage); 

// ***************************************************
If you do this, you might want to edit DealDamage()'s function. For Example, this would be the recommended change:

Code: Select all

// ***************************************************
//Original 
function DealDamage(defender, attacker, rawdamage, weapon) 

// New 
function DealDamage(defender, attacker, rawdamage, weapon:=0) 
if(weapon) 
rawdamage := rawdamage + RandomInt( (GetEffectiveSkill(attacker, 1) ) / 20); 
endif 

// ***************************************************
Now, the catch is you will want to call the DisplayDamage whereever damage is dealt in other systems too. For instance, like the Spells, or in other scripts that would send damage to the players.

Remember, you send it to both the attacker and the defender. DisplayDamage will see if there is a need to send it (aka, if it's a mob or item then no need).

The easiest way to achieve this being sent always, is to search your scripts to find the damage commands and update them with hitScriptInc.inc and use DealDamage instead. Below is a list of all the core's damage giving commands to replace.

ApplyDamage
ApplyRawDamage

I think those are all anyway. Could be wrong

Then, in the scripts that are NOT in the combat package, just send the defender, attacker, and the rawdamage. By not giving a fake weapon to send, it will know it was not the combat pkg calling it, and will NOT add the anatomy mod to it.
Last edited by MuadDib on Sat Jul 01, 2006 5:43 pm, edited 1 time in total.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

Displaying Damage Dealt Above Mobs In AOS Clients
ML+ Style in 096!
After a 4 page post on the old forums, I decided to make this quick and simple guide. This is based of 095 Distro, so be sure to change where you put this as needed (if you are not using distro, you should know where it goes then).

Remember, this is based off the newer ML method for displaying damage, and the 096 core's way of handling this.

In the file /pkg/systems/combat/hitScriptInc.inc add these 2 functions:

Code: Select all

// ***************************************************

function DisplayDamage(attacker, damaged, dmg)

  var dmg_packet := CreatePacket(0x0B, 0x07);
  if(dmg <= 255)
    dmg_packet.SetInt8(0x06, dmg);
  else
    dmg_packet.SetInt16(0x05, dmg);
  endif

  dmg_packet.SetInt32(0x01, damaged.serial);

  if(attacker.acct)
    dmg_packet.SendPacket(attacker);
  endif
  if(damaged.acct)
    dmg_packet.SendPacket(damaged);
  endif

endfunction

// ***************************************************
Now, in the function DealDamage, after the line that Sends the ApplyRawDamage, add the following:

Code: Select all

// ***************************************************

set_critical(1); 
DisplayDamage(attacker, defender, rawdamage); 

// ***************************************************
If you do this, you might want to edit DealDamage()'s function. For Example, this would be the recommended change:

Code: Select all

// ***************************************************
//Original 
function DealDamage(defender, attacker, rawdamage, weapon) 

// New 
function DealDamage(defender, attacker, rawdamage, weapon:=0) 
if(weapon) 
rawdamage := rawdamage + RandomInt( (GetEffectiveSkill(attacker, 1) ) / 20); 
endif 

// ***************************************************
Now, the catch is you will want to call the DisplayDamage whereever damage is dealt in other systems too. For instance, like the Spells, or in other scripts that would send damage to the players.

Remember, you send it to both the attacker and the defender. DisplayDamage will see if there is a need to send it (aka, if it's a mob or item then no need).

The easiest way to achieve this being sent always, is to search your scripts to find the damage commands and update them with hitScriptInc.inc and use DealDamage instead. Below is a list of all the core's damage giving commands to replace.

ApplyDamage
ApplyRawDamage

I think those are all anyway. Could be wrong

Then, in the scripts that are NOT in the combat package, just send the defender, attacker, and the rawdamage. By not giving a fake weapon to send, it will know it was not the combat pkg calling it, and will NOT add the anatomy mod to it.
Post Reply