Re: Special door cog....


[ Follow Ups ] [ Post Followup ] [ The Massassi Temple Message Board ]

Posted by Rishka on April 24, 1998 at 10:49:18:

In Reply to: Special door cog.... posted by Vodo on April 23, 1998 at 18:54:29:

: I need a door cog that would do the following:

: When you hit the switch once, the door would open. The door would not close again until the switch is hit again and the door would not open again until the switch is hit one more time etc.

: Could you please HELP ME!!!!!

: Thanx

Here, use the following cog... just copy & paste. =)


# Jedi Knight Cog Script
#
# 00_DOORSWITCH2.COG
#
# Doors handled by switch - when activated, the doors open. When deactivated, they close...
#
# [Rishka]
#
# (C) 1998 The Massassi Temple. All Rights Reserved


symbols

thing door0 linkid=1
thing door1 linkid=1
thing door2 linkid=1
thing door3 linkid=1

surface switch0 linkid=2
surface switch1 linkid=2

flex movespeed=8.0
flex sleeptime=2.0
flex lightvalue=0.5

sound onSound=set_hi2.wav local
sound offSound=lgclick1.wav local
sound locksound=df_door2-3.wav local

int doorsector local
int numdoors=0 local
int doorstatus=0 local
int movestatus=0 local
int garbage=-1 local
int dummy=0 local

message startup
message activated
message arrived
message blocked

end

# ========================================================================================

code
startup:
if(door0 >= 0) numdoors = numdoors + 1;
if(door1 >= 0) numdoors = numdoors + 1;
if(door2 >= 0) numdoors = numdoors + 1;
if(door3 >= 0) numdoors = numdoors + 1;

doorsector = GetThingSector(door0);
SectorAdjoins(doorsector, 0);
SectorLight(doorsector, lightvalue, 0.0); // add some light to door sector
return;

# ........................................................................................

activated:
if (GetSenderId() == 1)
{
dummy=PlaySoundLocal(locksound, 1, 0, 0);
}
else if (GetSenderId() == 2)
{
if (activated == 0)
{
activated = 1;
garbage = PlaySoundThing(onSound, door0, 0.6, -1, -1, 0); // play activate sound
garbage = setwallcel(switch0, 1);
if (switch1 >= 0) garbage = setwallcel(switch1, 1);
sectoradjoins(doorsector, 1);
call open_doors;
}
else
{
activated = 0;
garbage = PlaySoundThing(offSound, door0, 0.6, -1, -1, 0); // play deactivate sound
garbage = setwallcel(switch0, 0);
if(switch1 >= 0) garbage = setwallcel(switch1, 0);
sectoradjoins(doorsector, 0);
call close_doors;
}
}
return;

# ........................................................................................

blocked:
call open_doors;
return;

# ........................................................................................

open_doors:
movetoframe(door0, 1, movespeed);
if (door1 >= 0) movetoframe(door1, 1, movespeed);
if (door2 >= 0) movetoframe(door2, 1, movespeed);
if (door3 >= 0) movetoframe(door3, 1, movespeed);
return;

close_doors:
movetoframe(door0, 0, movespeed);
if (door1 >= 0) movetoframe(door1, 0, movespeed);
if (door2 >= 0) movetoframe(door2, 0, movespeed);
if (door3 >= 0) movetoframe(door3, 0, movespeed);
return;

end



Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ The Massassi Temple Message Board ]