- Joined
- Dec 1, 2010
- Messages
- 346
For my trade system, i've started tackling the final part, the loading and unloading of goods into a trade node. For this, i make heavy use of two hashtables also used in my other triggers.
This part of the system should check if a transport ship is in proximitty, then from it's hashtable look for the number transported and the integer of the good transported. Based on that it will check if in the node where the [tradeport] is build there's sufficient resources of the corresponding type, and then deduct those from that node. After deduction, an item corresponding to the resource is added to the ship, and the amount of stacks is set to the 'transportted amount' integer (1-9) from the hashtable.
All of this worked, however when i have two ships, i've noticed that it will take the transported amount of one of the ships for both. dropping off is function correctly but picking up will consistently give this problem when running a trade line with multiple ships.
I've added the map as an attachment Since this is the very last part of a multi trigger system. and testing purposes.
I feel like my issue is with the hashtable setting or sometthing but i can't seem to figure out where this is.
This part of the system should check if a transport ship is in proximitty, then from it's hashtable look for the number transported and the integer of the good transported. Based on that it will check if in the node where the [tradeport] is build there's sufficient resources of the corresponding type, and then deduct those from that node. After deduction, an item corresponding to the resource is added to the ship, and the amount of stacks is set to the 'transportted amount' integer (1-9) from the hashtable.
All of this worked, however when i have two ships, i've noticed that it will take the transported amount of one of the ships for both. dropping off is function correctly but picking up will consistently give this problem when running a trade line with multiple ships.
I've added the map as an attachment Since this is the very last part of a multi trigger system. and testing purposes.
I feel like my issue is with the hashtable setting or sometthing but i can't seem to figure out where this is.
Hashtable [3`]
Slot 0 = Unit ID
Slot 1 = handle of homeport
Slot 2 = Handle of target tradepoint
Slot 3 = Current order integer (0 = No order, 1 = Deliver cargo to target, 2 = Return to homeport)
slot 4 = Player number [owner]
slot 5 = amount transported
slot 6 = tradegood number= (1=wood,2=stone,3=food,...))
Hashtable [1`]
Slot1 = ID
Slott2: Unit type
Slot 3 = Tradenode number
slot 4 = Gold cost
slot 5 = wood cost
slot 6 =
Slot 0 = Unit ID
Slot 1 = handle of homeport
Slot 2 = Handle of target tradepoint
Slot 3 = Current order integer (0 = No order, 1 = Deliver cargo to target, 2 = Return to homeport)
slot 4 = Player number [owner]
slot 5 = amount transported
slot 6 = tradegood number= (1=wood,2=stone,3=food,...))
Hashtable [1`]
Slot1 = ID
Slott2: Unit type
Slot 3 = Tradenode number
slot 4 = Gold cost
slot 5 = wood cost
slot 6 =
-
unload Homeport
-
Events
- Time - Every 0.50 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in tradePorts and do (Actions)
-
Loop - Actions
- Set VariableSet portPos = (Position of (Picked unit))
- Set VariableSet tempUnit = (Picked unit)
-
Unit Group - Pick every unit in (Units within 300.00 of portPos matching ((Unit-type of (Matching unit)) Equal to Transport Ship).) and do (Actions)
-
Loop - Actions
- -------- If tradeship and going to homeport and port in range is homeportt --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Load 3 of (Key (Picked unit).) from hashtable[3].) Equal to 2
- (Load 1 of (Key (Picked unit).) in hashtable[3].) Equal to tempUnit
-
Then - Actions
- Game - Display to (All players) the text: Reached homeport pi...
- -------- Check if tradegood is in stock --------
- -------- wood --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Load 6 of (Key (Picked unit).) from hashtable[3].) Equal to 1
- (Load 5 of (Key (Matching unit).) from hashtable[3].) Less than or equal to wood[(Load 3 of (Key (Load 1 of (Key (Picked unit).) in hashtable[3].).) from hashtable[1].)]
-
Then - Actions
- -------- If wood in stock > needed wood for transport --------
- -------- Set wood to new value --------
- Set VariableSet wood[(Load 3 of (Key (Load 1 of (Key (Picked unit).) in hashtable[3].).) from hashtable[1].)] = (wood[(Load 3 of (Key (Load 1 of (Key (Picked unit).) in hashtable[3].).) from hashtable[1].)] - (Load 5 of (Key (Matching unit).) from hashtable[3].))
- -------- Add item --------
- Hero - Create wood and give it to (Picked unit)
- Item - Set charges remaining in (Last created item) to (Load 5 of (Key (Matching unit).) from hashtable[3].
- Hashtable - Save 1 as 3 of (Key (Picked unit).) in hashtable[3].
-
Else - Actions
- -------- Not enough wood in node --------
- Game - Display to (All players) the text: Not sufficient of s...
-
If - Conditions
- -------- stone --------
- -------- food --------
- Else - Actions
-
If - Conditions
- -------- If tradeship and going to destination port and port in range is destination port --------
- Game - Display to (All players) the text: (String((Load 3 of (Key (Picked unit).) from hashtable[3].)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Load 3 of (Key (Picked unit).) from hashtable[3].) Equal to 1
- (Load 2 of (Key (Picked unit).) in hashtable[3].) Equal to tempUnit
-
Then - Actions
- Game - Display to (All players) the text: Reached Destination...
- Hashtable - Save 0 as 3 of (Key (Picked unit).) in hashtable[3].
- Item - Create (Item-type of (Item carried by (Picked unit) in slot 1)) at (Center of (Playable map area))
- Item - Set charges remaining in (Last created item) to (Charges remaining in (Item carried by (Picked unit) in slot 1))
- Hero - Give (Last created item) to tempUnit
- Item - Remove (Item carried by (Picked unit) in slot 1)
- Hashtable - Save 2 as 3 of (Key (Picked unit).) in hashtable[3].
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
Loop - Actions
-
Unit Group - Pick every unit in tradePorts and do (Actions)
-
Events