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
  #15  
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
 


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:03 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