Where to hook trade units to automate movement?

civictor

Chieftain
Joined
Jul 7, 2006
Messages
65
I am writing a trade automation mod. What I need is to intercept the UI for when the trade convoy or vessel needs to be assigned a route and write code to automatically assign it a route.

I found the UI code for calculating and selecting trade routes. That is not where I need to hook, though.

Can someone point out what module I should hook to do that? I just do not know the naming convention to pick out the module that handles the unit movement queue or whatever it is.
 
For normal units, AFAIK you would use Unit.PushMission to give it MISSION_MOVE_TO, but it looks like trade units use MISSION_ESTABLISH_TRADE_ROUTE instead.

If you need to intercept the call, it looks like you want to intercept GAMEMESSAGE_PUSH_MISSION from Game.SelectionListGameNetMessage.

EDIT: It might be easier to directly edit ChooseInternationalTradeRoutePopup.lua.
 
Thank you for your reply, Nutty. I have checked everywhere and it does not appear there is a good place to intercept trade unit movement in the Lua code. Maybe I missed something. It appears I will need to wait until the DLL is available and find a good hook in the C++ code. If I am wrong, anyone is welcome to give me further guidance.
 
Hmm... I don't think I was thinking clearly when I wrote my earlier post. Have you checked whether Unit.CanStartMission returns false if the trade unit is already in the middle of a trade mission? In which case, you can simply check your trade units every turn to see if they've finished.
 
Back
Top Bottom