It just doesn't work v___v. Whenever I try to test this code with WE syntax, it disables all of them. Whenever I try without WE syntax, it loads WC, not WE, meaning there was an error in the script. It is supposed to create a struct when certain buildings are built, then access them and add units and handles.
Here is what I have...
The build trigger...
The Struct
The Add Transfer Function
The remove transfer...
The add function puts a handle and unit in the next spot in the arrays, while the remove finds the unit in the array, and replaces all the units above it so space is saved. I think though, that the problem is somewhere in the creation of the struct. Any help is appreciated. THanks.
Here is what I have...
The build trigger...
JASS:
function Trig_TowerBuild_Func001C takes nothing returns boolean
if ( ( GetUnitTypeId(GetConstructedStructure()) == 'h002' ) ) or ( ( GetUnitTypeId(GetConstructedStructure()) == 'h004' ) ) or ( ( GetUnitTypeId(GetConstructedStructure()) == 'h001' ) )or ( ( GetUnitTypeId(GetConstructedStructure()) == 'h000' ) ) or ( ( GetUnitTypeId(GetConstructedStructure()) == 'h003' ) ) then
return true
else
return false
endif
endfunction
function Trig_TowerBuild_Actions takes nothing returns nothing
local unit s = GetConstructedStructure()
local towerinfo u = towerinfo.create()
call SetUnitUserData(s, u)
endfunction
//===========================================================================
function InitTrig_TowerBuild takes nothing returns nothing
set gg_trg_TowerBuild = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_TowerBuild, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddCondition( gg_trg_TowerBuild, Condition( function Trig_TowerBuild_Func001C ) )
call TriggerAddAction( gg_trg_TowerBuild, function Trig_TowerBuild_Actions )
endfunction
JASS:
struct towerinfo
unit array t[10]
unit u
lightning array l[10]
integer n = 0
method AddUnit takes unit add, unit trig returns nothing
set this.n = this.n + 1
set this.t[this.n] = add
set this.l[this.n] = AddLightningEx( "CLPB", true, GetUnitX(trig),GetUnitY(trig), GetLocationZ(GetUnitLoc(trig)), GetUnitX(add),GetUnitY(add),GetLocationZ(GetUnitLoc(add)))
endmethod
method RemoveTransfer takes unit remove returns nothing
local integer c
set this.n = this.n - 1
loop
set c = c + 1
exitwhen remove == this.t[c]
endloop
call DestroyLightning(l[c])
loop
set this.t[c] = this.t[c + 1]
set this.l[c] = this.l[c + 1]
set c = c + 1
exitwhen this.t[c] == null
endloop
endmethod
endstruct
JASS:
function Trig_AddTransfer_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function Trig_AddTransfer_Actions takes nothing returns nothing
local towerinfo ti = GetUnitUserData(GetTriggerUnit())
call ti.AddUnit(GetSpellTargetUnit(),GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_AddTransfer takes nothing returns nothing
set gg_trg_AddTransfer = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AddTransfer, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_AddTransfer, Condition( function Trig_AddTransfer_Conditions ) )
call TriggerAddAction( gg_trg_AddTransfer, function Trig_AddTransfer_Actions )
endfunction
JASS:
function Trig_RemoveTransfer_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction
function Trig_RemoveTransfer_Actions takes nothing returns nothing
local towerinfo ti = GetUnitUserData(GetTriggerUnit())
call ti.RemoveTransfer(GetSpellTargetUnit())
endfunction
//===========================================================================
function InitTrig_RemoveTransfer takes nothing returns nothing
set gg_trg_RemoveTransfer = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RemoveTransfer, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_RemoveTransfer, Condition( function Trig_RemoveTransfer_Conditions ) )
call TriggerAddAction( gg_trg_RemoveTransfer, function Trig_RemoveTransfer_Actions )
endfunction
The add function puts a handle and unit in the next spot in the arrays, while the remove finds the unit in the array, and replaces all the units above it so space is saved. I think though, that the problem is somewhere in the creation of the struct. Any help is appreciated. THanks.