Code: Select all
[color=yellow]3/21/2006 - grimson[/color]
Call the OnHungerChange JS event in the SetHunger() function of chars instead of calling
it in every part of the code the where the hunger gets changed.
Added a new JS event:
onCombatDamageCalc( attacker, defender, getFightSkill )
This event is called everytime combat damage is calculated. You can do your own damage
calculation and return the damage to override the engine damage calculation, or return
a negative damage value to use the engine damage calculation.
The onCombatDamageCalc event is executed on the script id assigned to the attacker char or as a global script if the char has no script assigned. So you have to add it into your global script and into every script assigned to chars to override the damage calculation everywhere.
An example of using that event that does the same as the engine does:
Code: Select all
function CalculateHitLoc( )
{
var BODYPERCENT = 0;
var ARMSPERCENT = 1;
var HEADPERCENT = 2;
var LEGSPERCENT = 3;
var NECKPERCENT = 4;
var OTHERPERCENT = 5;
var TOTALTARGETSPOTS = 6;
var LOCPERCENTAGES = new Array( 44, 14, 14, 14, 7, 7 );
var hitLoc = RandomNumber( 0, 99 ); // Determine area of Body Hit
for( var t = BODYPERCENT; t < TOTALTARGETSPOTS; ++t )
{
hitLoc -= LOCPERCENTAGES[t];
if( hitLoc < 0 )
{
hitLoc = t + 1;
break;
}
}
return hitLoc;
}
function onCombatDamageCalc( pAttacker, pDefender, fightSkill )
{
var baseDamage = pAttacker.attack;
var hitLoc = CalculateHitLoc();
if( baseDamage == -1 ) // No damage if weapon breaks
return 0;
var damage = ApplyDamageBonuses( 1, pAttacker, pDefender, fightSkill, hitLoc, baseDamage );
if( damage < 1 )
return 0;
damage = ApplyDefenseModifiers( 1, pAttacker, pDefender, fightSkill, hitLoc, damage, true);
if( damage <= 0 )
damage = RandomNumber( 0, 4 );
if( !pDefender.npc )
damage /= 2;
return damage;
}