MoeTheCamel
Chieftain
- Joined
- Sep 28, 2017
- Messages
- 11
I've gotten into Lua modding recently and so far I've gotten to grips with getting playerIDs and unitIDs and converting them into variables that I can use with the inbuilt functions. I can add dummy buildings and policies pretty easily now but I'm unable to figure out how to check which plot a unit is on, or how to convert a plotID (something like 5E7D7290) into an x,y coordinate which I can use with Unit.SetXY().
I'm hoping if I can figure out those then I can make a ship which will essentially pull a unit towards it after doing a ranged attack, kind of the opposite of what the Winged Hussar does. My plan is to get the plot coordinates of the two units involved in the combat and then use some calculation to find the plot in between them, check whether it's water then if it is move the attacked unit into it (the way the hex grid works means that sometimes there will be two possible plots which are between the units so i'd just pick one at random).
I'd also like to have two different units which give combat bonuses to any adjacent units of the other type, basically meaning that you would need an alternating wall of these units to get the most out of them. Again, I feel like knowing the plot coordinate of one of the units and checking the surrounding plots is a decent way to approach this but if there is an easier way to check adjacent tiles then I'd love to know.
I'm hoping if I can figure out those then I can make a ship which will essentially pull a unit towards it after doing a ranged attack, kind of the opposite of what the Winged Hussar does. My plan is to get the plot coordinates of the two units involved in the combat and then use some calculation to find the plot in between them, check whether it's water then if it is move the attacked unit into it (the way the hex grid works means that sometimes there will be two possible plots which are between the units so i'd just pick one at random).
I'd also like to have two different units which give combat bonuses to any adjacent units of the other type, basically meaning that you would need an alternating wall of these units to get the most out of them. Again, I feel like knowing the plot coordinate of one of the units and checking the surrounding plots is a decent way to approach this but if there is an easier way to check adjacent tiles then I'd love to know.