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

03-01-2008, 08:49 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
common/rulesys.h
Index: Source/common/rulesys.h
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/common/rulesys.h,v
retrieving revision 1.2.2.2
diff -u -b -B -r1.2.2.2 rulesys.h
--- Source/common/rulesys.h 31 Oct 2006 02:02:54 -0000 1.2.2.2
+++ Source/common/rulesys.h 2 Mar 2008 08:41:02 -0000
@@ -35,6 +35,8 @@
rules->GetRealRule( RuleManager::Real__##rule )
#define RuleB(cat, rule) \
rules->GetBoolRule( RuleManager::Bool__##rule )
+#define RuleH(cat, rule) \
+ rules->GetHookRule( RuleManager::Hook__##rule )
#include <vector>
@@ -42,6 +44,7 @@
#include <map>
#include "types.h"
+#include "../common/default_Hooks.h"
class Database;
@@ -70,6 +73,13 @@
} BoolType;
typedef enum {
+ #define RULE_HOOK(cat, rule, default_value) \
+ Hook__##rule,
+ #include "ruletypes.h"
+ _HookRuleCount
+ } HookType;
+
+ typedef enum {
#define RULE_CATEGORY(catname) \
Category__##catname,
#include "ruletypes.h"
@@ -79,9 +89,10 @@
static const IntType InvalidInt = _IntRuleCount;
static const RealType InvalidReal = _RealRuleCount;
static const BoolType InvalidBool = _BoolRuleCount;
+ static const HookType InvalidHook = _HookRuleCount;
static const CategoryType InvalidCategory = _CatCount;
- static const uint32 _RulesCount = _IntRuleCount+_RealRuleCount+_BoolRuleCount;
+ static const uint32 _RulesCount = _IntRuleCount+_RealRuleCount+_BoolRuleCount+_HookR uleCount;
RuleManager();
@@ -89,11 +100,13 @@
inline int GetIntRule (IntType t) const { return(m_RuleIntValues[t] ); }
inline float GetRealRule(RealType t) const { return(m_RuleRealValues[t]); }
inline bool GetBoolRule(BoolType t) const { return(m_RuleBoolValues[t]); }
+ inline Hook GetHookRule(HookType t) const { return(m_RuleHookValues[t]); }
//management routines
static const char *GetRuleName(IntType t) { return(s_RuleInfo[t].name); }
static const char *GetRuleName(RealType t) { return(s_RuleInfo[t+_IntRuleCount].name); }
static const char *GetRuleName(BoolType t) { return(s_RuleInfo[t+_IntRuleCount+_RealRuleCount].name); }
+ static const char *GetRuleName(HookType t) { return(s_RuleInfo[t+_IntRuleCount+_RealRuleCount+_BoolRuleCount].name); }
static uint32 CountRules() { return(_RulesCount); }
static CategoryType FindCategory(const char *catname);
bool ListRules(const char *catname, std::vector<const char *> &into);
@@ -117,11 +130,13 @@
int m_RuleIntValues [_IntRuleCount ];
float m_RuleRealValues[_RealRuleCount];
bool m_RuleBoolValues[_BoolRuleCount];
+ Hook m_RuleHookValues[_HookRuleCount];
typedef enum {
IntRule,
RealRule,
- BoolRule
+ BoolRule,
+ HookRule
} RuleType;
static bool _FindRule(const char *rule_name, RuleType &type_into, uint16 &index_into);
|
 |
|
 |
 |
|
 |

03-01-2008, 08:50 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
common/ruletypes.h
Index: Source/common/ruletypes.h
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/common/ruletypes.h,v
retrieving revision 1.3.2.8
diff -u -b -B -r1.3.2.8 ruletypes.h
--- Source/common/ruletypes.h 21 Feb 2007 16:04:19 -0000 1.3.2.8
+++ Source/common/ruletypes.h 2 Mar 2008 08:41:02 -0000
@@ -13,6 +13,9 @@
#ifndef RULE_BOOL
#define RULE_BOOL(cat, rule, default_value)
#endif
+#ifndef RULE_HOOK
+#define RULE_HOOK(cat, rule, default_value)
+#endif
#ifndef RULE_CATEGORY_END
#define RULE_CATEGORY_END()
#endif
@@ -20,6 +23,15 @@
+RULE_CATEGORY( Attack )
+#ifdef ZONE
+RULE_HOOK( Attack, ToHitChance, (Hook) NULL )
+RULE_HOOK( Attack, ClientDamageRange, (Hook) NULL )
+RULE_HOOK( Attack, NpcDamageRange, (Hook) NULL )
+RULE_HOOK( Attack, Mitigation, (Hook) NULL )
+#endif /* ZONE */
+RULE_CATEGORY_END()
+
RULE_CATEGORY( Character )
RULE_INT ( Character, MaxLevel, 65 )
RULE_INT ( Character, DeathExpLossLevel, 6 )
@@ -32,6 +44,13 @@
RULE_INT ( Character, ManaRegenMultiplier, 100)
RULE_INT ( Character, EnduranceRegenMultiplier, 100)
RULE_INT ( Character, ConsumptionMultiplier, 100) //item's hunger restored = this value * item's food level, 100 = normal, 50 = people eat 2x as fast, 200 = people eat 2x as slow
+#ifdef ZONE
+RULE_HOOK( Character, PostAddItemBonuses, (Hook) NULL )
+RULE_HOOK( Character, CalcAC, (Hook) NULL )
+RULE_HOOK( Character, EXPForLevel, (Hook) NULL )
+RULE_HOOK( Character, ManaRegen, (Hook) NULL )
+RULE_HOOK( Character, ChanceOfSkillIncrease, (Hook) NULL )
+#endif /* ZONE */
RULE_CATEGORY_END()
RULE_CATEGORY( Guild )
@@ -61,6 +80,10 @@
RULE_REAL (Spells, ResistChance, 2.0) //chance to resist given no resists and same level
RULE_REAL (Spells, ResistMod, 0.40) //multiplier, chance to resist = this * ResistAmount
RULE_REAL (Spells, PartialHitChance, 0.7) //The chance when a spell is resisted that it will partial hit.
+#ifdef ZONE
+RULE_HOOK( Spells, FizzleChance, (Hook) NULL )
+RULE_HOOK( Spells, FinalResistChance, (Hook) NULL )
+#endif /* ZONE */
RULE_CATEGORY_END()
RULE_CATEGORY( Combat )
@@ -71,10 +94,28 @@
RULE_REAL ( Combat, ClientBaseCritChance, 0.0 ) //The base crit chance for all clients, this will stack with warrior's/zerker's crit chance.
RULE_CATEGORY_END()
+RULE_CATEGORY( CharacterCreation )
+#ifdef WORLD
+RULE_HOOK( CharacterCreation, ChangeCreationInfo, (Hook) NULL )
+#endif /* WORLD */
+RULE_CATEGORY_END()
+
+RULE_CATEGORY( Random )
+RULE_HOOK( Random, RandomFloat, (Hook) NULL )
+RULE_CATEGORY_END()
+
+RULE_CATEGORY( XP )
+#ifdef ZONE
+RULE_HOOK( XP, PreChange, (Hook) NULL )
+#endif /* ZONE */
+RULE_CATEGORY_END()
+
+
#undef RULE_CATEGORY
#undef RULE_INT
#undef RULE_REAL
#undef RULE_BOOL
+#undef RULE_HOOK
#undef RULE_CATEGORY_END
|
 |
|
 |

03-01-2008, 08:55 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
Hook 1 : Tweak Player choices on character creation
Adds the code to the server to process this hook. No effect until the hook is actually implemented in a shared library and activated in the database.
Index: client.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/world/client.cpp,v
retrieving revision 1.12.2.20
diff -u -b -B -r1.12.2.20 client.cpp
--- client.cpp 22 Nov 2006 14:03:34 -0000 1.12.2.20
+++ client.cpp 2 Mar 2008 08:53:44 -0000
@@ -907,6 +907,9 @@
return false;
}
+ if(RuleH(CharacterCreation, ChangeCreationInfo) != NULL)
+ ((Hook_CharacterCreation_ChangeCreationInfo) RuleH(CharacterCreation, ChangeCreationInfo))(cc);
+
// Convert incoming cc_s to the new PlayerProfile_Struct
memset(&pp, 0, sizeof(PlayerProfile_Struct)); // start building the profile
|
 |
|
 |

03-01-2008, 09:00 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
Hooks 2 : custom combat computations
Tweak the to-hit chance
Tweak the AC mitigation effect
Tweak the client and NPC damage ranges
Index: attack.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/attack.cpp,v
retrieving revision 1.28.2.57
diff -u -b -B -r1.28.2.57 attack.cpp
--- attack.cpp 21 Feb 2007 16:04:20 -0000 1.28.2.57
+++ attack.cpp 2 Mar 2008 08:58:41 -0000
@@ -166,7 +166,25 @@
int8 attacker_level = attacker->GetLevel() ? attacker->GetLevel() : 1;
int8 defender_level = defender->GetLevel() ? defender->GetLevel() : 1;
- //
+if(RuleH(Attack, ToHitChance) != NULL)
+{ struct _Hook_Attack_ToHitChance_Parameters Parameters;
+ Parameters.IsPvp = pvpmode;
+ Parameters.AttackerIsClient = attacker->IsClient();
+ Parameters.AttackerLevel = attacker_level;
+ Parameters.AttackerDex = attacker->GetDEX();
+ if(Parameters.AttackerIsClient)
+ { Parameters.AttackerWeaponSkill = attacker->GetSkill(skillinuse);
+ Parameters.AttackerOffense = attacker->GetSkill(OFFENSE);
+ }
+ Parameters.DefenderIsClient = defender->IsClient();
+ Parameters.DefenderLevel = defender_level;
+ Parameters.DefenderAgi = defender->GetAGI();
+ if(Parameters.DefenderIsClient)
+ Parameters.DefenderDefense = defender->GetSkill(DEFENSE);
+ chancetohit = ((Hook_Attack_ToHitChance) RuleH(Attack, ToHitChance))(&Parameters);
+}
+else
+{ //
// we start by giving them a base chance to hit
//
chancetohit = 50;
@@ -232,6 +250,7 @@
chancetohit += (float) ((float)attacker_dex * 0.15f);
mlog(COMBAT__TOHIT, "Applied Defending AGI (%d) and Attacking (DEX-50=%d) yeilding %.2f", defender_agi, attacker_dex, chancetohit);
+}
//divided these bonuses by 4... higher level battles were basically always 95%
//hit chance because of this 50% bonus...
@@ -319,7 +338,8 @@
//if chance to hit is crazy high, that means a discipline is in use, and let it stay there
} else if(chancetohit > 95) {
chancetohit = 95;
- } else if(chancetohit < 30) {
+ }
+ if(RuleH(Attack, ToHitChance) == NULL && chancetohit < 30) {
chancetohit = 30;
}
@@ -514,7 +534,24 @@
// Scorpious2k: Include AC in the calculation
// use serverop variables to set values
- int myac = GetAC();
+if(RuleH(Attack, Mitigation) != NULL)
+{ struct _Hook_Attack_Mitigation_Parameters Parameters;
+ Parameters.AttackerIsClient = other->IsClient();
+ Parameters.AttackerLevel = other->GetLevel();
+ if(Parameters.AttackerIsClient)
+ Parameters.AttackerOffense = GetSkill(OFFENSE);
+
+ Parameters.DefenderIsClient = other->IsClient();
+ Parameters.DefenderLevel = GetLevel();
+ Parameters.DefenderAC = GetAC();
+ if(Parameters.DefenderIsClient)
+ Parameters.DefenderDefense = GetSkill(DEFENSE);
+ Parameters.Damage = damage;
+ ((Hook_Attack_Mitigation) RuleH(Attack, Mitigation))(&Parameters);
+ damage = Parameters.Damage;
+}
+else
+{ int myac = GetAC();
if (damage > 0 && myac > 0) {
int acfail=1000;
char tmp[10];
@@ -551,6 +588,7 @@
mlog(COMBAT__DAMAGE, "AC Damage Reduction: fail chance %d%%. Did not fail.", acfail);
}
}
+}
int aaMit = 0;
switch(GetAA(aaCombatStability)){
@@ -780,7 +818,20 @@
mlog(COMBAT__ATTACKS, "Failed a finishing blow: AA at %d, other level %d, roll %.1f", aa_item, other->GetLevel(), tempchancerand);
}
- min_hit = 1;
+if(RuleH(Attack, ClientDamageRange) != NULL)
+{ struct _Hook_Attack_ClientDamageRange_Parameters Parameters;
+ Parameters.AttackerStr = this->GetSTR();
+ Parameters.AttackerLevel = this->GetLevel();
+ Parameters.AttackerWeaponDamage = weapon_damage;
+ Parameters.AttackerWeaponDelay = (weapon_item == NULL ? 20 : weapon_item->Delay);
+
+ Parameters.DefenderLevel = other->GetLevel();
+ ((Hook_Attack_ClientDamageRange) RuleH(Attack, ClientDamageRange))(&Parameters);
+ min_hit = Parameters.MinHit;
+ max_hit = Parameters.MaxHit;
+}
+else
+{ min_hit = 1;
//This needs to be researched, it seems terribly off. Changed to use offense skill for now instead of weapon since we know that is correct
max_hit = (weapon_damage * (((GetSTR()*20) + (GetSkill(OFFENSE)*15) + (mylevel*10)) / 1000)); // Apply damage formula
@@ -790,6 +841,7 @@
min_hit += damage_bonus;
max_hit += damage_bonus;
}
+}
min_hit = min_hit * (100 + itembonuses.MinDamageModifier + spellbonuses.MinDamageModifier) / 100;
@@ -1295,7 +1347,19 @@
otherlevel = otherlevel ? otherlevel : 1;
mylevel = mylevel ? mylevel : 1;
- //instead of calcing damage in floats lets just go straight to ints
+if(RuleH(Attack, ClientDamageRange) != NULL)
+{ struct _Hook_Attack_NpcDamageRange_Parameters Parameters;
+ Parameters.AttackerStr = this->GetSTR();
+ Parameters.AttackerLevel = this->GetLevel();
+ Parameters.AttackerMaxDamage = max_dmg;
+ Parameters.AttackerDelay = (int) (36.0 * (100.0f + attack_speed) / 100.0);
+
+ Parameters.DefenderLevel = other->GetLevel();
+ ((Hook_Attack_NpcDamageRange) RuleH(Attack, NpcDamageRange))(&Parameters);
+ damage = MakeRandomInt(Parameters.MinHit, Parameters.MaxHit);
+}
+else
+{ //instead of calcing damage in floats lets just go straight to ints
damage = MakeRandomInt(min_dmg, max_dmg);
//check if we're hitting above our max or below it.
@@ -1307,6 +1371,7 @@
mlog(COMBAT__DAMAGE, "Damage (%d) is above max (%d). Setting to max.", damage, max_dmg);
damage = max_dmg;
}
+}
//THIS IS WHERE WE CHECK TO SEE IF WE HIT:
if(other->IsClient() && other->CastToClient()->IsSitting()) {
|
 |
|
 |

03-01-2008, 09:01 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
One word about the previous hooks (and some coming others) : I did not indent the hook code as should normally be. the reason is that it avoids getting changes in diffs on all the regular code I enclosed in "ifs".
|

03-01-2008, 09:03 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
Hook 3 : More item bonuses computation
Index: bonuses.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/bonuses.cpp,v
retrieving revision 1.7.2.15
diff -u -b -B -r1.7.2.15 bonuses.cpp
--- bonuses.cpp 21 Feb 2007 16:04:20 -0000 1.7.2.15
+++ bonuses.cpp 2 Mar 2008 09:06:47 -0000
@@ -25,6 +25,7 @@
#include "../common/skills.h"
#include "../common/bodytypes.h"
#include "../common/classes.h"
+#include "../common/rulesys.h"
#include <math.h>
#include <assert.h>
#ifndef WIN32
@@ -277,6 +278,9 @@
for(i = 0; i < MAX_AUGMENT_SLOTS; i++) {
AddItemBonuses(inst->GetAugment(i),newbon);
}
+
+ if(RuleH(Character, PostAddItemBonuses) != NULL)
+ ((Hook_Character_PostAddItemBonuses) RuleH(Character, PostAddItemBonuses))(inst, newbon);
}
void Client::CalcEdibleBonuses(StatBonuses* newbon) {
Last edited by Bulle; 03-02-2008 at 05:07 AM..
Reason: Replacing mistake post
|

03-01-2008, 09:08 PM
|
Hill Giant
|
|
Join Date: Jan 2008
Posts: 102
|
|
Hook 4 : Tweak skill-up chance
Index: client.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/client.cpp,v
retrieving revision 1.36.2.51
diff -u -b -B -r1.36.2.51 client.cpp
--- client.cpp 21 Feb 2007 16:04:20 -0000 1.36.2.51
+++ client.cpp 2 Mar 2008 09:08:20 -0000
@@ -1654,9 +1654,15 @@
if (skillval < maxskill)
{
// the higher your current skill level, the harder it is
- sint16 Chance = 10 + chancemodi + ((252 - skillval) / 20);
+ sint16 Chance;
+if(RuleH(Character, ChanceOfSkillIncrease) != NULL)
+ Chance = ((Hook_Character_ChanceOfSkillIncrease) RuleH(Character, ChanceOfSkillIncrease))(skillid, skillval, maxskill, chancemodi);
+else
+{
+ Chance = 10 + chancemodi + ((252 - skillval) / 20);
if (Chance < 1)
Chance = 1; // Make it always possible
+}
if(MakeRandomFloat(0, 99) < Chance)
{
SetSkill(skillid, GetRawSkill(skillid) + 1);
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 04:00 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |