- Joined
- Sep 12, 2008
- Messages
- 657
okay, i made a code that makes a unit jump in a realistic way, but for some reason, when i added the same unit to the same loop(i dont use values, hashtables, groups, or w/e, only loops.), it made him go down faster, if i wrote it 10 times, he just jumped down. can any 1 tell me whats wrong with this code?
im pretty sure the problem is in:
call SetUnitFlyHeight(u, f-SCHeightDecrease*0.10, 0)
thank you in advance
JASS:
library SpeedGenerator
globals
integer array SCRealityCrush
real array SCRealityStatement
real array SCFacing
real array SCHeightDecrease
integer array SCCurrentCount
unit array SCUnit
real array SCStartingHeight
boolean array SCGeneratedUnit
endglobals
function Trig_Generator_Actions takes nothing returns nothing
local integer i = 0
local real f
local unit u
loop
set i = i + 1
set u = SCUnit[i]
set f = GetUnitFlyHeight(u)
if SCGeneratedUnit[i] == true then
if f >= 0 then
//--Doesnt Work?--\\
call SetUnitFlyHeight(u, f-SCHeightDecrease[i]*0.10, 0)
//--Doesnt Work?--\\
if SCRealityCrush[i] >= 0 then
set SCRealityCrush[i] = SCRealityCrush[i]-1
set SCHeightDecrease[i] = SCHeightDecrease[i]-SCRealityStatement[i]
set SCStartingHeight[i] = SCStartingHeight[i]-SCRealityStatement[i]
call SetUnitFlyHeight(u, SCStartingHeight[i], 0)
endif
else
call UnitRemoveAbility(u, 'Amrf')
call SetPlayerAbilityAvailable(GetOwningPlayer(u), 'Amrf', true)
set SCRealityCrush[i] = 0
set SCRealityStatement[i] = 0
set SCFacing[i] = 0
set SCHeightDecrease[i] = 0
set SCStartingHeight[i] = 0
set SCUnit[i] = u
set SCCurrentCount[1] = SCCurrentCount[1] - 1
set SCCurrentCount[2] = 0
set SCGeneratedUnit[i] = false
endif
endif
exitwhen i >= SCCurrentCount[2]
endloop
endfunction
function GenerateAdd takes unit u returns nothing
set SCCurrentCount[1] = SCCurrentCount[1] + 1
set SCCurrentCount[2] = SCCurrentCount[2] + 1
set SCRealityCrush[SCCurrentCount[2]] = udg_SC_RealityCrushing
set SCRealityStatement[SCCurrentCount[2]] = udg_SC_RealityStatement
set SCFacing[SCCurrentCount[2]] = udg_SC_Facing
set SCHeightDecrease[SCCurrentCount[2]] = udg_SC_HeightDecreasePerSecond
set SCStartingHeight[SCCurrentCount[2]] = udg_SC_StartingHeight
set SCUnit[SCCurrentCount[2]] = u
set SCGeneratedUnit[SCCurrentCount[2]] = true
call UnitAddAbility(u, 'Amrf')
call SetPlayerAbilityAvailable(GetOwningPlayer(u), 'Amrf', false)
call SetUnitFlyHeight(u, SCStartingHeight[SCCurrentCount[2]], 0)
endfunction
endlibrary
function InitTrig_Generator takes nothing returns nothing
set gg_trg_Generator= CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Generator, 0.10 )
call TriggerAddAction( gg_trg_Generator, function Trig_Generator_Actions )
endfunction
im pretty sure the problem is in:
call SetUnitFlyHeight(u, f-SCHeightDecrease*0.10, 0)
thank you in advance