I am currently trying to develop a trade caravan system for my civilization style map, right now I got the caravan to work in a way however I want to try and create a system similar to how I would back in warcraft 3.
Here is a run down of what I want to happen:
I have a trade caravan and 2 markets. One market belongs to me, the other belongs to another player.
I order the trade caravan to purchase a product from the other players market.
After that I order the trade caravan to sell the product at my market.
Resources are given to the player(s) depending on the distance between the markets.
After all this is done, the Caravan now knows the route, so it will go and do the trade route again, and repeat this route until I tell it to stop.
This is what I want to have happen, so I already have the abilities that serve their function for targetting the markets so now I need a way of storing the markets as variables on the caravan so it can remember where and what it interacted with, so the resources can be calculated correctly, and so the route can be remembered.
Back in warcraft 3, I remember there was a way using Gamecache's I think, to store handles on other handles and name them with strings. I want to know if someone knows another way of doing this on the Starcraft 2 editor.
Basically when I order the caravan to purchase the product from player 2's market, I want the caravan to have a stored unit variable of that players market, named "TargetMarket" or however it works. Then when it returns to my market with the product, it will store my market as "HomeMarket"
Then the trigger will just order it to do the purchase ability on "TargetMarket", then use the sell ability on "HomeMarket" and continue doing this until the caravan is given another order.
So, does anybody have a clue of what I'm talking about? Because I'm not sure what the technical name is for something like this, because to me, it just seemed like setting local variables to units that could be used whenever I referenced that unit.
@Zackreaver:
What you are asking is well beyond my knowledge, but browsing the actions tab, i saw "Bank" as an option and the description sounds a little like the gamecashes u mentioned in your post, also noticed the data table tab references the bank as well. hope this helps even just a little.
If you have a maximum number of caravans, I would use a global array of structs that contain all the variables needed. You could then set a custom value of the caravan unit to point to the index in the array that belongs to that caravan.
If you have no maximum number of caravans, you can just use the data table to implement a dynamic struct array.
What you are asking is well beyond my knowledge, but browsing the actions tab, i saw "Bank" as an option and the description sounds a little like the gamecashes u mentioned in your post, also noticed the data table tab references the bank as well. hope this helps even just a little.
The bank actually does seem similar, I'll have to reference the old code I used in my warcraft 3 maps to see if I can reformat them into what is used here in starcraft 2. However the code wasn't designed by me originally, I was utilizing code provided by another, so this could take some time.
If you have a maximum number of caravans, I would use a global array of structs that contain all the variables needed. You could then set a custom value of the caravan unit to point to the index in the array that belongs to that caravan.
If you have no maximum number of caravans, you can just use the data table to implement a dynamic struct array.
Warcraft 3 held a much simpler method of handling this kind of system, I doubt I would have to resort to a method like this. I'm certain there's a way to store variables locally on units, I'm going to look at the bank section deeper.
by obtaining this value, I can now create bank strings that are unique to the ID given, since each unit has it's own unique ID, if I were to say create zergling and it has ID 300, if I create a bank value that uses the unit ID with the word ZerglingExplode tagged onto it, it will only work when that zergling's ID is called.
Fascinating.
I'll get back to you all once I finish converting my old warcraft 3 code into this map.
Gah, yes the unique ID's are there, but I appear to have forgotten that TypeCasting doesn't exist in starcraft 2 (thankfully), and the bank's only load the unit's onto the field, not as a variable.
However maybe I can find a way to put data table's to use in this particular sense.
Once again, i'll get back once I find this out.
Edit: Well it seem's like Datatable's might work just fine, datatables only have 1 name but we can mix the unit's ID with a custom string to act as the key.
Well I guess this serves quite nicely. I'll come back when I'm successful.
I got the trade route working perfectly, when the caravan finish's the route once, it remember's it's route and continue's it over and over and over again. I'll post a youtube video of it later on.
Edit: Here's the youtube video link.
As you can see I got the trade vessel's to automatically continue the trade route after it is established.
I'll post the trigger data I used so people can reference it.
Since 24, 25, or 26 no longer work I can assume blizzard has put something in there. So since there might be further addition's like this I decided to couple the function into single function and changed the integer to something like 9000, that way I never have to worry about them doing this again.
Hello there everyone.
I am currently trying to develop a trade caravan system for my civilization style map, right now I got the caravan to work in a way however I want to try and create a system similar to how I would back in warcraft 3.
Here is a run down of what I want to happen:
I have a trade caravan and 2 markets. One market belongs to me, the other belongs to another player. I order the trade caravan to purchase a product from the other players market. After that I order the trade caravan to sell the product at my market. Resources are given to the player(s) depending on the distance between the markets. After all this is done, the Caravan now knows the route, so it will go and do the trade route again, and repeat this route until I tell it to stop.
This is what I want to have happen, so I already have the abilities that serve their function for targetting the markets so now I need a way of storing the markets as variables on the caravan so it can remember where and what it interacted with, so the resources can be calculated correctly, and so the route can be remembered.
Back in warcraft 3, I remember there was a way using Gamecache's I think, to store handles on other handles and name them with strings. I want to know if someone knows another way of doing this on the Starcraft 2 editor.
Basically when I order the caravan to purchase the product from player 2's market, I want the caravan to have a stored unit variable of that players market, named "TargetMarket" or however it works. Then when it returns to my market with the product, it will store my market as "HomeMarket"
Then the trigger will just order it to do the purchase ability on "TargetMarket", then use the sell ability on "HomeMarket" and continue doing this until the caravan is given another order.
So, does anybody have a clue of what I'm talking about? Because I'm not sure what the technical name is for something like this, because to me, it just seemed like setting local variables to units that could be used whenever I referenced that unit.
If you have a maximum number of caravans, I would use a global array of structs that contain all the variables needed. You could then set a custom value of the caravan unit to point to the index in the array that belongs to that caravan.
If you have no maximum number of caravans, you can just use the data table to implement a dynamic struct array.
The bank actually does seem similar, I'll have to reference the old code I used in my warcraft 3 maps to see if I can reformat them into what is used here in starcraft 2. However the code wasn't designed by me originally, I was utilizing code provided by another, so this could take some time.
Warcraft 3 held a much simpler method of handling this kind of system, I doubt I would have to resort to a method like this. I'm certain there's a way to store variables locally on units, I'm going to look at the bank section deeper.
I found out what I needed, the Unique ID's that are tagged on to every unit upon creation.
lv_test = UnitGetPropertyInt(lv_tU, 24, c_unitPropCurrent);
by obtaining this value, I can now create bank strings that are unique to the ID given, since each unit has it's own unique ID, if I were to say create zergling and it has ID 300, if I create a bank value that uses the unit ID with the word ZerglingExplode tagged onto it, it will only work when that zergling's ID is called.
Fascinating.
I'll get back to you all once I finish converting my old warcraft 3 code into this map.
Interesting find there. Interesting. We can make indexing systems again, at least for units.
@s3rius: Go
Gah, yes the unique ID's are there, but I appear to have forgotten that TypeCasting doesn't exist in starcraft 2 (thankfully), and the bank's only load the unit's onto the field, not as a variable.
However maybe I can find a way to put data table's to use in this particular sense.
Once again, i'll get back once I find this out.
Edit: Well it seem's like Datatable's might work just fine, datatables only have 1 name but we can mix the unit's ID with a custom string to act as the key.
Well I guess this serves quite nicely. I'll come back when I'm successful.
IT WORKS!!!!
I got the trade route working perfectly, when the caravan finish's the route once, it remember's it's route and continue's it over and over and over again. I'll post a youtube video of it later on.
Edit: Here's the youtube video link.
As you can see I got the trade vessel's to automatically continue the trade route after it is established.
I'll post the trigger data I used so people can reference it.
Here is the Trigger Data, I have it divided into 2 triggers, one for Purchase Product, and the other for Sell Product.
Ok new problem has come...
It must have been in a patch blizzard made, because the UnitGetPropertyInt function is no longer giving unique ID's anymore.
What the hell blizzard, gonna change something this important and not tell us?
I'm going to look into it because this completely destroyed my trade system.
Edit: Found it, after reading this http://us.battle.net/sc2/en/forum/topic/374938704?page=2 It turns out it's not just 24, but anything 24 and above will give unique ID's
Since 24, 25, or 26 no longer work I can assume blizzard has put something in there. So since there might be further addition's like this I decided to couple the function into single function and changed the integer to something like 9000, that way I never have to worry about them doing this again.