SEVERANCE, BLADE OF DARKNESS

Prospero's pages

Updated October 24, 2005

HOME PAGEAUTHORS > PROSPERO > BOD PYTHON SCRIPTING (14)

 

Tut14. Gates

Unlike Doors, opening Gates use a movable object rather than a sliding sector. You can use any object for this purpose, but practically all the RAS gates use the
"Rastrillo". (There are various flavours.). I'll stick to using this object in this tut.

Use the EBrowser to place the Rastrillo in the closed position in you doorway. It is up to you if you want to make a channel in the doorway for the gate to slide into. It will happily slide into a solid wall but it looks more convincing if it has a channel. Save the position/orientation in a temporary file.

You can put all your gates in the same file as
Doors. First make some clanky-type sounds:


snd_slidegate=Sounds.CreateEntitySound("..\\..\\Sounds\\rastrillo.wav", "GateSlideSound")
snd_slidegate.MaxDistance=20000
snd_slidegate.MinDistance=2000

snd_hitgate=Sounds.CreateEntitySound("..\\..\\Sounds\\golpe-metal-mediano.wav", "GateHitSound")
snd_hitgate.MaxDistance=20000
snd_hitgate.MinDistance=2000

#then create the gate:
gate1=Bladex.CreateEntity("Gate1","Rastrillo10",2000,-3000,8000,"Physic")
gate1.Scale=1.0
gate1.Orientation=0.5,0.5,-0.5,0.5

# take the Position/Orientation/Scale from the temp file you saved with EBrowser
gate1.Frozen=1 # dunno what this is for
gate1=Sparks.SetMetalSparkling(gate1.Name)# This makes sparks if you hit the gate.
gate1din=Objects.CreateDinamicObject(gate1.Name)# Assigns data to handle moving.




You now need a couple of functions in DefFuncs.py:


def OpenGate(gate,d1=2200,d2=600):
    displacement=(d1,d2)
    vectors=(0.0,-1.0,0.0),(0.0,-1.0,0.0)
    vel_init=(500,2000)
    vel_fin=(2000,500)
    whilesnd=(snd_slidegate,snd_slidegate)
    endsnd=("",snd_hitgate)
    Objects.NDisplaceObject(gate,displacement,vectors,vel_init,vel_fin,(),whilesnd,endsnd)

def CloseGate(gate,d1=2200,d2=600):
    displacement=(d1,d2)
    vectors=(0.0,1.0,0.0),(0.0,1.0,0.0)
    vel_init=(500,2000)
    vel_fin=(2000,500)
    whilesnd=(snd_slidegate,snd_slidegate)
    endsnd=("",snd_hitgate)
    Objects.NDisplaceObject(gate,displacement,vectors,vel_init,vel_fin,(),whilesnd,endsnd)


These functions will handle all your gates. I have put in default args for the distance of travel. These should wotk fine for the majority of gates but if you have an extra big one you can pass args in the function call to alter them for that particular gate.

You can use a lever to open in the same manner as doors, but you must tell the functions which gate you want to open:

gate1lvr.OnTurnOnFunc=OpenGate
gate1lvr.OnTurnOnArgs=(gate1din,)
gate1lvr.OnTurnOffFunc=CloseGate
gate1lvr.OnTurnOffArgs=(gate1din,)


to alter the displacement use:

gate1.OnTurnOnArgs=(gate1din,3000,600,)# adjust values until it moves far enough.

For other different objects you can make other functions based on these, customised to the object in question.

Locks.

Locks work like levers, but you need a KEY.

First, pick one of the lock plates and position it with the EBrowser.
Generate script to a temp file.

Create lock with this code:

#make the key first

gate1key=Bladex.CreateEntity("Gate1Key","Llavecutre",4000,-500,-78000,"Physic")
gate1key.Scale=1
gate1key.Orientation=0.5,0.25,-0.825,0.0
darfuncs.SetHint(gate1key,"Key") # This name will show onscreen
Stars.Twinkle(gate1key.Name) # this is optional

You can place the key anywhere with EBrowser or give it to an enemy.
If you give it to an enemy, create it at 0,0,0 and omit the Orientation setting. Use 
Actions.TakeObject("NameOfEnemy","NameOf Key")
Bear in mind that the key must be created before the enemy can take it.

#Make the lock
gate1lock=Locks.PlaceLock("Gate1Lock","Cerraduracutre",(-150,-6200,5500),(0.5,0.5,-0.5,0.5),1.6)
gate1lock.key="Gate1Key"
darfuncs.SetHint(gate1lock.obj, "Lock")# put appropiate name here
gate1lock.OnUnLockFunc=OpenGate
gate1lock.OnLockFunc=CloseGate
gate1lock.OnUnLockArgs=(gate1din,)
gate1lock.OnLockArgs=(gate1din,)



Use the settings you saved in the temp file. (Position),(Orientation) The last arg is the Scale. Unlike the Lever code the Scale will have effect.


That about covers the subject.

A word on Elevators.

They work in much the same way as Doors and Gates, except you ride up and down on them. They can be slide sectors or dinamic objects or sometimes a combination of both. You just have to give them greater displacement settings. They can get complicated if you want to be able to 'call' them from different floors, especially if you want them to stop at multiple levels. It can be done but I won't go into all that at the moment.