- Joined
- Apr 4, 2022
- Messages
- 13
Hello everybody, I'm having a little bug on one of my latest trigger and i'm out of ideas so I come here seeking help and knowledge.
I'm new here tell me if i mess up !
I've been developping a pirates themed map for a bit of time and I am trying to build a market system where in the init of the map, each market would be assigned 5 random tradeable items out of 15 initialized in the tradeable goods list (each picked item class is put at the end of the list, and the limit is length-a to ensure uniqueness), then one is randomly picked as the cheap good (the offer) and another one is picked randomly from the 1 to 15 items of the tradeable goods list (to ensure they are not sold there, and become the Demand) and dummy abilities tooltip are filed to display offer and demand to the player. here is the code :
Thanks you for your time !
I'm new here tell me if i mess up !
I've been developping a pirates themed map for a bit of time and I am trying to build a market system where in the init of the map, each market would be assigned 5 random tradeable items out of 15 initialized in the tradeable goods list (each picked item class is put at the end of the list, and the limit is length-a to ensure uniqueness), then one is randomly picked as the cheap good (the offer) and another one is picked randomly from the 1 to 15 items of the tradeable goods list (to ensure they are not sold there, and become the Demand) and dummy abilities tooltip are filed to display offer and demand to the player. here is the code :
-
-------- ---------------------------------------- --------
-
-------- Init tradeable good list --------
-
-------- ---------------------------------------- --------
-
Set VariableSet tradeableGoods[1] = Beer Keg
-
Set VariableSet tradeableGoods[2] = Chocolate
-
Set VariableSet tradeableGoods[3] = Coffee
-
Set VariableSet tradeableGoods[4] = Ebony
-
Set VariableSet tradeableGoods[5] = Flax
-
Set VariableSet tradeableGoods[6] = Furs
-
Set VariableSet tradeableGoods[7] = Gold
-
Set VariableSet tradeableGoods[8] = Mahogany
-
Set VariableSet tradeableGoods[9] = Rum
-
Set VariableSet tradeableGoods[10] = Silk
-
Set VariableSet tradeableGoods[11] = Silver
-
Set VariableSet tradeableGoods[12] = Spices
-
Set VariableSet tradeableGoods[13] = Sugar
-
Set VariableSet tradeableGoods[14] = Tobacco
-
Set VariableSet tradeableGoods[15] = Whale oil
-
-------- ---------------------------------------- --------
-
-------- Init markets --------
-
-------- ---------------------------------------- --------
-
Set VariableSet Markets = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Market))
-
Unit Group - Pick every unit in Markets and do (Actions)
-
Loop - Actions
-
-------- ---------------------------------------- --------
-
-------- init sold items --------
-
-------- ---------------------------------------- --------
-
For each (Integer A) from 1 to 5, do (Actions)
-
Loop - Actions
-
Set VariableSet itemTypeTempId = (Random integer number between 1 and (16 - (Integer A)))
-
Set VariableSet itemTypeTemp = tradeableGoods[itemTypeTempId]
-
Neutral Building - Add itemTypeTemp to (Picked unit) with 1 in stock and a max stock of 10
-
Set VariableSet tradeableGoods[itemTypeTempId] = tradeableGoods[(16 - (Integer A))]
-
Set VariableSet tradeableGoods[(16 - (Integer A))] = itemTypeTemp
-
Set VariableSet itemTypeTempList[(Integer A)] = itemTypeTemp
-
-
-
-------- ---------------------------------------- --------
-
-------- init good in surplus --------
-
-------- ---------------------------------------- --------
-
Set VariableSet itemTypeTemp = itemTypeTempList[(Random integer number between 1 and 5)]
-
Set VariableSet itemTemp = (Random item in initItems <gen> matching ((Item-type of (Matching item)) Equal to itemTypeTemp))
-
Ability - Set Tooltip of Offer to (Offer : + (Name of itemTemp)) for level marketNumber
-
Ability - Set Extended Tooltip of Offer to (Description of itemTemp) for level marketNumber
-
Unit - Set level of Offer for (Picked unit) to marketNumber
-
-------- ---------------------------------------- --------
-
-------- init wanted goods --------
-
-------- ---------------------------------------- --------
-
Set VariableSet itemTypeTemp = tradeableGoods[(Random integer number between 1 and 10)]
-
Set VariableSet itemTemp = (Random item in initItems <gen> matching ((Item-type of (Matching item)) Equal to itemTypeTemp))
-
Ability - Set Tooltip of Demand to (Demand : + (Name of itemTemp)) for level marketNumber
-
Ability - Set Extended Tooltip of Demand to (Description of itemTemp) for level marketNumber
-
Unit - Set level of Demand for (Picked unit) to marketNumber
-
Set VariableSet marketNumber = (marketNumber + 1)
-
-
Thanks you for your time !
Last edited: