View Single Post
  #23  
Old 03-01-2008, 09:31 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default common/default_hooks.h

I forgot the default_hooks.h file that contains the hook function declaractions. It is required for the changes in the rulexxx files to compile :

#ifndef DEFAULT_RULES_H_
#define DEFAULT_RULES_H_


/** A hook can be a function pointer of any type. So we define it as void *.
* Hooks are cast to their actual function type when they are called.
*/
typedef void *Hook;

/** Macro used to check the compliance of hook functions with the definition of the hook.
* It ensures the hook function has the correct signature.
* It can be very useful to avoid mistakes, and when a hook signature changes.
* The compiler can then issue an error.
* If no signature check is done, a badly-defined hook function will probably crash the server.
* usage: add a line after the hook function definition (in the *.cpp file)
* CheckHookSignature(CharacterCreation, ChangeCreationInfo, default_CharacterCreation_ChangeCreationInfo);
*/

#define CheckHookSignature(cat, rule, hook) \
static Hook_##cat##_##rule CheckSignature_##hook = hook


/************************************************** ******************************************/
/* Common hooks. Only hooks implemented in both the world and zone must go in this section. */
/************************************************** ******************************************/
/**
*/
typedef double (*Hook_Random_RandomFloat)(double low, double high);



/************************************************** ***************************************/
/* World-related hooks. Only hooks (and includes) used in World must go to this section. */
/************************************************** ***************************************/
#ifdef WORLD
#include "../common/eq_packet_structs.h"

/** Called during character creation right after the CharCreate structure has been checked for correctness.
* Allows the world builder to tweak the values sent by the client prior to the actual character creation.
*/
typedef void (*Hook_CharacterCreation_ChangeCreationInfo)(CharC reate_Struct *cc);


#endif /* WORLD */



/************************************************** ***************************************/
/* Zone-related hooks. Only hooks (and includes) used in Zone must go to this section. */
/************************************************** ***************************************/
#ifdef ZONE
#include "../zone/client.h"

typedef struct _Hook_Attack_ToHitChance_Parameters
{ bool IsPvp;

bool AttackerIsClient;
int8 AttackerLevel;
sint16 AttackerDex;
uint16 AttackerWeaponSkill; /* not applicable if !AttackerIsClient */
uint16 AttackerOffense; /* not applicable if !AttackerIsClient */

bool DefenderIsClient;
int8 DefenderLevel;
sint16 DefenderAgi;
uint16 DefenderDefense; /* not applicable if !DefenderIsClient */
} *Hook_Attack_ToHitChance_Parameters;

/** Called during the function checking whether an attack actualy hits.
* Computes the percentage chance of hitting based on level, weapon skill, DEX and AGI.
* The regular rules will be used for the rest of the hit chance (mods, AAs etc).
* 'Paramters' contains all information available for the computation.
*/
typedef float (*Hook_Attack_ToHitChance)(Hook_Attack_ToHitChance _Parameters Parameters);


typedef struct _Hook_Attack_ClientDamageRange_Parameters
{ sint16 AttackerStr;
int8 AttackerLevel;
int AttackerWeaponDamage;
int AttackerWeaponDelay;

int8 DefenderLevel;

int MinHit; /* output only */
int MaxHit; /* output only */
} *Hook_Attack_ClientDamageRange_Parameters;

/**
* 'Parameters' contains all information available for the computation.
*/
typedef void (*Hook_Attack_ClientDamageRange)(Hook_Attack_Clien tDamageRange_Parameters Parameters);


typedef struct _Hook_Attack_NpcDamageRange_Parameters
{ sint16 AttackerStr;
int8 AttackerLevel;
int AttackerMaxDamage;
int AttackerDelay;

int8 DefenderLevel;

int MinHit; /* output only */
int MaxHit; /* output only */
} *Hook_Attack_NpcDamageRange_Parameters;

/**
* 'Parameters' contains all information available for the computation.
*/
typedef void (*Hook_Attack_NpcDamageRange)(Hook_Attack_NpcDamag eRange_Parameters Parameters);


typedef struct _Hook_Attack_Mitigation_Parameters
{ bool AttackerIsClient;
int8 AttackerLevel;
uint16 AttackerOffense; /* not applicable if !AttackerIsClient */

bool DefenderIsClient;
int8 DefenderLevel;
sint16 DefenderAC;
uint16 DefenderDefense; /* not applicable if !DefenderIsClient */

sint32 Damage; /* input-output */
} *Hook_Attack_Mitigation_Parameters;

/**
* 'Parameters' contains all information available for the computation.
*/
typedef void (*Hook_Attack_Mitigation)(Hook_Attack_Mitigation_P arameters Parameters);


/** Called at the end of the function where the bonuses given by an item are cumulated to the current item bonuses a character receives.
* 'inst' is the item to evaluate.
* 'newbon' is the current set of bonuses received from items by the character.
*/
typedef void (*Hook_Character_PostAddItemBonuses)(const ItemInst *inst, StatBonuses* newbon);


/**
*/
typedef sint16 (*Hook_Character_CalcAC)(uint8 Level, uint16 Defense, sint16 ItemsAC, sint16 SpellsAC);


/**
*/
typedef uint32 (*Hook_Character_EXPForLevel)(uint8 Level, int16 CharacterRace, int8 CharacterClass);


/**
*/
typedef int32 (*Hook_Character_ManaRegen)(bool IsSitting, uint8 Level, sint32 MaxMana, sint16 Int, uint16 MeditateSkill, sint32 ItemsManaRegen, sint32 SpellsManaRegen);


/**
*/
typedef sint16 (*Hook_Character_ChanceOfSkillIncrease)(SkillType skillid, int CurrentSkill, int MaxSkill, int chancemodi);


/** Called right before the fizzle roll is made, to compute the percentage of chance to fizzle.
* 'ThisClient' is the character casting the spell.
* 'spell_id' is the ID of the spell being cast.
* The check whether the caster can never fizzle due to AAs has already been done.
*/
typedef float (*Hook_Spells_FizzleChance)(Client *ThisClient, const SPDat_Spell_Struct *spells, int16 spell_id);


typedef struct _Hook_Spells_FinalResistChance_Parameters
{ bool AttackerIsClient;
int8 AttackerLevel;
sint16 AttackerCha;
uint16 AttackerMeditation; /* not applicable if !AttackerIsClient */

bool DefenderIsClient;
int8 DefenderLevel;
sint16 DefenderResist;

const SPDat_Spell_Struct *spells;
int16 spell_id;
} *Hook_Spells_FinalResistChance_Parameters;

/**
*/
typedef float (*Hook_Spells_FinalResistChance)(Hook_Spells_Final ResistChance_Parameters Parameters);


/** Called during exprience change, before the new XP values are set. Ideal place to show a custom message with the numeric XP values.
* The XP for the current client is going to be set to 'set_exp' and 'set_aaxp'.
* The client currently has 'orig_exp' XP and 'orig_aaxp'.
* 'isrezzexp' indicates whether this is XP regained after a rez.
* The hook cannot affect the XP change in any way. The XP will be changed normally after the hook returns.
*/
typedef void (*Hook_XP_PreChange)(Client *ThisClient, int32 set_exp, int32 set_aaxp, bool isrezzexp, int32 orig_exp, int32 orig_aaxp);


#endif /* ZONE */


#endif /*DEFAULT_RULES_H_*/
Reply With Quote