View Single Post
  #22  
Old 03-01-2008, 09:25 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default Hooks 8 : Tweak fizzle and resist chance

Index: spells.cpp
================================================== =================
RCS file: /cvsroot/eqemulator/EQEmuCVS/Source/zone/spells.cpp,v
retrieving revision 1.14.2.44
diff -u -b -B -r1.14.2.44 spells.cpp
--- spells.cpp 21 Feb 2007 16:04:23 -0000 1.14.2.44
+++ spells.cpp 2 Mar 2008 09:24:51 -0000
@@ -480,7 +480,8 @@
}

bool Client::CheckFizzle(int16 spell_id)
-{
+{ float fizzlechance, diff;
+
// GMs don't fizzle
if (GetGM()) return(true);

@@ -516,7 +517,12 @@
//is there any sort of focus that affects fizzling?


- // neotokyo: this is my try to get something going
+if(RuleH(Spells, FizzleChance) != NULL)
+{ fizzlechance = ((Hook_Spells_FizzleChance) RuleH(Spells, FizzleChance))(this, spells, spell_id);
+ diff = 0;
+}
+else
+{ // neotokyo: this is my try to get something going
int par_skill;
int act_skill;

@@ -556,7 +562,7 @@
// > 0 --> skill is lower, higher chance of fizzle
// < 0 --> skill is better, lower chance of fizzle
// the max that diff can be is +- 235
- float diff = par_skill + spells[spell_id].basediff - act_skill;
+ diff = par_skill + spells[spell_id].basediff - act_skill;

// if you have high int/wis you fizzle less, you fizzle more if you are stupid
if (GetCasterClass() == 'W')
@@ -566,10 +572,11 @@

// base fizzlechance is lets say 5%, we can make it lower for AA skills or whatever
float basefizzle = 10;
- float fizzlechance = basefizzle - specialize + diff / 5.0;
+ fizzlechance = basefizzle - specialize + diff / 5.0;

// always at least 5% chance to fail or succeed
fizzlechance = fizzlechance < 5 ? 5 : (fizzlechance > 95 ? 95 : fizzlechance);
+}
float fizzle_roll = MakeRandomFloat(0, 100);

mlog(SPELLS__CASTING, "Check Fizzle %s spell %d fizzlechance: %0.2f%% diff: %0.2f roll: %0.2f", GetName(), spell_id, fizzlechance, diff, fizzle_roll);
@@ -2717,7 +2724,24 @@
break;
}

- // value in spell to adjust base resist by
+if(RuleH(Spells, FinalResistChance) != NULL)
+{ struct _Hook_Spells_FinalResistChance_Parameters Parameters;
+ Parameters.AttackerIsClient = caster->IsClient();
+ Parameters.AttackerLevel = caster->GetLevel();
+ Parameters.AttackerCha = caster->GetCHA();
+ if(Parameters.AttackerIsClient)
+ Parameters.AttackerMeditation = caster->GetSkill(MEDITATE);
+ Parameters.DefenderIsClient = this->IsClient();
+ Parameters.DefenderLevel = this->GetLevel();
+ Parameters.DefenderResist = resist;
+ Parameters.spells = spells;
+ Parameters.spell_id = spell_id;
+ resistchance = ((Hook_Spells_FinalResistChance) RuleH(Spells, FinalResistChance))(&Parameters);
+ if(caster->IsClient())
+ caster->CastToClient()->CheckIncreaseSkill(MEDITATE);
+}
+else
+{ // value in spell to adjust base resist by
if(spell_id != 0)
resist += spells[spell_id].ResistDiff;

@@ -2743,7 +2767,7 @@
resistchance -= (lvldiff)*0.8;
}
}
-
+}
/*The idea is we come up with 3 ranges of numbers and a roll between 0 and 100
[[[Empty Space above the resistchance line]]] - If the roll lands up here the spell wasn't resisted, the lower the resist chance the larger this range is
[[[Space between resistchance line and full resist chance line]]] - If the roll ends up here then the spell is resisted but only partially, we take the roll in porportion to where it landed in this range to det how
Reply With Quote