Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / How to end a level after opening a door (sort of)

Author
Message
Burger
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: New Zealand
Posted: 3rd Jul 2012 06:35 Edited at: 3rd Jul 2012 15:03
Tutorial

I was mucking around with scripts and winzones and found that I couldn't really use a winzone through trigger zones and simply slap the code I needed onto the end of a dooruse script. I was surprised how easy it was to do, but I thought its a usefull little script so I'd share it on the forums. All I did was make use of the "if used" property and plrmoveto action.

For this you'll need to modify dooruse.fpi or any door script, so make a copy of the original (only a little bit needs to be changed, but just always back up original files). In the script all you need to do is add activateifused=1 after the player has opened the door, so the script should be:


Once thats happened, set up you're level with a door in it. Under the doors properties find the "If Used" part. In this field put a simple but unique name for the entity we're going to activate. For simplicity's sake I'm going to call mine bob.

Create the entity "bob" (be sure to keep the name the same as whats referred to in the door) and place it near the door (it doesnt actually have to be near the door, read on). Make sure bob has no other purpose than to transport the player to the next entity and is set to dynamic. So we're also going to need to create another entity, this one for the player to move to. Make sure this entity is dynamic as well. For simplicity's sake I'm going to call mine mary.

Now we're going to have to create a new script, name this one something appropriate, such as "plrmovetomary.fpi". Put this into the script:


Those who have read the ocfpsc guide may recognise this script. In this script if the player is within 1 segment of bob than the player will be transported to mary. The reason we needed the opening of the door to activate bob was stop the player being transported to mary as you come close. So we needed to activate bob to spawn bob, then its effects come into place.

Underneath the properties of bob you need to set Spawn At Start to NO, Max at any time to 1, Number to Spawn to 1, Maximum Spawn to 1. All this means that only one will spawn, and it will spawn when the door activates it. After that, assign your plrmovetomary.fpi script to bob's main AI script.

Place the entity Mary somewhere secluded (only one segment is needed) and place a winzone in that same spot. If you dont what to let the player know you've teleported them somewhere random just for the effect, you could have a dark room or show a black hud. This is optional, but just do note the room you're transported to (where mary is located) is visible for half a second . . . so you might want to consider what I previously mentioned.

The script does work, but if for some reason it doesnt for you check that:

-the dooruse script is correct (does it contain activateifused=1?)
-the name of the entity to be activated is in the "If Used" field of the door, and is spelt the same
-the two entities are a set to dynamic
-check if you've correctly referred to entities in the scripts
-make sure bob's (or the first entity) properties for spawning are correctly set, without these done properly it wont work
-the scripts are correclty linked (new dooruse in door's main, plrmovetomary in bobs main)

Happy Scripting

I'm inspired by my own wise quotes, thank you.
maho76
13
Years of Service
User Offline
Joined: 31st May 2011
Location: universe-hub, playing the flute
Posted: 4th Jul 2012 10:21
nice and easy idea, burger. thanks.

Burger
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: New Zealand
Posted: 5th Jul 2012 01:00
Cool

I'm inspired by my own wise quotes, thank you.
elbow
13
Years of Service
User Offline
Joined: 3rd Dec 2010
Location:
Posted: 5th Jul 2012 09:35
Thanks Burger

Never thought of doing it this way.

Regards

Eugene
Burger
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: New Zealand
Posted: 6th Jul 2012 13:07
Great to see that I can give something back to the forums (after downloading almost anything and everything free . . .)

I'm inspired by my own wise quotes, thank you.

Login to post a reply

Server time is: 2024-11-23 21:49:05
Your offset time is: 2024-11-23 21:49:05