Movement highlighting

The Great Apple

Big Cheese
Joined
Mar 24, 2002
Messages
3,361
Location
Oxford, England
EDIT: Link added again - I will have another go at it tomorrow.

Being rather bored this afternoon, I decided to write a little script that would highlight every plot a unit could move to when the unit was selected - just a little visual aid for the player.

Unfortunetely I am completely unable to test it... anybody willing to have a go? I'm pretty sure it'll all work - I don't think the method I use to get movement costs will cheat (it's a built in game function... and the game doesn't cheat).

You'll need python error alerts enabled, as there may be... errors.

The main things I need testing are:
Does it work?
Does it show up at the right times, and not show up at the wrong times?
Does it cheat?
Does it slow down the game at all when highlighting a unit? (This is a possibilty as I have used a very crude method of searching squares)

NOTE: Not quite complete - still need methods to check to see if a unit has bonus' over certain terrains

Thanks in advance to any testers!
 

Attachments

I'll drop it into the Lunar Mod and see what happens, so long as I don't have to combine anything. :)
 
woodelf said:
I'll drop it into the Lunar Mod and see what happens, so long as I don't have to combine anything. :)
As long as the lunar mod isn't using any python events yet you'll be able to do it without combining anything.
 
It didn't overwrite anything so I assume that part went okay. So far it doesn't seem to be working though. :( I'm not noticing anything highlighted. Let me drop it into a different mod and see what happens.
 
Sorry, but nothing showed up in EE3 either and that only had a screen folder in Python so no chance of interference. It's a good idea though...
 
Thanks!

A question:

Do you have python error alerts enabled? If so, then it's something in my logic which is flawed, which should be easy to fix.

I know that the theory should work.
 
The Great Apple said:
Thanks!

A question:

Do you have python error alerts enabled? If so, then it's something in my logic which is flawed, which should be easy to fix.

I know that the theory should work.

How do you do that? Is it defaulted to being enabled?
 
The only error that could be yours is

File "CvGameInterface", line 118 in cannotTrain, but I think that's from the Moon Mod. I don't see any exceptions from files you created.
 
I've updated the first post. Spotted one bug by eye... though I don't know if it was what was causing it - also added something that I didn't think of before.

Now a few messages should pop up as well;

"Movement highlighting activated" should come whenever you click or select a unit.
"Movement highlighting deactivated" should come whenever you haven't actually selected a unit
"Drawing highlights..." should come up when it starts drawing the highlights
"Unit has no moves" should come up if the unit has no moves and is selected
"Plots being picked..." should come up when it starts searching for plots to pick
"Plot movecost = x" should come up for every valid plot found.

Basically, if you select a unit with moves it should go:
"Movement highlighting activated"
"Drawing highlights..."
"Plots being picked..."
"Plot movecost = x"
"Plot movecost = x"
"Plot movecost = x"
"Plot movecost = x"
"Plot movecost = x"
etc.


I think these should all go into the event log when they are triggered but I'm not sure.
 
I'm in class right now and I have work later, but if you need me for anything TGA I'de like to help you out :)
 
Well, first of all, I'm glad someones getting some use out of some part of my spelldemo. About your mod, the first problem is that you had OnUpdate not onUpdate. Python is case sensitive. However, that hasn't totally fixed it - I'm getting only some of the messages and no overlay.

Ok, the problem is that getMoves returns the number of squares the unit has moved, so it returns 0 to begin with, 60 means it has moved 1 square and 120 would mean 2 squares. Try movesLeft.

Next, theres no CyMap.getPlot, you want CyMap.plot

Next, you used g_HighlightActive in onMouseEvent and onUnitSelected without declaring it as a global. I assume a global would work, I just changed it to be a variable on the object.

Now it worked, except that it highlighted every square.

It appears that movementCost doesn't do what you want it to do. It does not look at the distance between the given squares. Also, isRevealed doesn't check for the fog of war, I don't know if that is what you wanted or not.
 
talchas said:
Well, first of all, I'm glad someones getting some use out of some part of my spelldemo. About your mod, the first problem is that you had OnUpdate not onUpdate. Python is case sensitive. However, that hasn't totally fixed it - I'm getting only some of the messages and no overlay.

Ok, the problem is that getMoves returns the number of squares the unit has moved, so it returns 0 to begin with, 60 means it has moved 1 square and 120 would mean 2 squares. Try movesLeft.

Next, theres no CyMap.getPlot, you want CyMap.plot

Next, you used g_HighlightActive in onMouseEvent and onUnitSelected without declaring it as a global. I assume a global would work, I just changed it to be a variable on the object.

Now it worked, except that it highlighted every square.

It appears that movementCost doesn't do what you want it to do. It does not look at the distance between the given squares. Also, isRevealed doesn't check for the fog of war, I don't know if that is what you wanted or not.

I assume he doesn't care about Fog of War. I thought about writing something like this myself, but I'm still confused (haven't spent the time to examine it) by their movement rules. There seem to be two sets of movement numbers. The ones we are used to, and then a much higher granularity system where, it takes 60 movement to go through a plains square and 240 into a hills or something. I don't recall the exact numbers, I've just run across them on occasion. If I get around to decyphering, I'll post if anyone is interesting.

The real reason I posted, though, was to tell Talchas that I for one really loved his Spelldemo mod. It gave me my first taste of what was really possible to mod in Civ4, and I have used it, for instance in doing the display of fuel for the fuel mod, and for exploration buttons in my ruins mod. I mark it as the single most important mod in my learning process for it lead me to the water. My own personal habbits are such that I might have avoided looking at CvMainInterface.py for laziness at figuring out what to do with it without breaking it. The Spelldemo mod cracked it's shell. Having read over that mod very carefully (both the action buttons and display panel changes) has made their entire system much more evident to me, giving me the confidence to attempt pretty much any sort of graphical modification I fancy 8).
 
Right, so just about everything is wrong at the moment... ooops. Thanks for checking it! That getPlot() thing always gets me....

I was hoping movementcost would be a nice shortcut. This means I will have to do a rather long-winded method, which will probably involve working out quite how CIV4RouteInfos.xml works.

Ta.

EDIT: I too am using the spelldemo thingy in with the 40k mod - it just isn't out yet :p
 
Well, if you can figure out how to use it, CySelectionGroup.generatePath and friends should have all that done already. However I just get an error if I try to use it.
 
Back
Top Bottom