Warcraft III resources & community, 2003–2006 · archived

As suspected... I need help with my scripts.

46 posts
#1

As suspected... I need help with my scripts.

That is it:

global variables used:
(for type "[x]" means place "x" of an array,
for type array "[x]" means array with "x" places)

force "udg_Streitmacht[0]"
force "udg_tempSpielergruppe"
unit array "udg_Katze[6]"
unit "udg_tempEinheit"
integer "udg_Zähler[13]"


Trigger "Katze Hilfe 1":
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":
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":
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":
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":
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":
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":
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.
#2
srry, could you please recode that in english??? i cant understand what it is supposed to do, as all the trigger names are in ( german i think )
#3
Hm...pity I don´t have the time to do this right now but otherwise, here are the translations for Purple:

Streitmacht=force
Spielergruppe=player group=force
Katze=cat
TempEinheit=TempUnit
Zähler=counter
Katze Hilfe=cat help
Katze Bau=cat training(/building)
Katze Tod=cat death
Katze Steuerung (Hilfe)=cat control (help)
Katze Steuerung Streifzug=cat control wander(move around)
TempPunkt=TempPoint
TempGebiet=TempRegion

And @LordZsar1: Please don´t post JASS code this way! This forum has a jass formatting script that makes JASS scripts much easier to read! The "Code" option you used is ONLY for GUI!

And I realize there are a lot of germans in this forum (including me) but IMO Scripts are also much easier to read if ALL names and references are in English as JASS is English too. And everyone else will be able understand your scripts easier.
Thanks :wink:
#4
Ah, sorry.
I am not common with such supportive forums. ^^

Okay then, here is my code with english names...
What if I had only used alphanummeric identifiers? ^^

global variables used:
(for type "[x]" means place "x" of an array,
for type array "[x]" means array with "x" places)

force "udg_force[0]" 
force "udg_tempForce" 
unit array "udg_cat[6]" 
unit "udg_tempUnit" 
integer "udg_counter[13]"


Trigger "helpCat1":
function Trig_helpCat1_Conditions1 takes nothing returns boolean 
return IsPlayerInForce(GetFilterPlayer(),udg_force[0]) == true and GetFilterPlayer() != GetOwningPlayer(udg_tempUnit) 
endfunction 

function Trig_helpCat1_Subactions1 takes nothing returns nothing 
call SetPlayerUnitAvailableBJ('ndog',false,GetEnumPlayer()) 
endfunction 

function Trig_helpCat1_Actions takes nothing returns nothing 
if GetIssuedOrderIdBJ() == UnitId2OrderIdBJ('ndog') then 
set udg_tempUnit=GetTriggerUnit() 
if udg_counter[13] == 5 then 
call IssueImmediateOrderBJ(udg_tempUnit,"stop") 
else 
set udg_tempForce = GetPlayersMatching(Condition(function Trig_helpCat1_Conditions1)) 
call ForForce(udg_tempForce,function Trig_helpCat1_Subactions1) 
set udg_counter[13] = udg_counter[13] + 1 
endif 
endif 
endfunction 

function InitTrig_helpCat1 takes nothing returns nothing 
set gg_trg_helpCat1 = CreateTrigger() 
call TriggerRegisterAnyUnitEventBJ(gg_trg_helpCat1,EVENT_PLAYER_UNIT_ISSUED_ORDER) 
call TriggerAddAction(gg_trg_helpCat1,function Trig_helpCat1_Actions) 
endfunction


Trigger "helpCat2":
function Trig_helpCat2_Subactions1 takes nothing returns nothing 
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer()) 
endfunction 

function Trig_helpCat2_Actions takes nothing returns nothing 
if GetIssuedOrderIdBJ() == String2OrderIdBJ("stop") then 
set udg_counter[13] = udg_counter[13] - 1 
call DestroyForce(udg_tempForce) 
call ForForce(udg_Force[0],function Trig_helpCat2_Subactions1) 
endif 
endfunction 

function InitTrig_helpCat2 takes nothing returns nothing 
set gg_trg_helpCat2 = CreateTrigger() 
call TriggerRegisterUnitEvent(gg_trg_helpCat2,udg_tempUnit,EVENT_UNIT_ISSUED_ORDER) 
call TriggerAddAction(gg_trg_helpCat2,function Trig_helpCat2_Actions) 
endfunction


Trigger "trainCat":
function Trig_trainCat_Subactions1 takes nothing returns nothing 
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer()) 
endfunction 

function Trig_trainCat_Subactions2 takes nothing returns nothing 
call SetPlayerUnitAvailableBJ('ndog',false,GetEnumPlayer()) 
endfunction 

function Trig_trainCat_Actions takes nothing returns nothing 
if GetUnitTypeId(GetTrainedUnit()) == 'ndog' then 
set udg_cat[udg_counter[13]] = GetTrainedUnit() 
call SetUnitOwner(udg_cat[udg_Counter[13]],Player(PLAYER_NEUTRAL_PASSIVE),true) 
if udg_counter[13] == 0 then 
call EnableTrigger(gg_trg_controlCat1) 
call EnableTrigger(gg_trg_helpControlCat1) 
call EnableTrigger(gg_trg_controlCat1Wander) 
call ForForce(udg_Force[0],function Trig_trainCat_Subactions1) 
elseif udg_counter[13] == 1 then 
call EnableTrigger(gg_trg_controlCat2) 
call EnableTrigger(gg_trg_helpControlCat2) 
call EnableTrigger(gg_trg_controlCat2Wander) 
call ForForce(udg_Force[0],function Trig_trainCat_Subactions1) 
elseif udg_counter[13] == 2 then 
call EnableTrigger(gg_trg_controlCat3) 
call EnableTrigger(gg_trg_helpControlCat3) 
call EnableTrigger(gg_trg_controlCat3Wander) 
call ForForce(udg_Streitmacht[0],function Trig_trainCat_Subactions1) 
elseif udg_counter[13] == 3 then 
call EnableTrigger(gg_trg_controlCat4) 
call EnableTrigger(gg_trg_helpControlCat4) 
call EnableTrigger(gg_trg_controlCat4Wander) 
call ForForce(udg_Force[0],function Trig_trainCat_Subactions1) 
elseif udg_counter[13] == 4 then 
call EnableTrigger(gg_trg_controlCat5) 
call EnableTrigger(gg_trg_helpControlCat5) 
call EnableTrigger(gg_trg_controlCat5Wander) 
call ForForce(udg_Force[0],function Trig_trainCat_Subactions1) 
else 
call EnableTrigger(gg_trg_controlCat6) 
call EnableTrigger(gg_trg_helpControlCat6) 
call EnableTrigger(gg_trg_controlCat6Wander) 
call ForForce(udg_Streitmacht[0],function Trig_trainCat_Subactions2) 
endif 
call DestroyForce(udg_tempForce) 
endif 
endfunction 

function InitTrig_trainCat takes nothing returns nothing 
set gg_trg_trainCat = CreateTrigger() 
call TriggerRegisterAnyUnitEventBJ(gg_trg_trainCat,EVENT_PLAYER_UNIT_TRAIN_FINISH) 
call TriggerAddAction(gg_trg_trainCat,function Trig_trainCat_Actions) 
endfunction


Trigger "killCat":
function Trig_killCat_Subactions1 takes nothing returns nothing 
call SetPlayerUnitAvailableBJ('ndog',true,GetEnumPlayer()) 
endfunction 

function Trig_killCat_Actions takes nothing returns nothing 
if GetUnitTypeId(GetDyingUnit()) == 'ndog' then 
if udg_counter[13] == 5 then 
call DisableTrigger(gg_trg_controlCat6) 
call DisableTrigger(gg_trg_helpControlCat6) 
call DisableTrigger(gg_trg_controlCat6Wander) 
elseif udg_counter[13] == 4 then 
call DisableTrigger(gg_trg_controlCat5) 
call DisableTrigger(gg_trg_helpControlCat5) 
call DisableTrigger(gg_trg_controlCat5Wander) 
elseif udg_counter[13] == 3 then 
call DisableTrigger(gg_trg_controlCat4) 
call DisableTrigger(gg_trg_helpControlCat4) 
call DisableTrigger(gg_trg_controlCat4Wander) 
elseif udg_counter[13] == 2 then 
call DisableTrigger(gg_trg_controlCat3) 
call DisableTrigger(gg_trg_helpControlCat3) 
call DisableTrigger(gg_trg_controlCat3Wander) 
elseif udg_counter[13] == 1 then 
call DisableTrigger(gg_trg_controlCat2) 
call DisableTrigger(gg_trg_helpControlCat2) 
call DisableTrigger(gg_trg_controlCat2Wander) 
else 
call DisableTrigger(gg_trg_controlCat1) 
call DisableTrigger(gg_trg_helpControlCat1) 
call DisableTrigger(gg_trg_controlCat1Wander) 
endif 
set udg_counter[13] = udg_counter[13] - 1 
call ForForce(udg_Force[0],function Trig_killCat_Subactions1) 
endif 
endfunction 

function InitTrig_killCat takes nothing returns nothing 
set gg_trg_killCat = CreateTrigger() 
call TriggerRegisterAnyUnitEventBJ(gg_trg_killCat,EVENT_PLAYER_UNIT_DEATH) 
call TriggerAddAction(gg_trg_killCat,function Trig_killCat_Actions) 
endfunction


Trigger "controlCat1":
function Trig_controlCat1_Actions takes nothing returns nothing 
if GetUnitTypeId(GetTriggerUnit()) == 'nfro' or GetUnitTypeId(GetTriggerUnit()) == 'ndwm' or GetUnitTypeId(GetTriggerUnit()) == 'nrat' then 
call DisableTrigger(gg_trg_controlCat1) 
call DisableTrigger(gg_trg_controlCat1Wander) 
call IssueTargetOrderBJ(udg_cat[0],"attack",GetTriggerUnit()) 
endif 
endfunction 

function InitTrig_controlCat1 takes nothing returns nothing 
set gg_trg_controlCat1 = CreateTrigger() 
call DisableTrigger(gg_trg_controlCat1) 
call TriggerRegisterUnitInRangeSimple(gg_trg_controlCat1,1000,udg_cat[0]) 
call TriggerAddAction(gg_trg_controlCat1,function Trig_controlCat1_Actions) 
endfunction


Trigger "helpControlCat1":
function Trig_helpControlCat1_Actions takes nothing returns nothing 
if GetKillingUnitBJ() == udg_cat[0] then 
call EnableTrigger(gg_trg_controlCat1) 
call EnableTrigger(gg_trg_controlCat1Wander) 
endif 
endfunction 

function InitTrig_helpControlCat1 takes nothing returns nothing 
set gg_trg_helpControlCat1 = CreateTrigger() 
call DisableTrigger(gg_trg_helpControlCat1) 
call TriggerRegisterPlayerUnitEventSimple(gg_trg_helpControlCat1,Player(PLAYER_NEUTRAL_PASSIVE),EVENT_PLAYER_UNIT_DEATH) 
call TriggerAddAction(gg_trg_helpControlCat1,function Trig_helpControlCat1_Actions) 
endfunction


Trigger "controlCat1Wander":
function Trig_controlCat1Wander_Actions takes nothing returns nothing 
local location array tempPoint 
local rect tempRectangle 
set tempPoint[0] = GetUnitLoc(udg_Cat[0]) 
set tempRectangle = RectFromCenterSizeBJ(tempPoint[0],1000.00,1000.00) 
set tempPoint[1] = GetRandomLocInRect(tempRectangle) 
call IssuePointOrderLocBJ(udg_cat[0],"move",tempPoint[1]) 
call TriggerSleepAction(3.00) 
call RemoveLocation(tempPoint[0]) 
call RemoveLocation(tempPoint[1]) 
call RemoveRect(tempRectangle) 
endfunction 

function InitTrig_controlCat1Wander takes nothing returns nothing 
set gg_trg_controlCat1Wander = CreateTrigger() 
call DisableTrigger(gg_trg_controlCat1Wander) 
call TriggerRegisterTimerEventPeriodic(gg_trg_controlCat1Wander,GetRandomReal(10.00,20.00)) 
call TriggerAddAction(gg_trg_controlCat1Wander,function Trig_controlCat1Wander_Actions) 
endfunction


Hey, while rewriting this piece of text, I encountered my first fatal fault:

Excerpt from Trigger "Katze_Bau" (now "trainCat"), function "Trig_Katze_Bau_Actions" (now "Trig_trainCat_Actions"):

That is what was there before:
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([b]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


This is how is has to look (and how it does look now):
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_Streifzug)


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_Streifzug)


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_Streifzug)


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_Streifzug)


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_Streifzug)

 
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Actions_Subactions2) 
endif


This trigger is fully operational - 2/3 of my problem are solved.
Unbelievable that such a simple mistake slipped through more than a dozen controls of mine... ~~
I am already too old. ^^

Remaining dysfunction:

Trigger "controlCat1" does not make the unit attack specified targets as it is supposed to do.
#5
ummm...the new version of the excerpt of trainCat is the same?(german names?) or did I miss something?
But if that whole function is messed nothing would work so I think its alright.
The cat doesnt attack targets? Perhaps a range of 1000 is too much and the cat changes targets too often; or you should replace the IssueTargetOrderBJ functon with the native one, this sometimes helps. Another reason could be that the trigger is not (re-)activated correctly.
#6
[...] the new version of the excerpt of trainCat is the same?

Yes, that is exactly what I thought a thousand times while looking over it again and again to find out, what is wrong.
These lines are different:

call EnableTrigger(gg_trg_Katze_Steuerung_x)


call EnableTrigger(gg_trg_Katze_Steuerung_x_Streifzug)


For each time exept the first one "x=1" I used them. ~~
That is, why only the first "cat" moved around while the others held their position.
Some mistakes are so simple... ~~


Let us see...

Range of 1000 has been an experimental value.
I tried 250 first, then 300, 500, 750 and finally 1000.

Native function of IssueTargetOrderBJ...
That is IssueTargetOrder - the only use of the BJ function is... none! Simple waste of time.
May it work or not, that i will change at once.

Trigger activation?
Do not have time to check it yet, that will take a whole bunch of this wealthy ressource. ^^

Okay, ether in one hour or in two days i will know if one of these two possiblities is right.
#7
hmm, cant look at this now, but ill have a look tonight ( prob not, gotta code a system for someone ) or tomorrow at this time

EDIT: the problem is that you are putting the DisableTrigger( gg_trg_controlCat1 ) before the triggerregisgterunitevent and triggeraddaction.

Since InitTrigs are only run on startup, this cancels the only chance to init the trigger

to fix this ( and still have the trigger disable as supposed to ) move the DisableTrigger to the end.
#8
Sorry but no, I have a lot of working triggers which make use of this order.

I isolated the problem by inserting text messages into my code:
It is the EventListener of "ControlCatX".

I only do not know, why.
Unit types are correct, syntax is right, the variable is set...
Must be the function itself. ~~
#9
well, srry then, cant say i know, but neways

-try to remove alot of those BJs you are using

-why use globals?
#10
Whenever I want more than one function to deal with an object, I prefer global variables as long as I use the trigger system.
... It should be possible to recode my whole script into a triggerless syntax, but the map I am working on has 135 of these and to be sure I am simply too lazy to do such a bunch of work.

Yes, these BJ-things are aggravating and most of them have already been replaced - I waited with cleaning these functions as they did not work yet.

... function "TriggerRegisterUnitInRange(trigger,unit,real,boolexpr)" does not work with Condition "null".
I will test, if it works with a filter.

postscript:
The function does not work at all. ~~
Not to wonder about why a trigger is not working if there is no event returned.
#11
the triggerregisterunitinrange should work with a null... thats odd :(

try creating a condition function that says
return true

that should work
#12
I already did.
As I wrote in the last postscript: No event is thrown.
I used a text message to test it - nothing happened.

Any idea for an alternate construction?
#13
hmm... the only thing i can think of is that DisableTrigger should not be fired before the event

oh, and make sure the unit you are testing it with is Cat[0]
#14
Here three triggers become activated...

if udg_Zaehler[13] == 0 then
call EnableTrigger(gg_trg_catControl1)
call EnableTrigger(gg_trg_helpCatControl1)
call EnableTrigger(gg_trg_catControl1Wander)
call ForForce(udg_Streitmacht[0],function Trig_Katze_Bau_Subactions1)
[...]


"gg_trg_catControl1Wander" works. It makes the cat moving around.

In order to expose the problem, I altered "gg_trg_catControl1":

function Trig_catControl1_Actions takes nothing returns nothing
call DisplayTimedTextToForce(GetPlayersAll(),5.00,"Cat 1 engages target.")
call DisableTrigger(gg_trg_catControl1)
call DisableTrigger(gg_trg_catControl1Wander)
call IssueTargetOrder(udg_Katze[0],"attack",GetTriggerUnit())
endfunction


As you see: If the wrong position of "DisableTrigger()" whould cause my trouble, at least the text whould be displayed - no text appeared, when I moved my test unit into range.
#15
right after the DisableTrigger in ControlCat1, try putting a BJDebugMsg( "bwahahahaahahaha" )

after the events, conds, actions and stuff ( at teh end of the InitTrig ), put a BJDebugMsg( "hahahaahahah" )

see if both fire. if the first does but not the second, you are having a thread crash somewhere. if neither fire, then the DisableTrigger should be moved to the end of the InitTrig. if Both fire, it is in the action or conditions itself. if both fire, tell me and ill have another look xD