I want an object to fire a random spell at the player anytime they are within range and are not already affected by one of its spells. I completely broke the game with my latest iteration, lagged it into oblivion because it was firing spells constantly. Looking for some help...
begin MT15_mg_scr_ball
float timer2
short istriggered
short spell
if ( timer2 > 10 )
set timer2 to 0
if ( GetDistance "player" < 1000 )
if ( Player->GetSpellEffects "MT15_mg_spell_ball_1" )
return
elseif ( Player->GetSpellEffects "MT15_mg_spell_ball_2" )
return
elseif ( Player->GetSpellEffects "MT15_mg_spell_ball_3" )
return
elseif ( Player->GetSpellEffects "MT15_mg_spell_ball_4" )
return
elseif ( Player->GetSpellEffects "MT15_mg_spell_ball_5" )
return
elseif ( Player->GetSpellEffects "MT15_mg_spell_ball_6" )
return
else
set istriggered to 1
endif
endif
endif
if ( istriggered > 0 )
set spell to random100
if ( spell < 15 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_1" player
set istriggered to istriggered - 1
endif
elseif ( spell < 30 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_2" player
set istriggered to istriggered - 1
endif
elseif ( spell < 45 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_3" player
set istriggered to istriggered - 1
endif
elseif ( spell < 60 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_4" player
set istriggered to istriggered - 1
endif
elseif ( spell < 75 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_5" player
set istriggered to istriggered - 1
endif
elseif ( spell < 90 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_6" player
set istriggered to istriggered - 1
endif
elseif ( spell < 100 )
set timer2 to ( timer2 + GetSecondsPassed )
cast "MT15_mg_spell_ball_7" player
set istriggered to istriggered - 1
endif
endif
endif
end MT15_mg_scr_ball
Odds are I really screwed things up when I tried to use the timer.
Thanks for taking a look.
-MD