Capture the Flag mechanic

sab89

Chieftain
Joined
Mar 6, 2008
Messages
25
Got my map and units taken care of, it's coding I need help with.

When a unit reaches a specific xy, the unit's owner receives a new unit(flag-unit), which spawns at the aforementioned xy.

The flag-unit, a worker-type, can be 'stolen' by other players. When the player moves the flag-unit onto another xy, they receive a point. When a player has received a set amount of points, they win.

Here's what I've got in my Events.py and what I need help with:

I made a variable for defining if the flag was taken. It is set to 0 at start. If the player takes the flag, it turns to 1.

I also made a variable for player scores. Starts at 0 (is added below).

onUnitMove

if the xy is stepped into
if the flagtaken variable = 0
....how do I get the unit's player?

once I have the player, I can then spawn a unit with gc.getPlayer(iOwner or iTeam?).andso-on.

if the xy is stepped into
if the unit stepping into the xy is the flag-unit
I add a point to the player score.

onEndTurn

if player score = 10 or whatever, that player wins.

Are there any mods like this out there?

Thank yous guys.:crazyeye:
 
Need to check this, but I think it will work -

under onUnitMove

gc.getPlayer(pUnit.getOwner()).initUnit(iFlagCarrier, 0, 0, 0, 0)
 
Back
Top Bottom