Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #26  
Old 03-01-2008, 09:44 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Zone Hooks

There are many more zone hooks. They are implemented in hero_zone_Hooks.cpp, which generates the hero_world.dll shared library.
I removed a couple hooks of mine as they rely on other non-hook related changes on my server.

Those custom hooks are of course only there as examples. You do not want them on your own server

#include "../common/debug.h"
#include "../common/default_Hooks.h"
#include "../common/MiscFunctions.h"
#include <math.h>

#ifdef WIN32
#define exportfunc extern "C" __declspec(dllexport)
#else
#define exportfunc extern "C"
#endif

#define SkillRegulationMod (+20)
#define StatRegulationMod (-50)

#define ZeroIfNegative(x) ((x) < 0 ? 0 : (x))


/** The to-hit chance is computed as :
* 100 - 100 * (DEF AGI + StatRegulationMod) / ( (DEF AGI + StatRegulationMod) + (ATK DEX + StatRegulationMod) + (ATK Skill + SkillRegulationMod) )
* If one of the opponent is not a client then its skill is equal to (Level + 1) * 5.
*/
exportfunc float hero_zone_Attack_ToHitChance(Hook_Attack_ToHitChan ce_Parameters Parameters)
{ float Result;
uint16 AttackerWeaponSkill;
//printf("Bulle-ToHit-Hook-01 : PVP=%d / ATK CLT=%d / ATK LVL=%d / ATK DEX=%d / ATK WEA=%d / ATK OFF=%d\n", Parameters->IsPvp, Parameters->AttackerIsClient, Parameters->AttackerLevel, Parameters->AttackerDex, Parameters->AttackerIsClient?Parameters->AttackerWeaponSkill : -1, Parameters->AttackerIsClient?Parameters->AttackerOffense : -1);
//printf("Bulle-ToHit-Hook-02 : PVP=%d / DEF CLT=%d / DEF LVL=%d / DEF AGI=%d / DEF OFF=%d\n", Parameters->IsPvp, Parameters->DefenderIsClient, Parameters->DefenderLevel, Parameters->DefenderAgi, Parameters->AttackerIsClient?Parameters->DefenderDefense : -1);

if(Parameters->AttackerIsClient)
AttackerWeaponSkill = Parameters->AttackerWeaponSkill;
else
AttackerWeaponSkill = (Parameters->AttackerLevel + 1) * 5;

Result = 100.0 - 100.0 * ZeroIfNegative(Parameters->DefenderAgi + StatRegulationMod) /
( ZeroIfNegative(Parameters->DefenderAgi + StatRegulationMod)
+ ZeroIfNegative(Parameters->AttackerDex + StatRegulationMod)
+ ZeroIfNegative(AttackerWeaponSkill + SkillRegulationMod) / 2
+ 1 /* avoids division by zero */
);
printf("Bulle-ToHit-Hook-03 : to hit=%f\n", Result);
return Result;
}
CheckHookSignature(Attack, ToHitChance, hero_zone_Attack_ToHitChance);


/** The damage range is computed as :
* MinHit = (ATK STR + StatRegulationMod) * ATK WEAP DLY / 100
* MaxHit = MinHit + 3 * ATK WEAP DMG
*/
exportfunc void hero_zone_Attack_ClientDamageRange(Hook_Attack_Cli entDamageRange_Parameters Parameters)
{
//printf("Bulle-ClientDamageRange-Hook-01 : ATK STR=%d / ATK LVL=%d / ATK DLY=%d / ATK DMG=%d / DEF LVL=%d\n", Parameters->AttackerStr, Parameters->AttackerLevel, Parameters->AttackerWeaponDelay, Parameters->AttackerWeaponDamage, Parameters->DefenderLevel);

Parameters->MinHit = (int) (ZeroIfNegative(Parameters->AttackerStr + StatRegulationMod) * Parameters->AttackerWeaponDelay / 100.0);
Parameters->MaxHit = Parameters->MinHit + 3 * Parameters->AttackerWeaponDamage;
printf("Bulle-ClientDamageRange-Hook-02 : min_hit=%d max_hit=%d\n", Parameters->MinHit, Parameters->MaxHit);
}
CheckHookSignature(Attack, ClientDamageRange, hero_zone_Attack_ClientDamageRange);


/** The damage range is computed as :
* MinHit = (ATK STR + StatRegulationMod) * ATK DLY / 100
* MaxHit = MinHit + 2 * ATK MAXDMG
*/
exportfunc void hero_zone_Attack_NpcDamageRange(Hook_Attack_NpcDam ageRange_Parameters Parameters)
{
//printf("Bulle-NpcDamageRange-Hook-01 : ATK STR=%d / ATK LVL=%d / ATK DLY=%d / ATK MAXDMG=%d / DEF LVL=%d\n", Parameters->AttackerStr, Parameters->AttackerLevel, Parameters->AttackerDelay, Parameters->AttackerMaxDamage, Parameters->DefenderLevel);

Parameters->MinHit = (int) (ZeroIfNegative(Parameters->AttackerStr + StatRegulationMod) * Parameters->AttackerDelay / 100.0);
Parameters->MaxHit = Parameters->MinHit + 2 * Parameters->AttackerMaxDamage;
printf("Bulle-NpcDamageRange-Hook-02 : min_hit=%d max_hit=%d\n", Parameters->MinHit, Parameters->MaxHit);
}
CheckHookSignature(Attack, NpcDamageRange, hero_zone_Attack_NpcDamageRange);


exportfunc void hero_zone_Attack_Mitigation(Hook_Attack_Mitigation _Parameters Parameters)
{ sint32 InitialDamage = Parameters->Damage;
float Mitigation;
uint16 AttackerOffense, DefenderDefense;
double AdjustedDefenderAC;
//printf("Bulle-Mitigation-Hook-01 : ATK CLT=%d / ATK LVL=%d / ATK OFF=%d / DEF CLT=%d / DEF LVL=%d / DEF AC=%d / DEF DEF=%d\n", Parameters->AttackerIsClient, Parameters->AttackerLevel, Parameters->AttackerIsClient ? Parameters->AttackerOffense : -1, Parameters->DefenderIsClient, Parameters->DefenderLevel, Parameters->DefenderAC, Parameters->DefenderIsClient ? Parameters->DefenderDefense : -1);

if(Parameters->AttackerIsClient)
AttackerOffense = Parameters->AttackerOffense;
else
AttackerOffense = (Parameters->AttackerLevel + 1) * 5;

if(Parameters->DefenderIsClient)
{ DefenderDefense = Parameters->DefenderDefense;
AdjustedDefenderAC = Parameters->DefenderAC;
}
else
{ DefenderDefense = (Parameters->DefenderLevel + 1 )* 5;
AdjustedDefenderAC = pow(Parameters->DefenderAC * 1.0, 0.9);
}

Mitigation = (AdjustedDefenderAC + ZeroIfNegative(DefenderDefense + SkillRegulationMod) * 1.25) /
(AdjustedDefenderAC + ZeroIfNegative(DefenderDefense + SkillRegulationMod) * 1.25 + ZeroIfNegative(AttackerOffense + SkillRegulationMod) * 5);
Parameters->Damage = (int) ((1.0 - Mitigation) * InitialDamage);
printf("Bulle-Mitigation-Hook-02 : dmgbfr=%d mitig=%f dmgaft=%d\n", InitialDamage, Mitigation, Parameters->Damage);
}
CheckHookSignature(Attack, Mitigation, hero_zone_Attack_Mitigation);


exportfunc sint16 hero_zone_Character_CalcAC(uint8 Level, uint16 Defense, sint16 ItemsAC, sint16 SpellsAC)
{ sint16 Result = ItemsAC + SpellsAC;
return Result;
}
CheckHookSignature(Character, CalcAC, hero_zone_Character_CalcAC);


exportfunc uint32 hero_zone_Character_EXPForLevel(uint8 Level, int16 CharacterRace, int8 CharacterClass)
{ uint32 Result = 100.0 * pow(1.2, Level + 10);
printf("Bulle-EXPForLevel-Hook-01 : level=%d XP=%d\n", Level, Result);
return Result;
}
CheckHookSignature(Character, EXPForLevel, hero_zone_Character_EXPForLevel);


exportfunc int32 hero_zone_Character_ManaRegen(bool IsSitting, uint8 Level, sint32 MaxMana, sint16 Int, uint16 MeditateSkill, sint32 ItemsManaRegen, sint32 SpellsManaRegen)
{ sint16 Result;

Result = MaxMana * Int / 4000;
if(!IsSitting)
Result = Result / 10;
Result += 2 + ItemsManaRegen + SpellsManaRegen;
//printf("Bulle-ManaRegen-Hook-01 : regen=%d\n", Result);
return Result;
}
CheckHookSignature(Character, ManaRegen, hero_zone_Character_ManaRegen);


/** Base chance is a linear function such that base chance is 25% when skill is 0, and 0% when skill is 250.
* The final chance is the base chance plus the chance modifier, or 5%, whichever is greater.
*/
exportfunc sint16 hero_zone_Character_ChanceOfSkillIncrease(SkillTyp e skillid, int CurrentSkill, int MaxSkill, int chancemodi)
{ sint16 Result;

Result = (25 * (250 - CurrentSkill) + 1250) / 300 + chancemodi;
if(Result < 5)
Result = 5;

printf("Bulle-ChanceOfSkillIncrease-Hook-01 : skill=%d chance=%d\n", CurrentSkill, Result);
return Result;
}
CheckHookSignature(Character, ChanceOfSkillIncrease, hero_zone_Character_ChanceOfSkillIncrease);


exportfunc float hero_zone_Spells_FinalResistChance(Hook_Spells_Fin alResistChance_Parameters Parameters)
{ float Result;
uint16 AttackerMeditation;

if(Parameters->AttackerIsClient)
AttackerMeditation = Parameters->AttackerMeditation;
else
AttackerMeditation = (Parameters->AttackerLevel + 1) * 5;

Result = 100.0 * Parameters->DefenderResist /
(1 + ZeroIfNegative(1.0 * Parameters->DefenderResist + (Parameters->AttackerCha + StatRegulationMod)
+ (AttackerMeditation + SkillRegulationMod) - Parameters->spells[Parameters->spell_id].ResistDiff));

printf("Bulle-Resist-Hook-01 : resist=%f\n", Result);
return Result;
}
CheckHookSignature(Spells, FinalResistChance, hero_zone_Spells_FinalResistChance);


/** Displays numeric XP value gains (or loss).
*/
exportfunc void hero_zone_XP_PreChange(Client *ThisClient, int32 set_exp, int32 set_aaxp, bool isrezzexp, int32 orig_exp, int32 orig_aaxp)
{ if(set_exp - orig_exp > 0)
ThisClient->Message(15, "You have gained %d XP.", set_exp - orig_exp);
else if(set_exp - orig_exp < 0)
ThisClient->Message(15, "You have lost %d XP.", set_exp - orig_exp);

if(set_aaxp - orig_aaxp > 0)
ThisClient->Message(15, "You have gained %d AA XP.", set_aaxp - orig_aaxp);
else if(set_aaxp - orig_aaxp < 0)
ThisClient->Message(15, "You have lost %d AA XP.", set_aaxp - orig_aaxp);
//printf("Bulle-XPPreChange-Hook-01 : XP:%d->%d AA:%d->%d\n", orig_exp, set_exp, orig_aaxp, set_aaxp);
}
CheckHookSignature(XP, PreChange, hero_zone_XP_PreChange);
Reply With Quote
 

Thread Tools
Display Modes

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 06:33 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3