• Welcome to Freedom Reborn Archive.
 

sim city mod

Started by bearded, August 30, 2008, 09:49:46 PM

Previous topic - Next topic

bearded

here's code that generates buildings in certain spots.  i've also got it set up so that when you custom click on a building, certain allies appear to help you fight.
what i'd like to do is be able to set up a building to spawn at certain intervals.  such as every five minutes a policeman will come out of the building_police.  how would i set up a timer for each building like that?
ultimately, i have 2 ideas in mind.  one is a self playing game, where the engine sets up a town with several good guy buildings and several bad guy buildings.  the buildings will spawn characters.  the characters will have 2 goals; defeat opponents, and destroy opposing buildings.  when a building is destroyed, a new building will be generated there based on who destroyed it.  say, if a policeman destroys a shopping mall of zombies, a police station will spawn at that spot.  it will be fun to run it, and see who owns the town.  i think this would make a good danger room style game.
the second idea is very similiar, but with levels set up, so that the bad guy buildings are already in place.  the player has a character, the Engineer, whose only power is to fly around and create buildings that then generate allies.  the building chosen should be based on what the bad guy lairs are.
def GetBuildingList():
return ["building_police", "building_school", "building_guard", "building_temple", "building_tower", "building_bank", "building_diner", "hourglass", "bus_greyhound", "turret_raygun", "turret_carrier", "turret_factory", "building_rundown"]

def RandomBuilding():
buildingList = GetBuildingList()
randMarker = 7
gotoMarker = "hero_7"
building = buildingList.pop(randint(0, len(buildingList)-1))
spawnName = "building_"+`building`
Object_Spawn(building, building, 'hero_7')

bearded

another idea, which i think will be impossible to implement, is for the watch mode, being able to jump in with a pc controlled character whenever the player wants, to turn the tides of darkness.
but how could this be done?  is there a way to script simply hitting a key to spawn a character, even if there are no characters there?

Epimethee

Cool idea! :) FF could certainly use some RTS love.

For spawning in Watch mode: it's possible, as you're going to need a character on the hero squad anyway (the "-----------"). We can't access the keyboard, sadly, but you can either add a custom command to the "------------" tiggot itself (you'd need to right-click on the portrait) or add a FF Trainer marker or somesuch.

bearded

a friend told me i simply need to start a timer with the command that spawns the building. 
sounds simple enough.  but how do i determine that timer stops spawning policemen when that specific building is destroyed?
Quote from: Epimethee on August 31, 2008, 06:07:48 PM
Cool idea! :) FF could certainly use some RTS love.

For spawning in Watch mode: it's possible, as you're going to need a character on the hero squad anyway (the "-----------"). We can't access the keyboard, sadly, but you can either add a custom command to the "------------" tiggot itself (you'd need to right-click on the portrait) or add a FF Trainer marker or somesuch.

and good solution!  thanks.

GogglesPizanno

Quotea friend told me i simply need to start a timer with the command that spawns the building.
sounds simple enough.  but how do i determine that timer stops spawning policemen when that specific building is destroyed?

By my thinking you'd actually call the timer when the building is spawned to start the timer loop.

That timer fires off the spawn character function... and then at the end of that function, calls the timer again. This way each time a character is spawned, a new timer gets fired, creating a loop cycle.

So what you could do is in the character spawn script at the very top, do a check for the building to see if it exists. If it does, continue on with the script (which would spawn the character and set a new timer), other wise break out of the script...

Since it broke out before calling the new timer, it would end the cycle of character spawning.