Movement limit / Ground unit range

cevarez

Chieftain
Joined
Sep 1, 2012
Messages
20
Hi.

I was looking for a mod to limit the unit movement. I´m playing a Earth scenario (made by myself) but i´m tired to fight the chineses roaming in France or Germany grounds. Historical, it´s not accurate.

I found this awesome mod So Far So Close (http://forums.civfanatics.com/showthread.php?t=316958), but it reduce the performance heavily. I´m playing with 45 players in my map.

I was thinking about a new way to limit the unit range (not aerial unit).

The unit will have "supply points" (SP). When the unit moves, one supply point is used. So, if the unit have 6 SP and moves 6 times, the unit dies. The SP is recharged only in cities.

By this way, i think the calculation process could be more quickly than "look" the culture on the So Far So Close mod.

SP would be increased by eras.

Program process:
Example SP=6

- If unit is in city, SP=6.
- If unit moves, SP=6-1 -> SP=5
- If SP=0, unit dies.

Second round
- If unit is in city, CP=6, if not SP=5
- If unit moves, SP=5-1 -> SP=4
- If SP=0, unit dies.


Notice that movement is the maximum displacement of the unit per turn, no matter of the route bonus.


Maybe could be nicer, but there´s a problem; i don´t know how to program it. Some one want to help me?

- Where i need to program? what files?

Thanks.
 
Maybe could be nicer, but there´s a problem; i don´t know how to program it. Some one want to help me?
You don't know how to program it because nobody knows how to do it. Besides I think managing the gameplay aspect of that would be horrible.

I found this awesome mod So Far So Close (http://forums.civfanatics.com/showthread.php?t=316958), but it reduce the performance heavily. I´m playing with 45 players in my map.
I think this is the solution, but for performance reasons the distance would have to be cached.

Do something like this:
Add an unsigned char array of length MAX_PLAYERS to CvPlot, which contain the distance to owned plots.

Make an init function, which sets all plots to 255 for a certain player. Call that for all players at game start or load.

Make the function CvPlot::setDist(int iDist, ePlayer), which sets the distance to iDist for ePlayer if iDist is lower than the current distance. If the distance is lowered for the plot, call setDist(iDist+1, ePlayer) for all surrounding plots. It can ignore all calls where iDist is too high as you don't have to know if the distance is 35 or 38 plots.

Make a set function, which loops the entire map and calls CvPlot::setDist(0, ePlayer) for all plots owned by ePlayer.

In CvUnit::canMoveInto(), check if the cached distance is too high. That is a really quick check and will not hurt performance.

When a player gain ownership of a new plot, call CvPlot::setDist(0, ePlayer) on that plot.

When a player loses ownership, call init for that player and then set. This is a bit slow as it loops all plots twice, but I can't think of a faster approach offhand. At least it only happens when a player loses a plot.

I think that would solve it without hurting performance.
 
Back
Top Bottom