• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Need some advice creating a ship trade system

Status
Not open for further replies.
Hello again!

I have a design problem in WiF that i need help solving regarding trading ships traveling from port to port as a mean of income.

The idea is, that every x seconds, trade ships would spawn att ports around the map and travel to allied ports.

Now, here's the thing: obviously, having one trade ship from each of your ports travel to each port of all of your allies won't do. Too many ships would spawn.
Instead we had the idea of having the two closest ports of each of your allies send trade ships between eachother. However, you want players who have more ports to recieve more trade deliveries - and besides, it can create complications in situations like the british-american trade, the US starts with ports in france, and somehow, you'd rather want to have the ports in the mainland to be the most relevant ones in this case (aswell as with other places that might be important for trade). You could propably attach a kind of relevance factor to each port, although i still can't seem to wrap my head around how this whole system would be designed!

Any help to get?
 
Level 7
Joined
Apr 1, 2010
Messages
289
bad idea: you could have the user set the ports, that there ports trade with so each port has a port that it trades with.


what you could do is have each port spawn one trade ship which would then go to a random allies port, as long as you have no inland sea this would be pretty easy.
that way if you had 10 ports you would have ten ships 30 ports 30 ships etc.. and it would look pretty cool having trade ships sailing from here to there.
(I would prevent user selection by adding locust then removing it from the trade ships, this would make so that you can still sink them you but you cannot select them.)
you would have to figure how to handle things if after a trade ship has "set sail the port they were headed to is sacked
 
Is that true? Adding and removing locust makes it impossible for you to select it?
Cool, i didn't know that?

As of now, player-set trade routes are not an option. As for the second suggestion, it might turn out awkward - if having more ports simply mean you will send more trade ships, then you don't want to be the one with a lot of ports, you'd rather want that person to be your ally! There is more economical profit from tributing them to him!

No, i'd prefer a system that allows the player with most ports to recieve the most trade ships. The problem is:

1: how is the distribution supposed to be?

2: how will the script choose what ports to send them to?
 
Level 7
Joined
Apr 1, 2010
Messages
289
i thought that your trade ships would give you money from trading with other ports.
the advantage of doing it so that your ships give you money, is you do an auto train for the ships and ships leave at different times.

what you could do is set a group of all of a players trade ports then set a group of all ports belonging to allies and do
  • Unit Group - Pick every unit in (ports owned by player) and do (Actions)
    • Loop - Actions
      • Set AlliedPort = (Random unit from Ports owned by allies)
this will send one trade ship per a players port
 
Well, i more prefer the idea of having the ships be like supply ships, that are delivering to their destination (like, that you are helping your ally through them to simulate the lend-lease pact etc). This would also make it easier to have the option of trade embargos - it just feels much more logical that a player would stop sending ships rather than that the allly would stop recieving them.

And i will not have ships auto-train, rather be spawned through scripting (you want to be able to train other ships at the port), but that's just a minor note. :)
 
Level 7
Joined
Apr 1, 2010
Messages
289
well doing it the way you want it you use this in your spawn trigger
  • Unit Group - Pick every unit in (ports owned by player) and do (Actions)
  • Loop - Actions
  • Set AlliedPort = (Random unit from Ports owned by allies)
  • Set TempPoint = (Unit position of AlliedPort)
  • Unit Create 1 Ship at TempPoint
  • Unit order last created unit to tradewith(a spell that has a cast range of 30) (Picked Unit
this will have allied ports send to your ports. you'd have Player group(or are they called forces?) for each player and have it have all of the allied players.
 
it still doesn't get to the problem:

this way, the ammount of shipments you will recieve is strictly determined by the ammount of ports your ally has, once again.
Also, ports are selected randomly - that means your trade ship can end up being sent to the other side of the world!!

Finally, your example code leaks one group and two locations.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
If your map contains many bodies of water which can have ports, you will need to break it down into trading bodieis which basically function the same but can not interact with each other.

Next you will need to decide how you want ships to behave.
Obviously a mesh network would be a stupid idea as 10 ports with 10 allied ports would make 100 ships, enough to overload the mini move system and cause movement lag.

You could have only 1 ship per dock but that would mean spreading the trade routes. For each trading body you then just pick a random allied port.to depart to and return to a random port. This would function fine and look busy but it could mean obscure ports of an ally slow trade down.

Another way would be to generate a trading power value and then designate ships based on that. The ships then get sent to allied ports, chance based on the allies trading power fraction of whole allied trading pool, where it finds the closest port for that player to the ship. This would be the most predictable as ships would avoid obscure roots but can mean docks get placed and never used.

It all depends on what you want to achive with your map. In all cases making the system using JASS is advisable for efficient running of the system.

You could make the trade system independant on port number so ports are only strategic. "Commercial" buildings provide a trade score based on various quantities (like number of them owned) which is separate for each player. The creation of an allience (allowing trade) initiates a trade route which creates a number of ships and dispatches them on the route. The number of ships created is based on a function of the sum of trade scores for both involved players reduced by a function of the sum of trade complexity for both players. Trade complexity is a penalty value to prevent too many ships which is increased for every trading ally a player has (can be thought of representing oversupply of imports and undersupply of exports). Trade ships are sent from the 2 closest ports between the allied players (might need some units to testrun to find the closest). Trade ships give gold upon reaching a port to both parties involved (import and company taxes). Trade ships are owned by whichever port they are heading to (so swap sides). The gold earned when reaching a port is dependant on the sum of the trading scores of players involved and shared based on the percentage of that sum each player contributed to.
 
@PurplePoot: The issue was not neccesarily of how it should be coded, more of.. how i should do to make ships be sent to ports in a way that makes sense. Dr Super Good got the idea pretty good.

The purpouse of the ship trading system is pretty simple - to make people want control over the seas, and in turn, to trigger naval battles. For this reason, i don't like the idea of strategic ports, since it limits this use quite significantly, especially in cases where for instance the US has ports in france and can use them to trade with britain, rather then having them send over the atlantic ocean.

I still haven't figured it all out, but at least i do know that each port will send one ship each and distribute them to the closest ports of each ally. Perhaps i will prioritize the allies with closest ports, or perhaps i will base it on other things, like the players trade power, or standings towards them (another feature we're using).
I might also use the concept of trade power based on harbour count to solve the issue of who gets most, thank you very much for that suggestion.

Please check out my other thread though, on ship turrets, all help very appreciated.
 
Status
Not open for further replies.
Top