Updated October 24, 2005
HOME PAGE > AUTHORS > 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.
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)
#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,)
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.![]()