roXplosive
New Member
- Reaction score
- 15
Well I made a structure for my reverse gravity spell I'm working on :
And later on any units antering in a reerse graity area will be sent flying :
The problem is my array of local FlyingUnit variables only memorizes the last unit entering the reerse gravity field on all the positions . I mean all the unit u fields in the structure hae the same value . If someone knows where I'm reinenting the wheel please point up .
PS : got to change my keyboard since my "V" key gies me a hard time
JASS:
struct FlyUnit //structure for making a unit fly
private unit u
private real x
private real y
private real z
private real BaseFlyHeight
private integer HeightModified //how many times this unit has been moved upwards
method Set takes unit target returns nothing
set .u=target
call BJDebugMsg(GetUnitName(.u))
set .x=GetUnitX(.u)
set .y=GetUnitY(.u)
set .z=GetUnitFlyHeight(.u)
set .BaseFlyHeight=.z
set .HeightModified = 0
call PauseUnit(.u,true)
call SetUnitPathing( .u , false )
call UnitAddAbility(.u,FlyAbilCode)
call UnitRemoveAbility(.u,FlyAbilCode)
endmethod
method GetFlyHeightNumber takes nothing returns integer
return .HeightModified
endmethod
method FlyHeight takes nothing returns real
return .z-.BaseFlyHeight
endmethod
method Unit takes nothing returns unit
return .u
endmethod
method Fly takes real NextHeight returns nothing
set .z=NextHeight+.BaseFlyHeight
set .HeightModified = .HeightModified + 1
// call BJDebugMsg("fly "+R2S(.z)+" "+GetUnitName(.u))
call SetUnitFlyHeight(.u,.z,FlyHeightRatio)
endmethod
method Destroy takes nothing returns nothing
call SetUnitFlyHeight(.u,.BaseFlyHeight,FlyHeightRatio)
call PauseUnit(.u , false )
call SetUnitPathing(.u , true )
set .u=null
endmethod
endstruct
And later on any units antering in a reerse graity area will be sent flying :
JASS:
set g=GetUnitsInRangeOfLocMatching(BaseAoE+AoEincrement*lvl , center , Filter(function True))
loop
set un=FirstOfGroup(g)
if IsUnitEnemy ( un , pl ) and (not IsUnitInGroup(un , g2)) and (un!=null) then
call GroupAddUnit(g2,un)
call affected[FlyingUnits].Set(un)
set FlyingUnits = FlyingUnits + 1
call BJDebugMsg("Unit added "+I2S(FlyingUnits)+" "+GetUnitName(un))
endif
exitwhen un==null
call GroupRemoveUnit(g,un)
endloop
The problem is my array of local FlyingUnit variables only memorizes the last unit entering the reerse gravity field on all the positions . I mean all the unit u fields in the structure hae the same value . If someone knows where I'm reinenting the wheel please point up .
PS : got to change my keyboard since my "V" key gies me a hard time