- Joined
- Nov 30, 2007
- Messages
- 1,202
This is a part from my SupplyCaravan Trigger whats bugging right now is:
1) When it is trying to re-order the failed spell from the ForGroup(failures, u) it detects that the city has mana to provide and picks it up (call IssueTargetOrder(u, "smart", genLastSpellTarget)) however, because of the wait needed to order it away to the other destination it doesn't work. Something with ForGroup, functioncalling and waits are messing it up. So how do I solve that? However, strangely enough: On the second iteration, next periodic trigger it does work.
TBH, the whole thing is a cluster fuck, apart from that they actually miracuasly walk to and from a city. Save me!
I'm thinking a better solution is to actually check every order that the Caravan unit gives and update its status accordingly.
1) When it is trying to re-order the failed spell from the ForGroup(failures, u) it detects that the city has mana to provide and picks it up (call IssueTargetOrder(u, "smart", genLastSpellTarget)) however, because of the wait needed to order it away to the other destination it doesn't work. Something with ForGroup, functioncalling and waits are messing it up. So how do I solve that? However, strangely enough: On the second iteration, next periodic trigger it does work.
JASS:
private function GatherSupplies takes nothing returns nothing
local unit u = genLastSpellCaster
local integer uId = GetUnitUserData(u)
local real cityMana = GetUnitState(genLastSpellTarget, UNIT_STATE_MANA)
if cityMana > 0 then
call IssueTargetOrder(u, "smart", genLastSpellTarget)
set status[uId] = 0
// THIS PART IS BUGGING, when being ordered from the failure group. They only move on the seond period.
call TriggerSleepAction(0.1)
call IssueTargetOrder(u, ORDER_DELIVER, city[cityDest[uId]].u)
else
call BJDebugMsg("failed to gather... added to failures")
call GroupAddUnit(failures, u)
call UnitAddAbility(u, WAITING_GATHER)
set status[uId] = STATUS_W_GATHER
set lastAttemptTarget[uId] = GetUnitUserData(genLastSpellTarget)
endif
set u = null
endfunction
private function ReCheck takes nothing returns nothing
local unit u = GetEnumUnit()
local integer uId = GetUnitUserData(u)
set genLastSpellCaster = u
set genLastSpellTarget = city[lastAttemptTarget[uId]].u
if status[uId] == STATUS_W_GATHER then
call GatherSupplies()
else
call DeliverSupplies()
endif
if status[uId] == 0 then
call GroupRemoveUnit(failures, u)
call UnitRemoveAbility(u, WAITING_GATHER)
call UnitRemoveAbility(u, WAITING_DELIVER)
endif
endfunction
private function Periodic takes nothing returns nothing
call ForGroup(failures, function ReCheck)
endfunction
TBH, the whole thing is a cluster fuck, apart from that they actually miracuasly walk to and from a city. Save me!
I'm thinking a better solution is to actually check every order that the Caravan unit gives and update its status accordingly.
Last edited: