| 02-25-2009, 01:58 PM | #1 |
JASS:scope Warstomp initializer Init globals private constant integer SPELL = 'AOws' private boolexpr b endglobals struct data real x real y group g unit caster integer i timer t real duration static method create takes nothing returns data local data d = data.allocate() set d.g = CreateGroup() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.i = GetUnitAbilityLevel(d.caster,SPELL) call GroupEnumUnitsInRange(d.g,d.x,d.y,100+50*d.i,b) call BJDebugMsg("Creating Struct.....") return d endmethod method OnDestroy takes nothing returns nothing call ReleaseTimer(.t) call DestroyGroup(.g) set .g = null endmethod endstruct private function Conditions takes nothing returns boolean call BJDebugMsg("Conditions Worked!") return GetSpellAbilityId() == SPELL endfunction private function Check takes nothing returns boolean call BJDebugMsg("Checking work") return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) endfunction private function Loop takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) local real ux local real uy local real a local unit f call BJDebugMsg("Time To Loop!") set d.duration = d.i + 0.05 if d.duration < 1+0.5*d.i then loop call BJDebugMsg("looping") set f = FirstOfGroup(d.g) exitwhen f == null set ux = GetUnitY(f) set uy = GetUnitY(f) set a = Atan2(uy-d.y,ux-d.x) call SetUnitPosition(f,ux + 40*Cos(a),uy+40*Sin(a)) call GroupRemoveUnit(d.g,f) endloop else call d.destroy() endif endfunction private function Actions takes nothing returns nothing local data d = data.create() call SetTimerData(d.t,integer(d)) call TimerStart(d.t,0.05,true,function Loop) call BJDebugMsg("actions worked") endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( t, Condition( function Conditions ) ) call TriggerAddAction( t, function Actions ) set b = Condition(function Check) endfunction endscope This code isn't pushing enemys back.. Actions , Check , Create , Conditions work fine but the loop just never works. |
| 02-25-2009, 02:33 PM | #2 |
JASS:set d.t=NewTimer() // this goes to create method |
| 02-25-2009, 03:05 PM | #3 |
Your indentation is horrific, you should work on that. Viikuna is dead on the money, though, you never initialize your timer. (So SetTimerData won't do anything) |
| 02-26-2009, 06:24 AM | #4 |
JASS:scope Warstomp initializer Init globals private constant integer SPELL = 'AOws' private constant real SPEED = 700 private constant real TIME = 0.03 private boolexpr b endglobals struct data real x real y group g unit caster integer i timer t real duration real distance static method create takes nothing returns data local data d = data.allocate() set d.g = CreateGroup() set d.t = NewTimer() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.i = GetUnitAbilityLevel(d.caster,SPELL) call GroupEnumUnitsInRange(d.g,d.x,d.y,100+50*d.i,b) call BJDebugMsg("Creating Struct.....") return d endmethod method OnDestroy takes nothing returns nothing call ReleaseTimer(.t) call DestroyGroup(.g) set .g = null endmethod endstruct private function DISTANCE takes integer level returns integer return level * 150 endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == SPELL endfunction private function Check takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) endfunction private function Loop takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) local real ux local real uy local real angle local unit t local real cos local real sin local group g = d.g loop set t = FirstOfGroup(g) exitwhen t == null set ux = GetUnitX(t) set uy = GetUnitY(t) set angle = Atan2(uy-d.y,ux-d.x) set cos = Cos(angle) set sin = Sin(angle) set ux = ux + cos * TIME * SPEED set uy = uy + sin * TIME * SPEED call SetUnitPosition(t,ux,uy) call GroupRemoveUnit(g,t) endloop set d.distance = d.distance - TIME * SPEED if d.distance <= 0 then call d.destroy() endif endfunction private function Actions takes nothing returns nothing local data d = data.create() local unit caster = GetTriggerUnit() set d.distance = DISTANCE(GetUnitAbilityLevel(d.caster,SPELL)) call SetTimerData(d.t,integer(d)) call TimerStart(d.t,TIME,true,function Loop) endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( t, Condition( function Conditions ) ) call TriggerAddAction( t, function Actions ) set b = Condition(function Check) endfunction endscope Alright, a revised verison , now why does this push the unit ... alittle bit instead of the distance which i wanted |
| 02-26-2009, 06:41 AM | #5 |
It's probably getting stopped by the SetUnitPosition call, which factors in collision and terrain and all that shaz when moving the unit. |
| 02-26-2009, 06:44 AM | #6 |
JASS:scope Warstomp initializer Init globals private constant integer SPELL = 'AOws' private constant real TIME = 0.03 private constant string EFFECT = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" private boolexpr b endglobals struct data real x real y group g unit caster integer i timer t real duration real distance real fx real speed static method create takes nothing returns data local data d = data.allocate() set d.g = CreateGroup() set d.t = NewTimer() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.i = GetUnitAbilityLevel(d.caster,SPELL) set d.speed = 600 call GroupEnumUnitsInRange(d.g,d.x,d.y,100+50*d.i,b) call BJDebugMsg("Creating Struct.....") return d endmethod method onDestroy takes nothing returns nothing call ReleaseTimer(.t) endmethod endstruct private function DISTANCE takes integer level returns integer return level * 250 endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == SPELL endfunction private function Check takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) endfunction private function Move takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) local unit t = GetEnumUnit() local real ux = GetUnitX(t) local real uy = GetUnitY(t) local real angle = Atan2(uy-d.y,ux-d.x) local real cos = Cos(angle) local real sin = Sin(angle) set ux = ux + cos * TIME * d.speed set uy = uy + sin * TIME * d.speed call SetUnitPosition(t,ux,uy) call DestroyEffect(AddSpecialEffect(EFFECT,ux,uy)) endfunction private function Loop takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) set d.speed = d.speed + 30 set d.distance = d.distance - TIME * d.speed if d.distance <= 0 then call d.destroy() endif call ForGroup(d.g,function Move) endfunction private function Actions takes nothing returns nothing local data d = data.create() local unit caster = GetTriggerUnit() set d.distance = DISTANCE(GetUnitAbilityLevel(d.caster,SPELL)) call SetTimerData(d.t,integer(d)) call TimerStart(d.t,TIME,true,function Loop) set caster = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( t, Condition( function Conditions ) ) call TriggerAddAction( t, function Actions ) set b = Condition(function Check) endfunction endscope I finally got all the effects and knockback done * cough * Now I have some problems, I want to limit the SFX to 8, how do i do that? |
| 02-27-2009, 04:15 AM | #7 |
BUMP |
| 03-01-2009, 05:59 AM | #8 |
Bump New Error found , when ever I set JASS:set d.speed = d.speed + 30 to JASS:set d.speed = d.speed - 30 The unit gets pushed back and then pushed back to the caster location , stuck there for eternity. Anybody know why? I am trying to do acceleration, from fast to slow pushback. I merely changed + 30 to - 30. I finally got all the effects and knockback done * cough * Now I have some problems, I want to limit the SFX to 8, how do i do that? Current code. JASS:scope Warstomp initializer Init globals private constant integer SPELL = 'AOws' private constant real TIME = 0.03 private constant string EFFECT = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" private boolexpr b endglobals private struct data real x real y group g unit caster integer i timer t real duration real distance real fx real speed static method create takes nothing returns data local data d = data.allocate() set d.g = CreateGroup() set d.t = NewTimer() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.i = GetUnitAbilityLevel(d.caster,SPELL) set d.speed = 600 call GroupEnumUnitsInRange(d.g,d.x,d.y,100+50*d.i,b) return d endmethod method onDestroy takes nothing returns nothing call ReleaseTimer(.t) endmethod endstruct private function DISTANCE takes integer level returns integer return level * 250 endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == SPELL endfunction private function Check takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) endfunction private function Move takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) local unit t = GetEnumUnit() local real ux = GetUnitX(t) local real uy = GetUnitY(t) local real angle = Atan2(uy-d.y,ux-d.x) local real cos = Cos(angle) local real sin = Sin(angle) set ux = ux + cos * TIME * d.speed set uy = uy + sin * TIME * d.speed call SetUnitPosition(t,ux,uy) call DestroyEffect(AddSpecialEffect(EFFECT,ux,uy)) set t = null endfunction private function Loop takes nothing returns nothing local data d = data(GetTimerData(GetExpiredTimer())) set d.speed = d.speed + 30 set d.distance = d.distance - TIME * d.speed if d.distance <= 0 then call d.destroy() endif call ForGroup(d.g,function Move) endfunction private function Actions takes nothing returns nothing local data d = data.create() set d.distance = DISTANCE(d.i) call SetTimerData(d.t,integer(d)) call TimerStart(d.t,TIME,true,function Loop) endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( t, Condition( function Conditions ) ) call TriggerAddAction( t, function Actions ) set b = Condition(function Check) endfunction endscope |
