That is it:
global variables used:
(for type "[x]" means place "x" of an array,
for type array "[x]" means array with "x" places)
Trigger "Katze Hilfe 1":
Trigger "Katze Hilfe 2":
Trigger "Katze Bau":
Trigger "Katze Tod":
Trigger "Katze Steuerung 1":
Trigger "Katze Steuerung 1 Hilfe":
Trigger "Katze Steuerung 1 Streifzug":
The last three triggers exist fife more times, these version's only difference are the numbers set into the arrays.
It should work this way:
I have got six players and each one is able to build the unit "Katze" ('ndog').
Each time one of these Players finishes the training of this unit type, the Trigger "Katze Bau" is supposed to save a reference to this unit in the unit array "udg_Katze".
Which place of the array is used shall depend on the number of such units already existing on the map.
Now, the three triggers "Katze Steuerung x", "Katze Steuerung x Hilfe" and "Katze Steuerung x Streifzug" should be activated, for x is the number of the built unit. (the first one should have x=1, the second one x=2 and so on up to a maximum of x=6)
That's not all this construction is supposed to do but here my problems start:
The first unit I create works (nearly) perfectly.
But the second and each next one does not!
The triggers are ether not activated or the units are not saved in the correct array place.
I thought about it a pretty long time but I do not get it, where my code is wrong. ~~
So, if somebody may have a lot of free time and whould enjoy to examine complicated code...
Your help whould be very welcome.
global variables used:
(for type "[x]" means place "x" of an array,
for type array "[x]" means array with "x" places)
JASS:
force "udg_Streitmacht[0]"
force "udg_tempSpielergruppe"
unit array "udg_Katze[6]"
unit "udg_tempEinheit"
integer "udg_Zähler[13]"
Trigger "Katze Hilfe 1":
JASS:
function Trig_Katze_Hilfe_1_Conditions1 takes nothing returns boolean
return IsPlayerInForce(GetFilterPlayer(),udg_Streitmacht[0]) == true and GetFilterPlayer() != GetOwningPlayer(udg_tempEinheit)
endfunction
function Trig_Katze_Hilfe_1_Subactions1 takes nothing returns nothing
call SetPlayerUnitAvailableBJ('ndog',false,GetEnumPlayer())
endfunction
function Trig_Katze_Hilfe_1_Actions takes nothing returns nothing
if GetIssuedOrderIdBJ() == UnitId2OrderIdBJ('ndog') then
set udg_tempEinheit=GetTriggerUnit()
if udg_Zaehler[13] == 5 then
call IssueImmediateOrderBJ(udg_tempEinheit,"stop")
else
set udg_tempSpielergruppe = GetPlayersMatching(Condition(function Trig_Katze_Hilfe_1_Conditions1))
call ForForce(udg_tempSpielergruppe,function Trig_Katze_Hilfe_1_Subactions1)
set udg_Zaehler[13] = udg_Zaehler[13] + 1
endif
endif
endfunction
function InitTrig_Katze_Hilfe_1 takes nothing returns nothing
set gg_trg_Katze_Hilfe_1 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Katze_Hilfe_1,EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddAction(gg_trg_Katze_Hilfe_1,function Trig_Katze_Hilfe_1_Actions)
endfunction
Trigger "Katze Hilfe 2":
JASS:
function Trig_Katze_Hilfe_2_Subactions1 takes nothing returns nothing
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer())
endfunction
function Trig_Katze_Hilfe_2_Actions takes nothing returns nothing
if GetIssuedOrderIdBJ() == String2OrderIdBJ("stop") then
set udg_Zaehler[13] = udg_Zaehler[13] - 1
call DestroyForce(udg_tempSpielergruppe)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Hilfe_2_Subactions1)
endif
endfunction
function InitTrig_Katze_Hilfe_2 takes nothing returns nothing
set gg_trg_Katze_Hilfe_2 = CreateTrigger()
call TriggerRegisterUnitEvent(gg_trg_Katze_Hilfe_2,udg_tempEinheit,EVENT_UNIT_ISSUED_ORDER)
call TriggerAddAction(gg_trg_Katze_Hilfe_2,function Trig_Katze_Hilfe_2_Actions)
endfunction
Trigger "Katze Bau":
JASS:
function Trig_Katze_Bau_Actions_Subactions1 takes nothing returns nothing
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer())
endfunction
function Trig_Katze_Bau_Actions_Subactions2 takes nothing returns nothing
call SetPlayerUnitAvailableBJ('ndog',false,GetEnumPlayer())
endfunction
function Trig_Katze_Bau_Actions takes nothing returns nothing
if GetUnitTypeId(GetTrainedUnit()) == 'ndog' then
set udg_Katze[udg_Zaehler[13]] = GetTrainedUnit()
call SetUnitOwner(udg_Katze[udg_Zaehler[13]],Player(PLAYER_NEUTRAL_PASSIVE),true)
if udg_Zaehler[13] == 0 then
call EnableTrigger(gg_trg_Katze_Steuerung_1)
call EnableTrigger(gg_trg_Katze_Steuerung_1_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_1_Streifzug)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions1)
elseif udg_Zaehler[13] == 1 then
call EnableTrigger(gg_trg_Katze_Steuerung_2)
call EnableTrigger(gg_trg_Katze_Steuerung_2_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_2)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions1)
elseif udg_Zaehler[13] == 2 then
call EnableTrigger(gg_trg_Katze_Steuerung_3)
call EnableTrigger(gg_trg_Katze_Steuerung_3_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_3)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions1)
elseif udg_Zaehler[13] == 3 then
call EnableTrigger(gg_trg_Katze_Steuerung_4)
call EnableTrigger(gg_trg_Katze_Steuerung_4_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_4)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions1)
elseif udg_Zaehler[13] == 4 then
call EnableTrigger(gg_trg_Katze_Steuerung_5)
call EnableTrigger(gg_trg_Katze_Steuerung_5_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_5)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions1)
else
call EnableTrigger(gg_trg_Katze_Steuerung_6)
call EnableTrigger(gg_trg_Katze_Steuerung_6_Hilfe)
call EnableTrigger(gg_trg_Katze_Steuerung_6)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions2)
endif
call DestroyForce(udg_tempSpielergruppe)
endif
endfunction
function InitTrig_Katze_Bau takes nothing returns nothing
set gg_trg_Katze_Bau = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Katze_Bau,EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddAction(gg_trg_Katze_Bau,function Trig_Katze_Bau_Actions)
endfunction
Trigger "Katze Tod":
JASS:
function Trig_Katze_Tod_Actions_Subactions1 takes nothing returns nothing
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer())
endfunction
function Trig_Katze_Tod_Actions takes nothing returns nothing
if GetUnitTypeId(GetDyingUnit()) == 'ndog' then
if udg_Zaehler[13] == 5 then
call DisableTrigger(gg_trg_Katze_Steuerung_6)
call DisableTrigger(gg_trg_Katze_Steuerung_6_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_6_Streifzug)
elseif udg_Zaehler[13] == 4 then
call DisableTrigger(gg_trg_Katze_Steuerung_5)
call DisableTrigger(gg_trg_Katze_Steuerung_5_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_5_Streifzug)
elseif udg_Zaehler[13] == 3 then
call DisableTrigger(gg_trg_Katze_Steuerung_4)
call DisableTrigger(gg_trg_Katze_Steuerung_4_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_4_Streifzug)
elseif udg_Zaehler[13] == 2 then
call DisableTrigger(gg_trg_Katze_Steuerung_3)
call DisableTrigger(gg_trg_Katze_Steuerung_3_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_3_Streifzug)
elseif udg_Zaehler[13] == 1 then
call DisableTrigger(gg_trg_Katze_Steuerung_2)
call DisableTrigger(gg_trg_Katze_Steuerung_2_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_2_Streifzug)
else
call DisableTrigger(gg_trg_Katze_Steuerung_1)
call DisableTrigger(gg_trg_Katze_Steuerung_1_Hilfe)
call DisableTrigger(gg_trg_Katze_Steuerung_1_Streifzug)
endif
set udg_Zaehler[13] = udg_Zaehler[13] - 1
call ForForce(udg_Streitmacht[0],function Trig_Katze_Tod_Actions_Subactions1)
endif
endfunction
function InitTrig_Katze_Tod takes nothing returns nothing
set gg_trg_Katze_Tod = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Katze_Tod,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(gg_trg_Katze_Tod,function Trig_Katze_Tod_Actions)
endfunction
Trigger "Katze Steuerung 1":
JASS:
function Trig_Katze_Steuerung_1_Actions takes nothing returns nothing
if GetUnitTypeId(GetTriggerUnit()) == 'nfro' or GetUnitTypeId(GetTriggerUnit()) == 'ndwm' or GetUnitTypeId(GetTriggerUnit()) == 'nrat' then
call DisableTrigger(gg_trg_Katze_Steuerung_1)
call DisableTrigger(gg_trg_Katze_Steuerung_1_Streifzug)
call IssueTargetOrderBJ(udg_Katze[0],"attack",GetTriggerUnit())
endif
endfunction
function InitTrig_Katze_Steuerung_1 takes nothing returns nothing
set gg_trg_Katze_Steuerung_1 = CreateTrigger()
call DisableTrigger(gg_trg_Katze_Steuerung_1)
call TriggerRegisterUnitInRangeSimple(gg_trg_Katze_Steuerung_1,1000,udg_Katze[0])
call TriggerAddAction(gg_trg_Katze_Steuerung_1,function Trig_Katze_Steuerung_1_Actions)
endfunction
Trigger "Katze Steuerung 1 Hilfe":
JASS:
function Trig_Katze_Steuerung_1_Hilfe_Actions takes nothing returns nothing
if GetKillingUnitBJ() == udg_Katze[0] then
call EnableTrigger(gg_trg_Katze_Steuerung_1)
call EnableTrigger(gg_trg_Katze_Steuerung_1_Streifzug)
endif
endfunction
function InitTrig_Katze_Steuerung_1_Hilfe takes nothing returns nothing
set gg_trg_Katze_Steuerung_1_Hilfe = CreateTrigger()
call DisableTrigger(gg_trg_Katze_Steuerung_1_Hilfe)
call TriggerRegisterPlayerUnitEventSimple(gg_trg_Katze_Steuerung_1_Hilfe,Player(PLAYER_NEUTRAL_PASSIVE),EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(gg_trg_Katze_Steuerung_1_Hilfe,function Trig_Katze_Steuerung_1_Hilfe_Actions)
endfunction
Trigger "Katze Steuerung 1 Streifzug":
JASS:
function Trig_Katze_Steuerung_1_Streifzug_Actions takes nothing returns nothing
local location array tempPunkt
local rect tempGebiet
set tempPunkt[0] = GetUnitLoc(udg_Katze[0])
set tempGebiet = RectFromCenterSizeBJ(tempPunkt[0],1000.00,1000.00)
set tempPunkt[1] = GetRandomLocInRect(tempGebiet)
call IssuePointOrderLocBJ(udg_Katze[0],"move",tempPunkt[1])
call TriggerSleepAction(3.00)
call RemoveLocation(tempPunkt[0])
call RemoveLocation(tempPunkt[1])
call RemoveRect(tempGebiet)
endfunction
function InitTrig_Katze_Steuerung_1_Streifzug takes nothing returns nothing
set gg_trg_Katze_Steuerung_1_Streifzug = CreateTrigger()
call DisableTrigger(gg_trg_Katze_Steuerung_1_Streifzug)
call TriggerRegisterTimerEventPeriodic(gg_trg_Katze_Steuerung_1_Streifzug,GetRandomReal(10.00,20.00))
call TriggerAddAction(gg_trg_Katze_Steuerung_1_Streifzug,function Trig_Katze_Steuerung_1_Streifzug_Actions)
endfunction
The last three triggers exist fife more times, these version's only difference are the numbers set into the arrays.
It should work this way:
I have got six players and each one is able to build the unit "Katze" ('ndog').
Each time one of these Players finishes the training of this unit type, the Trigger "Katze Bau" is supposed to save a reference to this unit in the unit array "udg_Katze".
Which place of the array is used shall depend on the number of such units already existing on the map.
Now, the three triggers "Katze Steuerung x", "Katze Steuerung x Hilfe" and "Katze Steuerung x Streifzug" should be activated, for x is the number of the built unit. (the first one should have x=1, the second one x=2 and so on up to a maximum of x=6)
That's not all this construction is supposed to do but here my problems start:
The first unit I create works (nearly) perfectly.
But the second and each next one does not!
The triggers are ether not activated or the units are not saved in the correct array place.
I thought about it a pretty long time but I do not get it, where my code is wrong. ~~
So, if somebody may have a lot of free time and whould enjoy to examine complicated code...
Your help whould be very welcome.