View Single Post
  #3  
Old 07-14-2010, 09:32 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

OK redid this code as well as a few spells threw a wrench in the previous code, namely Cauldron Summoning, Wildmagic Blast & the annihilate line I linked earlier. In order to get all those working, required new logic so hopefully this is alittle more robust.

spdat.h
Code:
Index: spdat.h
===================================================================
--- spdat.h	(revision 1600)
+++ spdat.h	(working copy)
@@ -475,7 +475,7 @@
 #define SE_PercentXPIncrease		337	//not implemented
 #define SE_SummonAndResAllCorpses	338	//not implemented
 #define SE_TriggerOnCast			339	//not implemented
-#define SE_LifeshardChance			340	//chance to create lifeshard
+#define SE_SpellTrigger     		340	//chance to trigger spell
 //#define SE_Unknown341				341	//not used
 #define SE_ImmuneFleeing			342	//not implemented
 #define SE_InterruptCasting			343	//not implemented. % chance to interrupt spells being cast every tic. Cacophony (8272)
spell effects
Code:
Index: spell_effects.cpp
===================================================================
--- spell_effects.cpp	(revision 1600)
+++ spell_effects.cpp	(working copy)
@@ -2812,6 +2812,7 @@
 			case SE_LimitCastTime:
 			case SE_NoCombatSkills:
 			case SE_TriggerOnCast:
+			case SE_SpellTrigger:
 			{
 				break;
 			}
spells
Code:
Index: spells.cpp
===================================================================
--- spells.cpp	(revision 1600)
+++ spells.cpp	(working copy)
@@ -3045,6 +3045,8 @@
 		}
 
 	TryTriggerOnCast(spelltar, spell_id);
+	
+	TrySpellTrigger(spelltar, spell_id);
 
 	if(spell_id == 982)	// Cazic Touch, hehe =P
 	{
mob.h
Code:
Index: mob.h
===================================================================
--- mob.h	(revision 1600)
+++ mob.h	(working copy)
@@ -778,6 +778,7 @@
 	bool TryDeathSave();
 	void DoBuffWearOffEffect(uint32 index);
 	void TryTriggerOnCast(Mob *target, uint32 spell_id);
+	void TrySpellTrigger(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 1600)
+++ mob.cpp	(working copy)
@@ -3036,4 +3036,58 @@
 			}
 		}
 	}
-}
\ No newline at end of file
+}
+
+void Mob::TrySpellTrigger(Mob *target, uint32 spell_id)
+{
+	if(target == NULL || !IsValidSpell(spell_id))
+	{
+		return;
+	}
+	int spell_trig = 0;
+	// Count all the percentage chances to trigger for all effects
+	for(int i = 0; i < EFFECT_COUNT; i++)
+	{
+		if (spells[spell_id].effectid[i] == SE_SpellTrigger)
+			spell_trig += spells[spell_id].base[i];
+	}
+	// If all the % add to 100, then only one of the effects can fire but one has to fire.
+	if (spell_trig == 100)
+	{
+		int trig_chance = 100;
+		for(int i = 0; i < EFFECT_COUNT; i++)
+		{
+			if (spells[spell_id].effectid[i] == SE_SpellTrigger)
+			{
+				if(MakeRandomInt(0, trig_chance) <= spells[spell_id].base[i]) 
+				{
+					// If we trigger an effect then its over.
+					SpellOnTarget(spells[spell_id].base2[i], target);
+					break;
+				}
+				else
+				{
+					// Increase the chance to fire for the next effect, if all effects fail, the final effect will fire.
+					trig_chance -= spells[spell_id].base[i];
+				}
+			}
+		
+		}
+	}
+	// if the chances don't add to 100, then each effect gets a chance to fire, chance for no trigger as well.
+	else
+	{
+		for(int i = 0; i < EFFECT_COUNT; i++)
+		{
+			if (spells[spell_id].effectid[i] == SE_SpellTrigger)
+			{
+				if(MakeRandomInt(0, 100) <= spells[spell_id].base[i]) 
+				{
+					SpellOnTarget(spells[spell_id].base2[i], target);
+				}
+			}
+		}
+	}
+}
+
+
Reply With Quote