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)

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2008, 09:00 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default 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()) {
Reply With Quote
  #2  
Old 03-01-2008, 09:01 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default

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".
Reply With Quote
  #3  
Old 03-01-2008, 09:03 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default 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
Reply With Quote
  #4  
Old 03-01-2008, 09:08 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default 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);
Reply With Quote
  #5  
Old 03-01-2008, 09:12 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Hook 5 : Tweak AC calculation

Index: client_mods.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/client_mods.cpp,v
retrieving revision 1.6.4.19
diff -u -b -B -r1.6.4.19 client_mods.cpp
--- client_mods.cpp 21 Feb 2007 16:04:20 -0000 1.6.4.19
+++ client_mods.cpp 2 Mar 2008 09:11:32 -0000
@@ -28,6 +28,7 @@
#include "../common/moremath.h"
#include "../common/guilds.h"
#include "../common/logsys.h"
+#include "../common/rulesys.h"
#include "StringIDs.h"
#include "NpcAI.h"

@@ -714,7 +715,10 @@
// AC from spells are not included (cant even cast spells yet..)
sint16 Client::CalcAC() {

- // new formula
+if(RuleH(Character, CalcAC) != NULL)
+ AC = ((Hook_Character_CalcAC) RuleH(Character, CalcAC))(GetLevel(), GetSkill(DEFENSE), itembonuses.AC, spellbonuses.AC);
+else
+{ // new formula
int avoidance = 0;
avoidance = (acmod() + ((GetSkill(DEFENSE)*16)/9));
if (avoidance < 0)
@@ -749,8 +753,8 @@

//spell AC bonuses are added directly to natural total
displayed += spellbonuses.AC;
-
AC = displayed;
+}
return(AC);
}
Reply With Quote
  #6  
Old 03-01-2008, 09:15 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Hook 6 : Tweak Mana pool computation

Index: client_process.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/client_process.cpp,v
retrieving revision 1.50.2.23
diff -u -b -B -r1.50.2.23 client_process.cpp
--- client_process.cpp 21 Feb 2007 16:04:21 -0000 1.50.2.23
+++ client_process.cpp 2 Mar 2008 09:13:34 -0000
@@ -1466,7 +1466,13 @@
return;
int32 level=GetLevel();
int32 regen = 0;
- if (IsSitting()) { //this should be changed so we dont med while camping, etc...
+
+if(RuleH(Character, ManaRegen) != NULL)
+{ regen = ((Hook_Character_ManaRegen) RuleH(Character, ManaRegen))(IsSitting(), GetLevel(), GetMaxMana(), GetINT(), GetSkill(MEDITATE), itembonuses.ManaRegen, spellbonuses.ManaRegen);
+ medding = IsSitting() && HasSkill(MEDITATE);
+}
+else
+{ if (IsSitting()) { //this should be changed so we dont med while camping, etc...
if(HasSkill(MEDITATE)) {
medding = true;
regen = (((GetSkill(MEDITATE)/10)+(level-(level/4)))/4)+4;
@@ -1480,12 +1486,13 @@
medding = false;
regen = 2+spellbonuses.ManaRegen+itembonuses.ManaRegen+(le vel/5);
}
+}
regen += GetAA(aaMentalClarity);
regen += GetAA(aaBodyAndMindRejuvenation);
regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;

SetMana(GetMana() + regen);
Reply With Quote
  #7  
Old 03-01-2008, 09:18 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Hook 7 : Pre-XP change hook and Tweak XP per level value

Index: exp.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/exp.cpp,v
retrieving revision 1.2.2.14
diff -u -b -B -r1.2.2.14 exp.cpp
--- exp.cpp 16 Jan 2007 04:04:53 -0000 1.2.2.14
+++ exp.cpp 2 Mar 2008 09:17:01 -0000
@@ -34,7 +34,6 @@
void Client::AddEXP(int32 add_exp, int8 conlevel, bool resexp) {
if (m_epp.perAA<0 || m_epp.perAA>100)
m_epp.perAA=0; // stop exploit with sanity check
-
int32 add_aaxp;
if(resexp) {
add_aaxp = 0;
@@ -117,6 +116,8 @@
return; // Must be invalid class/race
}

+ if(RuleH(XP, PreChange) != NULL)
+ ((Hook_XP_PreChange) RuleH(XP, PreChange))(this, set_exp, set_aaxp, isrezzexp, m_pp.exp, m_pp.expAA);

if ((set_exp + set_aaxp) > (m_pp.exp+m_pp.expAA)) {
if (isrezzexp)
@@ -312,7 +320,10 @@
uint32 Client::GetEXPForLevel(int16 check_level)
{

- int16 check_levelm1 = check_level-1;
+if(RuleH(Character, EXPForLevel) != NULL)
+ return ((Hook_Character_EXPForLevel) RuleH(Character, EXPForLevel))(check_level, GetBaseRace(), GetClass());
+else
+{ int16 check_levelm1 = check_level-1;
float mod;
if (check_level < 31)
mod = 1.0;
@@ -368,6 +379,7 @@

return(uint32(base * mod));
}
+}

void Group::SplitExp(uint32 exp, Mob* other) {
if( other->CastToNPC()->MerchantType != 0 ) // Ensure NPC isn't a merchant
Reply With Quote
Reply

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 04:47 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