• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

how to order just unloaded units

Status
Not open for further replies.
Level 17
Joined
Aug 19, 2007
Messages
1,380
- fixed, see below

Hi all,

I made a system where AI do droppings (with flying transports), but as soon as they unloaded the units at the enemy base, the unloaded units just walk back to their own base (except when being attacked by e.g. enemy towers) even while the enemy buildings are in their attack range.

So I need to give them an order to attack-move. I just don't really know which event I need to use. At the moment I have the following but it doesn't work (I thought maybe that when a unit is unloaded it re-enters the map):

  • AI unit is unloaded
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Triggering unit) is A peon-type unit) Not equal to True
      • ((Triggering unit) is A structure) Not equal to True
    • Actions
      • Set TEMP_PointUnload = (Position of (Triggering unit))
      • Unit - Order (Triggering unit) to Attack-Move To TEMP_PointUnload
      • Custom script: call RemoveLocation(udg_TEMP_PointUnload)
Anyone an idea? +rep for helpers
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,196
You need to tell the enemy army to attack the base as well as dropping it in the base. Otherwise the AI will think the army should be in his base so retreat it there.

In StarCraft II you could create a custom attack wave that you order to attack where you dropped. In Warcraft III I am not sure how one goes about doing it as programming AI is a lot harder but I am guessing you still need to order the army to attack the base.
 
Level 17
Joined
Aug 19, 2007
Messages
1,380
Thanks for the comments;

Why don't you order to attack right after do the Unload Unit order?
, an issue order does not work while they are transported (atleast not in this case, tested it a few times). Units just keep retreating to their base if they are not attacked.

You can use this to detect unloading: Unit Event v2.0.0.0
, that sounds like a good solution, I get script errors though when copying it to my map & saving the map (I followed the 4 steps of 'installing' it), something about wrong name or something like that (can post a screenshot if needed).

You need to tell the enemy army to attack the base as well as dropping it in the base. Otherwise the AI will think the army should be in his base so retreat it there.
, it is probably possible through the 'send ai command' trigger, but I have no clue how that one works.
 
Level 17
Joined
Aug 19, 2007
Messages
1,380
You are propably missing a variable. Post the error.
, my quess is the DEvTimer variable is missing, thanks for taking the time so far +rep


138114-albums6211-picture72976.jpg



-edit, I fixed it by adding the DEvTimer as a variable. Thanks for steering me right way Maker. And thanks Spartipilo and Dr Super Good for trying to help.

-edit edit, I cannot do really much with this event atm. - fixed

  • On Unload Copy
    • Events
      • Game - CargoEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • Game - Display to (All players) the text: ((Name of UDexUnits[UDex]) + ( was unloaded from + (Name of CargoTransportUnit[UDex])))

  • Unit Event
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • -------- --------
      • -------- Functionality credits go to Nestharus (for vJass UnitEvent) and grim001 (for AutoEvents) --------
      • -------- --------
      • Custom script: if udg_DEvAbility == 0 then
      • -------- --------
      • -------- Copy Death Event Ability from Object Editor, then set DEvAbility to it as follows --------
      • -------- --------
      • Set DEvAbility = Death Event Ability (Undefend Detect)
      • -------- --------
      • Custom script: call ExecuteFunc("InitDeathEvent")
      • Custom script: endif
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitIndexEvent Equal to 1.00
        • Then - Actions
          • Unit - Add DEvAbility to UDexUnits[UDex]
          • Custom script: call UnitMakeAbilityPermanent(udg_UDexUnits[udg_UDex], true, udg_DEvAbility)
          • Set DEvBlock[UDex] = True
          • Set IsUnitAlive[UDex] = True
          • Custom script: call ExecuteFunc("DEvCheckDeathProxy")
        • Else - Actions
          • Set IsUnitAlive[UDex] = False
          • Set IsUnitReincarnating[UDex] = False
          • Set DEvRemoved[UDex] = False
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CargoTransportUnit[UDex] Not equal to No unit
            • Then - Actions
              • Custom script: call ExecuteFunc("CEvFireUnload")
            • Else - Actions
          • Custom script: if udg_CargoTransportGroup[udg_UDex] != null then
          • Custom script: call DestroyGroup(udg_CargoTransportGroup[udg_UDex])
          • Custom script: set udg_CargoTransportGroup[udg_UDex] = null
          • Custom script: endif
      • Custom script: endfunction
      • Custom script:
      • Custom script: function CEvFireUnload takes nothing returns nothing
      • Unit Group - Remove UDexUnits[UDex] from CargoTransportGroup[(Custom value of CargoTransportUnit[UDex])]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CEvSpecial[UDex] Equal to True
        • Then - Actions
          • Set CEvSpecial[UDex] = False
          • Set CEvNext[CEvPrev[UDex]] = CEvNext[UDex]
          • Set CEvPrev[CEvNext[UDex]] = CEvPrev[UDex]
          • Set CEvPrev[UDex] = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CEvNext[0] Equal to 0
            • Then - Actions
              • Countdown Timer - Pause CEvUnloadTimer
            • Else - Actions
        • Else - Actions
      • Set CEvBlock[UDex] = True
      • Set CargoEvent = 0.00
      • Set CargoEvent = 2.00
      • Set CargoEvent = 0.00
      • Set CEvBlock[UDex] = False
      • Custom script: if not IsUnitLoaded(udg_UDexUnits[udg_UDex]) or IsUnitType(udg_CargoTransportUnit[udg_UDex], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[udg_UDex]) == 0 then
      • Set CargoTransportUnit[UDex] = No unit
      • Custom script: endif
      • Custom script: endfunction
      • Custom script:
      • Custom script: function DEvOnDeath takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Set UDex = (Custom value of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UDex Not equal to 0
        • Then - Actions
          • Set IsUnitAlive[UDex] = False
          • Set DeathEvent = 0.00
          • Set DeathEvent = 1.00
          • Set DeathEvent = 0.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CargoTransportUnit[UDex] Not equal to No unit
            • Then - Actions
              • Custom script: call CEvFireUnload()
            • Else - Actions
        • Else - Actions
      • Custom script: set udg_UDex = pdex
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function DEvCheckDeath takes nothing returns nothing
      • Set UDex = DEvList[0]
      • Set DEvList[0] = 0
      • Custom script: loop
      • Custom script: exitwhen udg_UDex == 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DEvBlock[UDex] Equal to True
        • Then - Actions
          • Set DEvBlock[UDex] = False
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsUnitAlive[UDex] Equal to True
            • Then - Actions
              • Set IsUnitAlive[UDex] = False
              • Set IsUnitReincarnating[UDex] = True
              • Set DeathEvent = 0.50
              • Set DeathEvent = 0.00
            • Else - Actions
      • Set UDex = DEvList[UDex]
      • Custom script: endloop
      • Custom script: endfunction
      • Custom script:
      • Custom script: function DEvCheckDeathProxy takes nothing returns nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DEvList[0] Equal to 0
        • Then - Actions
          • Custom script: call TimerStart(udg_DEvTimer, 0, false, function DEvCheckDeath)
        • Else - Actions
      • Set DEvList[UDex] = DEvList[0]
      • Set DEvList[0] = UDex
      • Custom script: endfunction
      • Custom script:
      • Custom script: function DEvOnOrder takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Set UDex = (Custom value of (Matching unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UDex Not equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of DEvAbility for UDexUnits[UDex]) Equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DEvRemoved[UDex] Equal to False
                • Then - Actions
                  • Set DEvRemoved[UDex] = True
                  • Set DeathEvent = 0.00
                  • Set DeathEvent = 3.00
                  • Set DeathEvent = 0.00
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • IsUnitAlive[UDex] Equal to False
                • Then - Actions
                  • Set IsUnitAlive[UDex] = True
                  • Set DeathEvent = 0.00
                  • Set DeathEvent = 2.00
                  • Set DeathEvent = 0.00
                  • Set IsUnitReincarnating[UDex] = False
                • Else - Actions
                  • Custom script: if IsUnitType(udg_UDexUnits[udg_UDex], UNIT_TYPE_DEAD) then
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • DEvBlock[UDex] Equal to True
                    • Then - Actions
                      • Set IsUnitAlive[UDex] = False
                      • Set DeathEvent = 0.00
                      • Set DeathEvent = 1.00
                      • Set DeathEvent = 0.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • CEvSpecial[UDex] Equal to True
                          • (UDexUnits[UDex] is A Hero) Equal to True
                        • Then - Actions
                        • Else - Actions
                          • Custom script: call DEvCheckDeathProxy()
                  • Custom script: endif
          • Custom script: if udg_CargoTransportUnit[udg_UDex] != null and not udg_CEvBlock[udg_UDex] and not IsUnitLoaded(udg_UDexUnits[udg_UDex]) or IsUnitType(udg_UDexUnits[udg_UDex], UNIT_TYPE_DEAD) then
          • Custom script: call CEvFireUnload()
          • Custom script: endif
        • Else - Actions
      • Custom script: set udg_UDex = pdex
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function CEvUnloadChecker takes nothing returns nothing
      • Set UDex = CEvNext[0]
      • Custom script: loop
      • Custom script: exitwhen udg_UDex == 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UDexUnits[UDex] is being transported) Equal to False
        • Then - Actions
          • Custom script: call CEvFireUnload()
        • Else - Actions
      • Set UDex = CEvNext[UDex]
      • Custom script: endloop
      • Custom script: endfunction
      • Custom script:
      • Custom script: function CEvStartChecker takes nothing returns nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CEvNext[0] Equal to 0
        • Then - Actions
          • Custom script: call TimerStart(udg_CEvUnloadTimer, 0.03125, true, function CEvUnloadChecker)
        • Else - Actions
      • Set CEvSpecial[UDex] = True
      • Set CEvPrev[CEvNext[0]] = UDex
      • Set CEvNext[UDex] = CEvNext[0]
      • Set CEvNext[0] = UDex
      • Custom script: endfunction
      • Custom script:
      • Custom script: function CEvOnLoad takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Custom script: local integer udg_TempInteger
      • Set UDex = (Custom value of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UDex Not equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CargoTransportUnit[UDex] Not equal to No unit
            • Then - Actions
              • Custom script: call CEvFireUnload()
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsUnitAlive[UDex] Equal to False
            • Then - Actions
              • Custom script: call CEvStartChecker()
            • Else - Actions
          • Set CargoTransportUnit[UDex] = (Transporting unit)
          • Set TempInteger = (Custom value of CargoTransportUnit[UDex])
          • Custom script: if udg_CargoTransportGroup[udg_TempInteger] == null then
          • Custom script: set udg_CargoTransportGroup[udg_TempInteger] = CreateGroup()
          • Custom script: endif
          • Unit Group - Add UDexUnits[UDex] to CargoTransportGroup[TempInteger]
          • Set CargoEvent = 0.00
          • Set CargoEvent = 1.00
          • Set CargoEvent = 0.00
        • Else - Actions
      • Custom script: set udg_UDex = pdex
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function CEvOnPause takes nothing returns boolean
      • Custom script: local integer pdex = udg_UDex
      • Set UDex = (Custom value of (Matching unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UDexUnits[UDex] is paused) Equal to True
          • CargoTransportUnit[UDex] Not equal to No unit
          • CEvSpecial[UDex] Equal to False
        • Then - Actions
          • Custom script: call CEvStartChecker()
        • Else - Actions
      • Custom script: set udg_UDex = pdex
      • Custom script: return false
      • Custom script: endfunction
      • Custom script:
      • Custom script: function InitDeathEvent takes nothing returns nothing
      • Custom script: local integer i = 15
      • Custom script: local player p
      • Custom script: local trigger d = CreateTrigger()
      • Custom script: local trigger l = CreateTrigger()
      • Custom script: local trigger t = GetTriggeringTrigger()
      • Custom script: local boolexpr o = Filter(function DEvOnOrder)
      • Custom script: local boolexpr u = Filter(function CEvOnPause)
      • Custom script: call TriggerAddCondition(d, Filter(function DEvOnDeath))
      • Custom script: call TriggerAddCondition(l, Filter(function CEvOnLoad))
      • Custom script: loop
      • Custom script: set p = Player(i)
      • Custom script: call SetPlayerAbilityAvailable(p, udg_DEvAbility, false)
      • Custom script: call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, o)
      • Custom script: call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, u)
      • Custom script: call TriggerRegisterPlayerUnitEvent(d, p, EVENT_PLAYER_UNIT_DEATH, null)
      • Custom script: call TriggerRegisterPlayerUnitEvent(l, p, EVENT_PLAYER_UNIT_LOADED, null)
      • Custom script: exitwhen i == 0
      • Custom script: set i = i - 1
      • Custom script: endloop
      • Custom script: set d = null
      • Custom script: set l = null
      • Custom script: set o = null
      • Custom script: set p = null
      • Custom script: set t = null
      • Custom script: set u = null
      • Custom script: call DestroyGroup(udg_CargoTransportGroup[0])
      • Custom script: set udg_CargoTransportGroup[0] = null
 
Last edited:
Status
Not open for further replies.
Top