Well it's not trigger killing, but it's is crippling.
This trigger works in tandem with a number of abilities that allow a group of citizens to 'mine' wheat or ore from respective fields (to be improved), while another or other citizens collect the stored items from the storage granary and deposit it in the Town Hall.
The cycle goes like this:
There is a House, a Field, and Storage. A working citizen will use Set Home ability on House, then use Work on Field (all at the behest of Player), the citizen will go into field, animate mining for five seconds than recieve Ore/Wheat for their trouble, they immediately deposit it in random Storage within Range (just found a trigger to get ClosestUnit that I will use).
Then the citizen will go to House, pause, then begin the cycle over again on its own.
Meanwhile, another Citizen will have a Town Centre (Town Hall's have the ability to dub themselves Town Centres) and all he needs to do is use the Collect ability on Storage. Then he'll wait until there's an item, and then he'll grab all the items, and then deposit all the items in the Town Centre.
Problem is, he can grab them fine, but only deposits ONE instead of all items, the loop just kills itself. And there's no wait or anything in it, it's identical to previous loops that work perfectly. Could anyone help with this?
I've included the entire trigger just in case, but the relevant function is under the Collect comment heading, the bottom (third) function set.
Here's the trigger: Look near the bottom for the little loop integer B with the comments PROBLEM around it. That should give you a hint in the right direction. (Continued after trigger)
Maybe it's stuffed up because there's another loop integer in the same trigger, and for some reason me using custom scripts has fluffed it up. ??? I really have no idea.
Also, I realise that the trigger must look a mess, but I've only had one night's study of JASS so am just learning. Puh-lease hulp!
This trigger works in tandem with a number of abilities that allow a group of citizens to 'mine' wheat or ore from respective fields (to be improved), while another or other citizens collect the stored items from the storage granary and deposit it in the Town Hall.
The cycle goes like this:
There is a House, a Field, and Storage. A working citizen will use Set Home ability on House, then use Work on Field (all at the behest of Player), the citizen will go into field, animate mining for five seconds than recieve Ore/Wheat for their trouble, they immediately deposit it in random Storage within Range (just found a trigger to get ClosestUnit that I will use).
Then the citizen will go to House, pause, then begin the cycle over again on its own.
Meanwhile, another Citizen will have a Town Centre (Town Hall's have the ability to dub themselves Town Centres) and all he needs to do is use the Collect ability on Storage. Then he'll wait until there's an item, and then he'll grab all the items, and then deposit all the items in the Town Centre.
Problem is, he can grab them fine, but only deposits ONE instead of all items, the loop just kills itself. And there's no wait or anything in it, it's identical to previous loops that work perfectly. Could anyone help with this?
I've included the entire trigger just in case, but the relevant function is under the Collect comment heading, the bottom (third) function set.
Here's the trigger: Look near the bottom for the little loop integer B with the comments PROBLEM around it. That should give you a hint in the right direction. (Continued after trigger)
-
Villager AI Response
-
Events
- Unit - A unit Begins channeling an ability
- Conditions
-
Actions
- Custom script: local location l= null
- Custom script: local unit farmer= null
- Custom script: local unit storage= null
- Custom script: local unit collector= null
-
-------- Set Home --------
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Ability being cast) Equal to (==) Set Home
- ((Target unit of ability being cast) is A structure) Equal to (==) True
-
Then - Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
-
Loop - Actions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Integer A) Equal to (==) (Player number of (Owner of (Casting unit)))
-
Then - Actions
- Set home[(Integer A)] = (Target unit of ability being cast)
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
-------- Work --------
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Casting unit)) Equal to (==) 0
- (Ability being cast) Equal to (==) Work
-
Then - Actions
- Custom script: set l= GetSpellTargetLoc()
- Custom script: set farmer= GetTriggerUnit()
- Unit - Set the custom value of (Casting unit) to 1
- Animation - Queue (Triggering unit)'s Animation - Stand Work animation
-
Wait until ((((Triggering unit) is in (Units within 70.00 of (Target point of ability being cast))) Equal to (==) True) or ((Custom value of (Triggering unit)) Equal to (==) 0)), checking every 0.10 seconds
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set l= null
- Custom script: set farmer= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display Made it past Wait 1. Modify duration: Add 0.00 seconds and Don't wait
- Unit - Order (Triggering unit) to Hold Position
- Animation - Play (Triggering unit)'s Animation - Stand Work animation
-
Wait 5.00 game-time seconds
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Destructible-type of (Random destructible in (Region centered at (Position of (Triggering unit)) with size (200.00, 200.00)) matching ((Destructible-type of (Matching destructible)) Equal to (==) Wheat))) Equal to (==) Wheat
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display I found some Weet-B.... Modify duration: Add 0.00 seconds and Don't wait
- Hero - Create Weet-Bix and give it to (farmer)
-
Else - Actions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Destructible-type of (Random destructible in (Region centered at (Position of (Casting unit)) with size (200.00, 200.00)) matching ((Destructible-type of (Matching destructible)) Equal to (==) Rock))) Equal to (==) Rock
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display I found a rock!. Modify duration: Add 0.00 seconds and Don't wait
- Hero - Create Ore and give it to (farmer)
-
Else - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display I got nufin. Thanks.... Modify duration: Add 0.00 seconds and Don't wait
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- -------- I recently found out about polled waits. Game-time things are better than real-time. --------
- Animation - Reset (Triggering unit)'s animation
- Unit - Order (Triggering unit) to Move To (Position of (Random unit from (Units within 2000.00 of (Position of (Triggering unit)) matching ((Unit-type of (Matching unit)) Equal to (==) Storage))))
-
Wait until (((Integer((Distance between (Position of (Triggering unit)) and (Position of (Random unit from (Units within 2000.00 of (Position of (Triggering unit)) matching ((Unit-type of (Matching unit)) Equal to (==) Storage))))))) Less than or equal to (<=) 150) or (, checking every 0.10 seconds
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set l= null
- Custom script: set farmer= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display Made it past Wait 2. Modify duration: Add 0.00 seconds and Don't wait
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
- Unit - Order (Triggering unit) to Give (Random unit from (Units within 500.00 of (Position of (Triggering unit)) matching ((Unit-type of (Matching unit)) Equal to (==) Storage))) to (Item carried by (Triggering unit) of type Weet-Bix)
- Unit - Order (Triggering unit) to Give (Random unit from (Units within 500.00 of (Position of (Triggering unit)) matching ((Unit-type of (Matching unit)) Equal to (==) Storage))) to (Item carried by (Casting unit) of type Ore)
-
Loop - Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
- Wait 0.10 game-time seconds
- Unit - Order (Triggering unit) to Move To (Position of home[(Player number of (Owner of (Triggering unit)))])
- Wait until (((Integer((Distance between (Position of (Triggering unit)) and (Position of home[(Player number of (Owner of (Triggering unit)))])))) Less than or equal to (<=) 150) or ((Custom value of (Triggering unit)) Equal to (==) 0)), checking every 0.10 seconds
-
Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display Made it past Wait 3. Modify duration: Add 0.00 seconds and Don't wait
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set l= null
- Custom script: set farmer= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Unit - Order (Triggering unit) to Stop
-
-------- if still don't work, switch to integer b --------
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
- Unit - Order (Triggering unit) to Give home[(Player number of (Owner of (Triggering unit)))] to (Item carried by (Triggering unit) of type Weet-Bix)
- Unit - Order (Triggering unit) to Give home[(Player number of (Owner of (Triggering unit)))] to (Item carried by (Triggering unit) of type Ore)
-
Loop - Actions
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
- Unit - Set the custom value of (farmer) to 0
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display And you are there!. Modify duration: Add 0.00 seconds and Don't wait
- Wait 0.10 game-time seconds
- Unit - Order (Triggering unit) to (Order(absorb)) (l)
- Custom script: set l= null
- Custom script: set farmer= null
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
-------- Collect --------
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
- (Unit-type of (Target unit of ability being cast)) Equal to (==) Storage
- (Ability being cast) Equal to (==) Collect
-
Then - Actions
- Custom script: set storage= GetSpellTargetUnit()
- Custom script: set collector= GetTriggerUnit()
- Unit - Set the custom value of (Triggering unit) to 1
- Cinematic - Send transmission to (All players) from (collector) named Collector: Play No sound and display Hi-ho! Hi-Ho! It's .... Modify duration: Add 0.00 seconds and Don't wait
- Unit - Order (collector) to Stop
- Wait until (((Storage 0296 <gen> has an item of type Weet-Bix) Equal to (==) True) or ((Custom value of (Triggering unit)) Equal to (==) 0)), checking every 0.10 seconds
-
Cinematic - Send transmission to (All players) from (collector) named Collector: Play No sound and display Wait 1 Passed. Modify duration: Add 0.00 seconds and Don't wait
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set storage= null
- Custom script: set collector= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Unit - Order (collector) to Move To (Position of (storage))
- Wait until ((((Triggering unit) is in (Units within 150.00 of (Position of Storage 0296 <gen>))) Equal to (==) True) or ((Custom value of (Triggering unit)) Equal to (==) 0)), checking every 0.10 seconds
-
Cinematic - Send transmission to (All players) from (collector) named Collector: Play No sound and display Wait 2 Passed. Modify duration: Add 0.00 seconds and Don't wait
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Casting unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set storage= null
- Custom script: set collector= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Do Multiple ActionsFor each (Integer A) from 1 to 6, do (Actions)
-
Loop - Actions
- Unit - Order (storage) to Give (Triggering unit) to (Item carried by (storage) in slot (Integer A))
-
Loop - Actions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Wait 0.10 game-time seconds
- Unit - Order (Triggering unit) to Move To (Position of Town_Hall[(Player number of (Owner of (Triggering unit)))])
-
Wait until (((Integer((Distance between (Position of (Triggering unit)) and (Position of Town_Hall[(Player number of (Owner of (Triggering unit)))])))) Less than or equal to (<=) 250) or ((Custom value of (Triggering unit)) Equal to (==) 0)), checking every 0.10 seconds
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) Equal to (==) 0
-
Then - Actions
- Cinematic - Send transmission to (All players) from (farmer) named Bob: Play No sound and display SKIP. Modify duration: Add 0.00 seconds and Don't wait
- Custom script: set storage= null
- Custom script: set collector= null
- Skip remaining actions
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
-------- PROBLEM --------
-
Do Multiple ActionsFor each (Integer B) from 1 to 6, do (Actions)
-
Loop - Actions
- Unit - Order (Triggering unit) to Give Town_Hall[(Player number of (Owner of (Triggering unit)))] to (Item carried by (Triggering unit) in slot (Integer B))
-
Loop - Actions
-
Do Multiple ActionsFor each (Integer B) from 1 to 6, do (Actions)
- -------- PROBLEM --------
- Unit - Set the custom value of (Triggering unit) to 0
- Cinematic - Send transmission to (All players) from (collector) named Collector: Play No sound and display I'm done!. Modify duration: Add 0.00 seconds and Don't wait
- Wait 1.00 game-time seconds
- Custom script: call IssueTargetOrderById( collector, OrderId("harvest"), storage )
- Custom script: set storage= null
- Custom script: set collector= null
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Custom script: set l= null
- Custom script: set farmer= null
- Custom script: set storage= null
- Custom script: set collector= null
-
Events
Maybe it's stuffed up because there's another loop integer in the same trigger, and for some reason me using custom scripts has fluffed it up. ??? I really have no idea.
Also, I realise that the trigger must look a mess, but I've only had one night's study of JASS so am just learning. Puh-lease hulp!