EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   COMMITTED: SE_Twincast (https://www.eqemulator.org/forums/showthread.php?t=31614)

Caryatis 07-07-2010 12:48 PM

COMMITTED: SE_Twincast
 
Pretty self explanatory, there are 2 versions, passive AA that gives low % to twincast any spell(auras and songs like this too) and a self only buff that grants 100% to twincast for 3 ticks.

Code...
spdat.h - line 526 - add this
Code:

#define SE_Twincast                                        399 //cast 2 spells for every 1
spell effects.cpp - line 2816 - add this
Code:

case SE_Twincast:
spell effects.cpp - line 3859 - add this
Code:

case SE_Twincast:
                {
                        if(type == focusTwincast)
                        {
                                value = 1;
                        }
                        break;
                }

spells.cpp - line 1068 - add this
Code:

TryTwincast(this, target, spell_id);
mob.h - line 90 - add this
Code:

        focusTwincast,
mob.h - line 784 - add this
Code:

void TryTwincast(Mob *caster, Mob *target, uint32 spell_id);
mob.cpp - line 3094 - add this
Code:

void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id)
{
        if(!IsValidSpell(spell_id))
        {
                return;
        }

        uint32 buff_count = GetMaxTotalSlots();
        for(int i = 0; i < buff_count; i++)
        {
                if(IsEffectInSpell(buffs[i].spellid, SE_Twincast))
                {
                        sint32 focus = CalcFocusEffect(focusTwincast, buffs[i].spellid, spell_id);
                        if(focus == 1)
                        {
                                if(MakeRandomInt(0, 100) <= spells[buffs[i].spellid].base[0])
                                {
                                        uint32 spell_mana = (spells[spell_id].mana);
                                        this->SetMana(GetMana() - spell_mana);
                                        SpellOnTarget(spell_id, target);
                                }
                        }
                }
        }
}


Caryatis 07-14-2010 08:50 PM

New code for this, uses mana more accurately and also produces a message now, like live.

spdat.h
Code:

Index: spdat.h
===================================================================
--- spdat.h        (revision 1598)
+++ spdat.h        (working copy)
@@ -523,6 +523,7 @@
 #define SE_Leap                                                383 //used to leap forward? probably something like a small knock back reverse to push you forward
 //#define SE_Unknown384                                384        //not used
 //#define SE_Unknown385                                385        //not used
+#define SE_Twincast                                        399  //cast 2 spells for every 1
 //last effect
 
 #define DF_Permanent                50

spell effects
Code:

Index: spell_effects.cpp
===================================================================
--- spell_effects.cpp        (revision 1598)
+++ spell_effects.cpp        (working copy)
@@ -2812,6 +2812,7 @@
                        case SE_LimitCastTime:
                        case SE_NoCombatSkills:
                        case SE_TriggerOnCast:
+                        case SE_Twincast:
                        {
                                break;
                        }
@@ -3860,6 +3861,14 @@
                        }
                        break;
                }
+                case SE_Twincast:
+                {
+                        if(type == focusTwincast)
+                        {
+                                value = 1;
+                        }
+                        break;
+                }
 #if EQDEBUG >= 6
                //this spits up a lot of garbage when calculating spell focuses
                //since they have all kinds of extra effects on them.

spells.cpp
Code:

Index: spells.cpp
===================================================================
--- spells.cpp        (revision 1598)
+++ spells.cpp        (working copy)
@@ -1065,6 +1065,8 @@
                }
        }
       
+        TryTwincast(this, target, spell_id);
+       
        // we're done casting, now try to apply the spell
        if( !SpellFinished(spell_id, spell_target, slot, mana_used, inventory_slot) )
        {

mob.h
Code:

Index: mob.h
===================================================================
--- mob.h        (revision 1598)
+++ mob.h        (working copy)
@@ -87,6 +87,7 @@
        focusResistRate,
        focusSpellHateMod,
        focusTriggerOnCast,
+        focusTwincast,
 } focusType;
 
 enum {
@@ -778,6 +779,7 @@
        bool TryDeathSave();
        void DoBuffWearOffEffect(uint32 index);
        void TryTriggerOnCast(Mob *target, uint32 spell_id);
+        void TryTwincast(Mob *caster, Mob *target, uint32 spell_id);
 
        static int32 GetAppearanceValue(EmuAppearance iAppearance);
        void SendAppearancePacket(int32 type, int32 value, bool WholeZone = true, bool iIgnoreSelf = false, Client *specific_target=NULL);

mob.cpp
Code:

Index: mob.cpp
===================================================================
--- mob.cpp        (revision 1598)
+++ mob.cpp        (working copy)
@@ -3036,4 +3036,35 @@
                        }
                }
        }
+}
+
+void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id)
+{
+        if(!IsValidSpell(spell_id))
+        {
+                return;
+        }
+
+        uint32 buff_count = GetMaxTotalSlots();
+        for(int i = 0; i < buff_count; i++)
+        {
+                if(IsEffectInSpell(buffs[i].spellid, SE_Twincast))
+                {
+                        sint32 focus = CalcFocusEffect(focusTwincast, buffs[i].spellid, spell_id);
+                        if(focus == 1)
+                        {
+                                if(MakeRandomInt(0, 100) <= spells[buffs[i].spellid].base[0])
+                                {
+                                        uint32 mana_cost = (spells[spell_id].mana);
+                                        if(this->IsClient())
+                                        {
+                                                mana_cost = GetActSpellCost(spell_id, mana_cost);
+                                                this->Message(MT_Spells,"You twincast %s!",spells[spell_id].name);
+                                        }
+                                        this->SetMana(GetMana() - mana_cost);
+                                        SpellOnTarget(spell_id, target);
+                                }
+                        }
+                }
+        }
 }
\ No newline at end of file


steve 07-14-2010 10:24 PM

I am in awe of you, sir. Quality work coming from you!

Keep up the awesome work!


All times are GMT -4. The time now is 08:36 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.