home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Classic Fond 52
/
ClassicFond52.iso
/
GAMES
/
DROIDW.RAR
/
DWCD.GOB
/
mission_cog_sy_crane.cog
< prev
next >
Wrap
Text File
|
1998-11-04
|
41KB
|
1,252 lines
# Droids COG Script
#
# SY_Crane.cog
#
# The pulley/incline puzzle cog
#
# Written By: Doug Shannon
# While listening to: All 18 volumes of the Ultra-Lounge
#
# Desc:
# This cog controls a crane that can pick up two different sized girders (large and small)
# and move them between three locations (A, B, and C). In addition, The crane can be docked
# without payload is a 4th position (frame 0). The crane uses 3 different pulley setups to
# help get the job done.
#
# This cog makes extensive use of "AttachThingToThing()" to get things done.
# All moving parts are attached to the crane for left/right movement, handled in the
# "move_crane" routine. For up and down movement, the crane's hook and its rope ghosts
# are attached to one of six "girder ghosts". Each girder tips differently depending
# on what position it's at. Becuase of this, there are six ghosts: one ghost for each girder
# at each location (large girder at A, B, and C; small girder at A, B, and C). There is also
# a ghost used for moving the hook when both the hook and the position it's in is empty.
#
# When a pulley is added into the crane, the previous pulley is removed. The new pulley
# creates all the ropes and attaches the rope's ghosts to either the crane (if they stay
# with the crane when the hook is lowered) or to the hook (if they move with the hook when
# the hook is lowered). This way, when the hook is moved, the ropes and pulleys associated
# with it move as well.
#
# By default the hook is attached to the crane. When the crane moves left and right,
# the hook moves as well, moving the ropes and pulleys. When the hook needs to move up
# and down, the hook is detached from the crane and attached to the appropriate girder ghost.
# This girder ghost is moved, causing the hook to move with it.
#
# The girders, when picked up, get attached to the hook. This way, when the crane moves
# the hook left/right or a girder ghost moves the hook up/down, the girder moves along with
# it. When a girder is getting picked up, it's girder ghost moves (with hook attached) from
# frame 0 to frame 4 (frame 3 in position A). When a girder is getting dropped off, the girder
# ghosts frames are reversed, running from 4 (3 in pos. A) to 0.
#
# precise alignment of frames for the girder ghosts and the crane keep it all in check.
# All the girder ghosts start at the same vertical position (Z: 1.712). They also all
# end at the same position (Z: 1.3). these two positions represent the resting position of
# the hook (1.712 when nothing's hooked on, and 1.3 when a girdered hooked). It is important
# that these vertical positions remain constant across all girder ghosts. This is what
# keeps the hook from sliding a little bit between pickups and drop-offs.
#
# Variables are used to keep track of what's in each position. Pulley_cargo is used to tell
# what object in in the hook's hand. PulleyA_cargo, PulleyB_cargo, and PulleyC_cargo are used
# to tell what's laying on the floor in each area. A value of 0 means the position (or hook)
# is empty. Otherwise, it will equal the thing-reference-number of the thing that's there.
#
# More explanation of this cog can be found in each routine below.
#
# 02/20/98 -D. Shannon
#
# 02/17/98 [DGS] Created
# 02/20/98 [DGS] Finished
#
# ========================================================================================
symbols
message activate
message arrived
message startup
message pulse
message used
message timer
message entered
## ----------------Cogs
## ----------------Things
thing Crane_o linkid=10
thing girder_small_o
thing girder_large_o
## ---------------- Ghost Objects
thing pulley_top_g
thing pulley_bot_g
thing pulley_hook_g
thing smallC_g
thing smallB_g
thing smallA_g
thing largeC_g
thing largeB_g
thing largeA_g
thing pulleyE_g
thing small_g
thing large_g
## ---------------- Rope Ghosts
thing rope1a_g
thing rope1b_g
thing rope2a_g
thing rope2b_g
thing rope3a_g
thing rope3b_g
thing rope4a_g
thing rope4b_g
thing rope5a_g
## ----------------- Templates
template pulley1_t
template pulley2_t
template pulley3_t
template hook_t
## ----------------Surfaces,sectors, & integer surfaces
surface Left_s linkid=2
surface right_s linkid=3
surface lower_s linkid=4
surface return_s linkid=5
sector track_sect linkid=10
int on_s=0 local
##----------------- Object Integers
int pulley_top_i=0 local
int pulley_bot_i=0 local
int pulley_hook_i=0 local
##----------------- Rope Integers
int rope1_i=0 local
int rope2_i=0 local
int rope3_i=0 local
int rope4_i=0 local
# ================== Sounds
sound act_snd=SWT00DrSwtch.WAV local
sound put_snd=SWTt3PutPulley.WAV local
sound move_snd=FLY00Crate1.WAV local
sound start_snd=ELV00tSmllElvSt.WAV local
sound stop_snd=ELV00tSmllElvStp.WAV local
sound lower_snd=FLYt3PulleyLp.WAV local
## ----------------Misc. Vars
int pulleyA_cargo=0 local
int pulleyB_cargo=0 local
int pulleyC_cargo=0 local
int pulley_cargo=0 local
int crane_dir=0 local
flex crane_speed=4.0 local
flex speed_min=3.0 local
flex speed_max=4.0 local
flex pulley_speed=4.0 local
int moving=0 local
int pulley_1_b=28 local
int pulley_2_b=29 local
int pulley_3_b=30 local
int hookthing=0 local
int anim_frame=0 local
int r_color=0 local
int celnum=0 local
int buffer=0 local
int pressed=0 local
flex r_size=0.007 local
int setup=0 local
end
code
//###############################################################################################################################################
startup:
pulleyC_cargo = girder_small_o; //PulleyC_cargo is the variabel that tells this cog what's sitting underneath the crane at pos. C
pulleyB_cargo = 0; // Nothing's at position B
pulleyA_cargo = girder_large_o; //PulleyC_cargo is the variabel that tells this cog what's sitting underneath the crane at pos. A
player = getlocalplayerthing();
//ChangeInv(player, pulley_1_b, 1);
//ChangeInv(player, pulley_3_b, 1); // add pulley 3 to the player's inv
//ChangeInv(player, pulley_2_b, 1); // add pulley 2 to the player's inv
movetoframe(largeC_g,4,1000); // Sets up ghosts so they're where we needs 'em to be.
movetoframe(largeB_g,4,1000);
movetoframe(smallA_g,3,1000);
movetoframe(smallB_g,4,1000);
call update_bins;
call setup_pulley1;
return;
entered:
if (getsenderid() == 10)
{
if (enter_sect == 0)
{
dwPlayCammySpeech(12260, "M1ca051.wav", 10, 0);
enter_sect = 1;
print("Sayline");
}
}
return;
//###############################################################################################################################################
Setup_pulley1:
// This routine is responsible for creating objects for the first pulley setup
garbage = playsoundthing(put_snd,pulley_top_g,1.0,-1,-1,0);
pulley_top_i = creatething(pulley1_t,pulley_top_g); // Crane's top pulley
capturething(pulley_top_i);
pulley_hook_i = creatething(hook_t,pulley_hook_g); // crane's hook
capturething(pulley_hook_i);
rope1_i = addbeam(rope1a_g,pulley_hook_i,147,r_size); // ropes
pullet_bot_i = pulley_top_i;
attachthingtothing(rope1a_g, crane_o);
attachthingtothing(pulley_top_i, crane_o);
//attachthingtothing(pulley_bot_i,pulley_hook_i);
call hook_to_crane; // Attach the hook to the crane 3d0
setup = 1; // Let's the cog know which setup's in place
ChangeInv(player, pulley_1_b, -1);
call update_bins;
return;
//---------------------------------------------------------
takedown_pulley1:
// This removes/deletes all objects for pulley 1.
releasething(pulley_top_i);
releasething(pulley_hook_i);
detachthing(rope1a_g);
removelaser(rope1_i);
destroything(pulley_top_i);
destroything(pulley_hook_i);
setup = 0;
ChangeInv(player, pulley_1_b, 1);
return;
//#############################################################