Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 65 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
SOF1 Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Scripting : A Rotating Door With Breakable Glass
Versions: You must be logged in to view history.
Ok for this tutorial we will make a rotating door with breakable glass, something which is impossible without scripting.
A Rotating Door With Breakable Glass

Ok for this tutorial we will make a rotating door with breakable glass, something which is impossible without scripting.

First copy the blank script and rename it to "door". Edit your batch file and change "test" to "door".

All the entities we need are already made in the example map. You will notice that both the "func_wall" and the "func_breakable_brush" both have origin brushes, without these the entities will not rotate properly. It works the same as "func_door". Notice also that the glass origin is the same as the door origin as we want them to rotate together. The trigger_multiple has the "UseKey" checked so the the player has to press the use key to activate the door. You can take this out to make the door open as soon as the player touches it.

As it's a short script I will give to you all in o­ne go and then run through each line. Here it is

#include "../common/header.ds"

output "C:/games/sof/base/ds/test"

////////////

// declare

///////////

local entity door

local entity door_glass

local int sig1

////////////

// assign

///////////

door = find entity with targetname "door1"

door_glass = find entity with targetname "door1_glass"

door.movetype=MOVETYPE_PUSH

door_glass.movetype=MOVETYPE_PUSH

////////////

// action

////////////

label start

play sound "ambient/doors/norm/swing1/opn.wav" for entity door at volume 1 o­n channel CHAN_ENT1

rotate entity door by [0,90,0] at 100 speed

rotate entity door_glass by [0,90,0] signaling sig1 at 100 speed

play sound "ambient/doors/norm/metal/swngrsty1/mid.wav" for entity door at volume 1 o­n channel CHAN_ENT2

wait for all clearing sig1

wait 3 seconds

rotate entity door by [0,-90,0] at 100 speed

rotate entity door_glass by [0,-90,0] signaling sig1 at 100 speed

play sound "ambient/doors/norm/metal/swngrsty1/mid.wav" for entity door at volume 1 o­n channel CHAN_ENT2

wait for all clearing sig1

play sound "ambient/doors/norm/swing1/cls.wav" for entity door at volume 1 o­n channel CHAN_ENT1

suspend

goto start

Note. the play sound ..... o­n channel ... should all be o­n o­ne line.

Ok, you should understand the declare and assign sections. Note that for the door and glass we use "MOVETYPE_PUSH" as we want the door to push the player (solid).

The label start is needed for reusable or repeatable scripts and is a marker to jump to at some point in the script. In our case right at the end.

First we play the open sound and we use "CHAN_ENT1" which is channel 5, if we play all sounds o­n o­ne channel then they will clash and you will not here them all. So we use a different channel for the open, close & the mid sounds.

Next we rotate both the door and the glass 90 degrees in the y plane, looking from the top view in SofRadiant left to right is x, and up / down is y. Notice that we o­nly use the signaling o­n o­ne of the entities, this ensures that they both move together. We also play the opening sound here too.

We then wait for the door to fully open, with the wait for all command. Clearing sig1 for reuse.

We then wait 3 seconds, this is the time the door is fully open, and then close the door and glass by doing a negative rotate.

The last 2 lines are important for reusable scripts, the first o­ne "suspend" halts execution of the script, though it will resume at the next statement when the script is targeted or executed again.

The last line tells the script to jump to our label at the beginning, so in use our script is run, opens & closes the door, halts, when used again jumps back to the beginning, and does this every time it is triggered.

Ok that concludes this set of tutorials, the best thing to help you learn more is to experiment and to examine the example scripts that are from the first level of the game. Don't forget to look at the Scripting Documentation that comes with the SDK as well.

Happy scripting.

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»