Hey all,
By recommendation I have posted this script here for you to use for whatever necessary.
It's a pretty flexible script, so theres quite a few things it can do.
WHAT IT DOES: (in a nutshell)
You link this script to an entity, such as a button or switch
Upon using the button or switch in game, it will spawn the object in its ifused field
Once that object has been spawned it can then go on to spawn a further two objects, enabling the player to spawn three different objects with one switch
I am using this script for my entry in the Xmas puzzle game competition. However you are free to use this in whatever.
THE SCRIPT:
;Artificial Intelligence Script
;Header
desc = Switch for the puzzle game - spawn three different boxes
;Triggers
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecoretextpressentertouse.tga,hudname=useswitchprompt,hudhide=1,hudmake=display,state=10
:plrdistwithin=100:hudshow=useswitchprompt,hudfadeout=useswitchprompt
:state=10,plrdistwithin=100,plrusingaction=1:state=20,setframe=0,plrsound=$0,activateifused=1
:state=20:settargetname=object2,state=25
:state=25:incframe=0
:state=25,frameatend=0:state=30
:state=30,plrusingaction=0:state=35
:state=35:decframe=0
:state=35,frameatstart=0:state=40,setframe=0
:state=40:state=50
:state=50,plrdistwithin=100,plrusingaction=1:state=60,setframe=0,plrsound=$0,activatetarget=1
:state=60:settargetname=object3,state=65
:state=65:incframe=0
:state=65,frameatend=0:state=70
:state=70,plrusingaction=0:state=75
:state=75:decframe=0
:state=75,frameatstart=0:state=80,setframe=0
:state=80:state=90
:state=90,plrdistwithin=100,plrusingaction=1:state=95,setframe=0,plrsound=$0,activatetarget=1
:state=95:incframe=0
:state=95,frameatend=0:state=100
:state=100,plrusingaction=0:state=105
:state=105:decframe=0
:state=105,frameatstart=0:state=110,setframe=0
:state=110:state=0
;End of script
HOW TO USE: (Read carefully!)
1. Create a switch - I wrote this script based around "switch2.fpi", so whether this works on other objects other than those using switch2.fpi is uncertain - please tell me if you find out. I recommend using this on the
liftswitch found in Sci-Fi/Wall furniture for a good starter.
2. Make your three objects. Although the script is easy enough to adapt to allow four, five, six etc. objects to work with a bit of copy/pasting.
In the script I have called the three objects object1 object2 and object3, although if you rename the objects make sure you change it in the script. You may notice object1 isn't referenced in the script...
put the name of the first object in the switch's IFUSED field.
3. Position objects 1, 2, and 3 around your map where you'd like them to appear. Give them these settings in the editor:
Spawn at start: No
Max at any time: 1
Maximum spawn: 1
You can leave everything else. Changing the Max at any time and the Maximum Spawn options as you like them will give some interesting results...I'll leave you to experiment
4. Run the game... and you are done! Upon pressing the switch, first object1 will appear. Pressing it again makes object2 spawn, and a third time will create object3.
Any problems, post them below in this thread, and good luck!
Have a nice day!
~ piXX3D