View Single Post
  #22  
Old 11-15-2014, 10:46 PM
rencro
Hill Giant
 
Join Date: Sep 2008
Location: So. California
Posts: 219
Default

Here is what i have so far, I built this on my fork, and tested, but a diff from my fork would be useless so I imported into the latest source after doing a diff between my source and the latest (not too many changes, and nothing I think that would cause any issues) Note, I did not build or test this on the current live source even though it is diffed against it.

I cannot stress enough to create a branch of your source, patch this in, and build on a TEST ENVIRONMENT, not your production server, also that test environment should be using a COPY of your production database, not the actual production db itself (sorry if I seem overly anal, but I assisted a server op before with the same provisos, and to thoroughly test my changes, and he told me he would, but he went live with it 5 minutes later and there were countless bugs as a result affecting the live players :facepalm

Rant over

diff current source
Code:
diff --git a/common/spdat.cpp b/common/spdat.cpp
index 1ff8f26..8579f61 100644
--- a/common/spdat.cpp
+++ b/common/spdat.cpp
@@ -1146,3 +1146,39 @@ const char* GetSpellName(int16 spell_id)
     return spells[spell_id].name;
 }
 
+// rencro timeofday buff, both day and night buffs are listed here
+bool IsTimeOfDayBuff(int16 spell_id)
+{
+	switch(spell_id)
+	{
+	case 346:
+	case 992:
+//	case 11: //rencro temp testing 
+//	case ###:
+		return true;
+	}
+	return false;
+}
+//rencro daytime buffs only
+bool IsDayTimeBuff(int16 spell_id)
+{
+	switch(spell_id)
+	{
+	case 992: 
+//	case 11: //rencro testing purposes only 
+//	case ###:
+		return true;
+	}
+	return false;
+}
+//rencro nightime buffs only
+bool IsNightTimeBuff(int16 spell_id)
+{
+	switch(spell_id)
+	{
+	case 346:
+//	case ###:
+		return true;
+	}
+	return false;
+}
\ No newline at end of file
diff --git a/common/spdat.h b/common/spdat.h
index ed8a86e..7cd1e00 100644
--- a/common/spdat.h
+++ b/common/spdat.h
@@ -874,5 +874,8 @@ int32 GetFuriousBash(uint16 spell_id);
 bool IsShortDurationBuff(uint16 spell_id);
 bool IsSpellUsableThisZoneType(uint16 spell_id, uint8 zone_type);
 const char *GetSpellName(int16 spell_id);
+bool IsTimeOfDayBuff(int16 spell_id); //rencro
+bool IsDayTimeBuff(int16 spell_id); //rencro
+bool IsNightTimeBuff(int16 spell_id); //rencro
 
 #endif
diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp
index 447d34e..c63d109 100644
--- a/zone/spell_effects.cpp
+++ b/zone/spell_effects.cpp
@@ -3360,8 +3360,45 @@ void Mob::BuffProcess()
 			// If the Mob died during DoBuffTic, then the buff we are currently processing will have been removed
 			if(buffs[buffs_i].spellid == SPELL_UNKNOWN)
 				continue;
+			//rencro Time of Day Buffing
+			if(IsClient() && IsTimeOfDayBuff(buffs[buffs_i].spellid))
+			{
+				TimeOfDay_Struct eqTime;
+				zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
+
+				if(eqTime.hour > 6 && eqTime.hour < 20) // eqTime.hour -1 is proper formula, we are checking greater than 5am less than 7pm
+				{
+					//Message(13, "We are in daylight"); //troubleshooting message
+					if(IsNightTimeBuff(buffs[buffs_i].spellid))
+					{
+						Message(12, "The sun's rays beam down.");
+						BuffFadeBySlot(buffs_i);
+						CastSpell(992, GetID(), 1,0,0); //cast spell the day spell with no mana cost and no cast time
+					}
+					//leaving this if daytime check for when weather checks get added in
+					if(IsDayTimeBuff(buffs[buffs_i].spellid))
+					{
+//						Message(11, "I have a daytime buff on"); //troubleshooting message
+					}
 
-			if(spells[buffs[buffs_i].spellid].buffdurationformula != DF_Permanent)
+				} else 
+				{
+//					Message(13, "We are in the dark"); //troubleshooting message
+					if(IsDayTimeBuff(buffs[buffs_i].spellid))
+					{
+						Message(12, "The sunlight fades");
+						BuffFadeBySlot(buffs_i);
+						CastSpell(346, GetID(), 1,0,0); //cast spell grim aura the night spell with no mana cost, no cast time
+					}
+					//leaving this here in case of future weather adjustments at night
+					if(IsNightTimeBuff(buffs[buffs_i].spellid))
+					{
+//						Message(11, "I have a Nighttime buff on"); //troubleshootinmg message							
+					}
+				}
+			}
+			//rencro done with timeofday stuff
+			else if(spells[buffs[buffs_i].spellid].buffdurationformula != DF_Permanent)
 			{
 				if(!zone->BuffTimersSuspended() || !IsSuspendableSpell(buffs[buffs_i].spellid))
 				{
I had experimented with creating a custom spell effect, this would allow you to remove any of the buffs via perl BuffFadeByEffect(), and also have control over stacking, as well as easy implementation into the use of the DoBuffTic function. I left those out.

All this does is check if any of these buffs are active, and if its active during the wrong time-frame to remove it and put the relevant version on. You still need to turn the relevant buff on via perl for this to do the checks on.

I made this to where it is easily expandable, can add more spells in, do compares of day buffs during the day ect ect. Also, please anyone, feel free to tell me where this can be improved ect..
Reply With Quote