CP - Alien Breed Remake - 7

Miscellaneous Forums/Blitz Showcase/CP - Alien Breed Remake - 7

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How about this:

We have a single object definition file which is used as the palette for the editor. This includes self-contained generic objects, where the ID is simply stamped on the map object layer, and picked up and run in game (as currently).

However, it also includes specially tagged 'template' objects. These appear in the editor palette for placement on the map, but when placed create a new object in a new level.obj file, with a new ID (from a fixed starting ID, e.g. 100). All properties are copied over from the template to the new object. These properties can then be edited by selecting the item on the map (MMB?). You can then make the sxcript do what you want. the assigning of the ID, creation of a copy in the level.obj, and stamping of the new ID on the map location are all handled by the editor.

For example, we define a template switch object. We could include script in the template to opendoor(x,y). On placing the switch on the map, you then open up that instance of the object script and change x,y to the correct door location.

The main game then loads the generic objects in all instances (although template object IDs never actually get used). If a level has a specific object file defined, that gets loaded too. The appropriate script can then be run for each object.

This sorts out switches opening doors, etc. What it doesn't really do is sort out interdependencies between objects. I'm thinking the most flexible approach here might be some script commands like setvar(<variablename>,<value>) and checkvar(<variable>,<value>).

So, if we have three switches, of which 1+3 must be on and 2 off to open a door, each switch includes "setvar(switchN,on)|checkvar(switch1,on)|checkvar(switch2,off)|checkvar(switch3,on)|opendoor(10,11)" (N=1-3)

However, I've just realised that to make a switch turn on and back off again, and so on, will need some slightly more complex scripting - i.e. if...then constructs. In a format like "If(variable,value,actiontrue,actionfalse)". So the template code for an on/off switch would need to look like:

"if(<switchname>,on,setvar(<switchname>,off)|setimage(23),setvar(<switchname>,on)|setimage(24))"

Where the user is expected to change <switchname> in the script when it is placed. (We could even be clever and prompt for these...). The bit of script to run on flicking the switch could then either exist in the 'true' part of the above template if it's just dependent on that switch, or after the If block if we want to check a whole bunch of other vars too. So, finally(!) our three switches look like:

if(switch1,on,
  setvar(switch1,off)|setimage(23),
  setvar(switch1,on)|setimage(24))|
checkvar(switch1,on)|
checkvar(switch2,off)|
checkvar(switch3,on)|
opendoor(10,11)


Does that make any sense? ;-)