- Joined
- Sep 1, 2024
- Messages
- 8
Trigger text:
UPDATE: It seems that it was the event itself that leaks. I tested by disabling the above trigger and create a new one:
-
Periodically forcing units to pick up nearby items
-

Events
-


Time - Every 0.01 seconds of game time
-
-

Conditions
-

Actions
-


-------- The AI doesn't take advantage of the added ability of non-hero unit to use items. Therefore, this trigger is necessary to force computer-controlled units to pick the items up. --------
-


Item - Pick every item in PlayableMapArea and do (Actions)
-



Loop - Actions
-




Set CurrentItem = (Picked item)
-




Set CurrentItemLocation = (Position of CurrentItem)
-




Player Group - Pick every player in AllComputerPlayer and do (Actions)
-





Loop - Actions
-






Set CurrentPlayer = (Picked player)
-






Set CurrentUnitGroup = (Units within 500.00 of CurrentItemLocation)
-






-------- If there is a hero with a spare item slot, the computer AI should automatically order that hero to pick up items on the ground, no needs to interfere --------
-






-------- We prefer non-interference because interference cause the unit to acts stupid in combat situation: It would be torn between the AI's order to fight and this trigger's order to pick up item, resulting in a useless unit. --------
-






Set HeroWithSpareItemSlotIsNearby = False
-






-------- Remove unqualified units from CurrentUnitGroup. And if a qualified unit is found to be a hero with spare item slot, set the corresponding boolean variable to True. --------
-






Unit Group - Pick every unit in CurrentUnitGroup and do (Actions)
-







Loop - Actions
-








Set CurrentUnit = (Picked unit)
-








If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-









If - Conditions
-










Or - Any (Conditions) are true
-











Conditions
-












(Number of items carried by CurrentUnit) Equal to (Size of inventory for CurrentUnit)
-












(Owner of CurrentUnit) Not equal to CurrentPlayer
-
-
-
-









Then - Actions
-










Unit Group - Remove CurrentUnit from CurrentUnitGroup
-
-









Else - Actions
-










If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-











If - Conditions
-












(CurrentUnit is A Hero) Equal to True
-
-











Then - Actions
-












Set HeroWithSpareItemSlotIsNearby = True
-
-











Else - Actions
-
-
-
-








Set CurrentUnit = No unit
-
-
-






If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-







If - Conditions
-








HeroWithSpareItemSlotIsNearby Equal to False
-
-







Then - Actions
-








Unit Group - Pick every unit in CurrentUnitGroup and do (Actions)
-









Loop - Actions
-










Unit - Order (Picked unit) to Right-Click CurrentItem
-
-
-
-







Else - Actions
-
-






Set CurrentPlayer = Neutral Extra
-






Custom script: call DestroyGroup(udg_CurrentUnitGroup)
-






Set HeroWithSpareItemSlotIsNearby = False
-
-
-




Set CurrentItem = No item
-




Custom script: call RemoveLocation(udg_CurrentItemLocation)
-
-
-
-
AllComputerPlayer and PlayableMapArea is a "static" variable that is initialized once:-
Initialize Objects
-

Events
-


Map initialization
-
-

Conditions
-

Actions
-


Set AllComputerPlayer = (All players controlled by a Computer player)
-


Set PlayableMapArea = (Playable map area)
-


Custom script: call DestroyTrigger(GetTriggeringTrigger())
-
-
Custom script: set bj_wantDestroyGroup = true.UPDATE: It seems that it was the event itself that leaks. I tested by disabling the above trigger and create a new one:
-
Periodically doing nothing
-

Events
-


Time - Every 0.01 seconds of game time
-
-

Conditions
-

Actions
-


-------- do nothing --------
-
-
Last edited:

