waaaks!
Zinctified
- Reaction score
- 255
ok I made this system which acts like a unit capture system, here's how it works:
now I have this as an example to call the struct
as you can see, I called steal method and then calls clear method after it, which means if a unit uses an ability that captures a unit that I already captured, I will lose visibility to that unit and its previous position, because the zone indicators are killed inside the clear method
the problem is, even though the enemy captured one of my captured units, I still gain visibility on its position, which means there are still zone indicators alive in that area, not sure if its my allies' zone indicators
this won't conflict on games that has some missing players because zone indicators are created for each player on a team, also the zone indicators only has the invulnerable ability
- creates a struct which assigns the unit to be captured and the player which we set the unit's owner
- when steal method is called, it converts the unit owner to the assigned player and creating dummy units (based on zone indicator) for each player in a force
- when clear method is called, it takes a force argument and removes the dummy units (based on its unit type) around the assigned unit (in create method) only for each player in the assigned force, regardless computer or user or playing or not playing
JASS:
library BaseCapture initializer init needs GroupUtils
globals
private constant string sfx = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
endglobals
struct controlTower
unit c
player p
method clear takes force f returns nothing
local group g
local unit u
local integer n
if( f == teamGwapo ) then
set g = NewGroup()
set n = 0
call GroupEnumUnitsInRange(g,GetUnitX(.c),GetUnitY(.c),300,BOOLEXPR_TRUE)
loop
set u = FirstOfGroup(g)
exitwhen u == null
loop
exitwhen n > 5
if( GetUnitTypeId(u) == 039;n000039; and GetOwningPlayer(u) == Player(n) ) then
call KillUnit(u)
endif
set n = n + 1
endloop
call GroupRemoveUnit(g,u)
endloop
call ReleaseGroup(g)
elseif( f == teamPangit ) then
set g = NewGroup()
set n = 6
call GroupEnumUnitsInRange(g,GetUnitX(.c),GetUnitY(.c),300,BOOLEXPR_TRUE)
loop
set u = FirstOfGroup(g)
exitwhen u == null
loop
exitwhen n > 11
if( GetUnitTypeId(u) == 039;n000039; and GetOwningPlayer(u) == Player(n) ) then
call KillUnit(u)
endif
set n = n + 1
endloop
call GroupRemoveUnit(g,u)
endloop
call ReleaseGroup(g)
endif
set g = null
set u = null
endmethod
method steal takes nothing returns nothing
local integer n = 0
local unit u
call SetUnitOwner(.c,.p,true)
call DestroyEffect(AddSpecialEffectTarget(sfx,.c,"origin"))
if( .p == playerGwapo ) then
if (IsPlayerInForce(GetLocalPlayer(), teamGwapo)) then
call PingMinimap(GetUnitX(.c), GetUnitY(.c), 3)
endif
loop
exitwhen n > 5
set u = CreateUnit(Player(n),039;n000039;,GetUnitX(.c),GetUnitY(.c),0.0)
set n = n + 1
endloop
elseif( .p == playerPangit ) then
if (IsPlayerInForce(GetLocalPlayer(), teamPangit)) then
call PingMinimap(GetUnitX(.c), GetUnitY(.c), 3)
endif
set n = 6
loop
exitwhen n > 11
set u = CreateUnit(Player(n),039;n000039;,GetUnitX(.c),GetUnitY(.c),0.0)
set n = n + 1
endloop
endif
set u = null
endmethod
static method create takes unit c, player p returns controlTower
local controlTower d = controlTower.allocate()
set d.c = c
set d.p = p
return d
endmethod
endstruct
endlibrary
now I have this as an example to call the struct
JASS:
...
private function act takes nothing returns nothing
local unit c = SpellEvent.CastingUnit
local unit t = SpellEvent.TargetUnit
local controlTower d
if( IsPlayerInForce(GetOwningPlayer(c), teamGwapo) )then
set d = controlTower.create(t,playerGwapo)
call d.steal()
call d.clear(teamPangit)
call d.destroy()
elseif ( IsPlayerInForce(GetOwningPlayer(c), teamPangit) )then
set d = controlTower.create(t,playerPangit)
call d.steal()
call d.clear(teamGwapo)
call d.destroy()
endif
set c = null
set t = null
endfunction
...
as you can see, I called steal method and then calls clear method after it, which means if a unit uses an ability that captures a unit that I already captured, I will lose visibility to that unit and its previous position, because the zone indicators are killed inside the clear method
the problem is, even though the enemy captured one of my captured units, I still gain visibility on its position, which means there are still zone indicators alive in that area, not sure if its my allies' zone indicators
this won't conflict on games that has some missing players because zone indicators are created for each player on a team, also the zone indicators only has the invulnerable ability