home *** CD-ROM | disk | FTP | other *** search
- # Droids Cog Script
- #
- # D0_skyway.cog
- #
- # Skyways cog
- #
- #
- #
- #
- #
- # [MT]
- #
- #
- # (C) 1997 LucasLearningLimited. All Rights Reserved
-
-
-
- symbols
- message startup
- message activate
- message arrived
- message pulse
- message timer
- message user0 //Countdown is done
- message user1 //Create fake crate
- message user4 //destroy the crate (attached to funky tram)
- message user5 //okay to call another crate
-
- surface adjustswitch linkid=2 //rotates the catapult
- surface destructionfloor0 mask=0x004
- surface destructionfloor1 mask=0x004
- surface destructionfloor2 mask=0x004
- surface fakelever linkid=1 //launches the crate
- surface add_sand linkid=10
- surface rem_sand linkid=4
- surface led_ones nolink
- surface led_tens nolink
- surface led_hund nolink
- surface callregcrate linkid=6
-
- sector destructionsector
- sector curplayersector
- sector ds2
- sector ds3
-
- thing catapult
- thing minecart linkid=3
- thing catapult0
- thing catapult1
- thing catapult2
- thing catapult3
- thing catapult4
- thing catapult5
- thing smallcrate local
- thing player local
- thing createcrateghost
-
- template ADcratetemplate
-
- cog callcratecog
-
- //template explosion_tpl=+grenade_exp
-
- flex md_power=10.0 local
- flex c_dest=10.0 local
- flex sand_inc=5.0 local
- flex payloadweight local
- flex playerweight local
- flex timecount local
- int callcrate=0 local
- int crateisinworld=0 local
- int launch=0 local
- int cratev local
- int step=10 local
- vector catvel local
-
- thing anglecamera
- thing launchcamera
-
- sound t1catlaunch
- sound t1caton
- sound t1catreset
- sound t1catwarmup
- sound texplo01
- sound clicksound
-
- template explosion_tpl=+grenade_exp
- surface CRMface linkid=2
- surface fakeadd_sand1 linkid=10
- surface fakeadd_sand2 linkid=10
- surface fakerem_sand1 linkid=4
- surface fakerem_sand2 linkid=4
- sound switchsound=swt00ltswch1.wav
- sound dave=mcht1ctrsetstp.wav
- end
-
- ## Code Section
- code
- startup:
- setwallcel(callregcrate, 0);
- player=getlocalplayerthing();
- attachthingtothing(minecart, catapult);
- callcrate=0;
- crateisinworld=0;
- launch=0;
- donotlaunch=0;
- md_power=10.0;
- magcrate=0;
- setwallcel(CRMface, 1);
- sleep(3);
- call displayweight;
- setwallcel(fakelever, 1);
- # call user1;
- return;
-
- pulse:
- if ((getthingsector(crate))==destructionsector) {
- print("sorry, no");
- call destroycrate;
- }
- if ((getthingsector(crate))==ds2) {
- print("closer, but no");
- call destroycrate;
- }
- if ((getthingsector(crate))==ds3) {
- print("oh drat. almost there.");
- call destroycrate;
- }
- return;
-
- user4:
- print("it's going well...");
- destroything(crate);
- setpulse(0);
- return;
-
- destroycrate:
- print("destroying crate");
- setpulse(0);
- exsector=getthingsector(crate);
- expos=getthingpos(crate);
- createthingatpos(explosion_tpl, exsector, expos, '0,0,0');
- destroything(crate);
- playsoundpos(tExplo01, expos, 1, -1, 80, 0);
- callcrate=0;
- crateisinworld=0;
- setwallcel(callregcrate, 0);
- return;
-
- user5:
- print("special destroying crate");
- callcrate=0;
- crateisinworld=0;
- setwallcel(callregcrate, 0);
- return;
-
- getpayloadweight:
- if (crateisinworld==1) payloadweight=730;
- return;
-
- arrived:
- //if the mine cart has arrived at the end of the catapult, launch the crate
- if (getsenderid()==3) {
- if (donotlaunch==1) {
- playsoundthing(dave, minecar, 1, -1, -1, 0);
- return;
- }
- playsoundthing(t1catreset, minecar, 1, 10, 20, 0);
- if ((launch==1)&&(crateisinworld==0)&&(getsectorplayercount(curplayersector)!=1)) {
- call launchnothing;
- return;
- }
- launch=1;
- call getpayloadweight;
- if ((getcurframe(catapult))==0) {
- catvel=computecatapultvelocity(payloadweight, catapult0, catapult1, catpower);
- skiptoframe(minecart, 0, 3);
- if (crateisinworld==1) call launchcrate;
- }
- else if ((getcurframe(catapult))==1) {
- skiptoframe(minecart, 2, 3);
- catvel=computecatapultvelocity(payloadweight, catapult2, catapult3, catpower);
- if (crateisinworld==1) call launchcrate;
- }
- else if ((getcurframe(catapult))==2) {
- skiptoframe(minecart, 4, 3);
- catvel=computecatapultvelocity(payloadweight, catapult4, catapult5, catpower);
- if (crateisinworld==1) call launchcrate;
- }
- }
- else if (getsenderref()==catapult) {
- if (getcurframe(catapult)==0) setwallcel(adjustswitch, 0);
- if (getcurframe(catapult)==1) setwallcel(adjustswitch, 1);
- if (getcurframe(catapult)==2) setwallcel(adjustswitch, 2);
- // playsoundthing(t1catadjstop, catapult, 1, -1, -1, 0);
- // stopsound(channel22, 0.5);
- setwallcel(CRMface, 1);
- }
- return;
-
- launchnothing:
- print("launchnothing");
- donotlaunch=1;
- if ((getcurframe(catapult))==0) {
- skiptoframe(minecart, 0, 3);
- }
- else if ((getcurframe(catapult))==1) {
- skiptoframe(minecart, 2, 3);
- }
- else if ((getcurframe(catapult))==2) {
- skiptoframe(minecart, 4, 3);
- }
- return;
-
-
- //launches the minecar
- launchit:
- print("launchitcalled");
- launchchannel=playsoundthing(t1catlaunch, minecar, 1, 10, 20, 0);
- call cameracheck;
- if ((getcurframe(catapult))==0) skiptoframe(minecart, 1, 29.17);
- else if ((getcurframe(catapult))==1) skiptoframe(minecart, 3, 29.17);
- else if ((getcurframe(catapult))==2) skiptoframe(minecart, 5, 29.17);
- stopsound(warmupchannel, 0.5);
- setthingmass(crate, 730);
- return;
-
- cameracheck:
- dwfreezeplayer();
- if (crateisinworld==1) setcamerafocii(2, crate, launchcamera);
- else if (crateisinworld==0) setcamerafocii(2, minecart, launchcamera);
- setcurrentcamera(2);
- setTimerEX(4, 3, 0, 0);
- return;
-
-
- //create the true crate out of thin air
- user1:
- print("creating cType crate");
- crate=creatething(ADcratetemplate, createcrateghost);
- setwallcel(fakelever, 0);
- settimerEX(2, 5, 0, 0);
- return;
-
- activate:
- //start the launch sequence to move the minecar.
- if (getsenderid()==1) {
- if (getwallcel(fakelever)==1) return;
-
- else {
- donotlaunch=0;
- setwallcel(fakelever, 1);
- // sendmessage(countdowncog, user0);
- // settimerEX(6,1,0,0);
- warmupchannel=playsoundthing(t1catwarmup, minecar, 1, 10, 20, 0x1);
- playsoundthing(t1caton, minecar, 1, 10, 20, 0);
- call launchit;
- }
- }
- //move (rotate) the catapult
- else if (getsenderid()==2) {
- if ( (isthingmoving(catapult)!=0)||(isthingmoving(minecar)!=0) ) return;
- else {
- playsoundpos(switchsound, getsurfacecenter(adjustswitch), 1.0, -1, -1, 0);
- setwallcel(CRMface, 0);
- setwallcel(adjustswitch, 1);
- // channel22=playsoundthing(t1catadjloop, catapult, 1.0, -1, -1, 0x1);
- if ((getcurframe(catapult))==0) movetoframe(catapult, 1, 0.3);
- else if ((getcurframe(catapult))==1) movetoframe(catapult, 2, 0.3);
- else if ((getcurframe(catapult))==2) movetoframe(catapult, 0, 0.3);
- call rotatecamera;
- }
- }
- else if (GetSenderId() == 10) call sand_add;
- else if (GetSenderId() == 4) {
- call sand_rem;
- }
- else if ( (getsenderid() ==5)||(getsenderid() ==6) ) {
- if (getwallcel(callregcrate)==1) return;
- playsoundpos(switchsound, getsurfacecenter(callregcrate), 1.0, -1, -1, 0);
- call callcrates;
- }
- return;
-
- rotatecamera:
- dwfreezeplayer();
- setcamerafocii(2, catapult, anglecamera);
- setcurrentcamera(2);
- setTimerEX(4, 3, 0, 0);
- return;
-
- callcrates:
- //bring in a small crate
- setwallcel(callregcrate, 1);
- sendmessage(callcratecog, user1);
- truecratetype=0;
- call nocrates;
- return;
-
- timer:
- if (getsenderid()==2) {
- md_power = md_power + sand_inc;
- if (md_power < step) {
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- md_power = step;
-
- }
- else if (md_power>100) {
- SetWallCel(add_sand,0);
- SetWallCel(rem_sand,0);
- md_power=100;
- }
-
- else if (md_power == c_dest) {
- SetWallCel(add_sand, 0);
- SetWallCel(rem_sand, 0);
- }
-
- else {
- SetTimerEX(0.02,2,0,0);
- }
- call displayweight;
- }
- // else if (getsenderid()==1) {
- // setwallcel(fakelever, 0);
- // }
- else if (getsenderid()==3) {
- setcurrentcamera(7);
- dwunfreezeplayer();
- }
- else if (getsenderid()==5) setthingmass(crate, 730);
- return;
-
- nocrates:
- launch=0;
- callcrate=1;
- crateisinworld=1;
- setwallcel(callsmallcrate,1);
- setwallcel(callbigcrate,1);
- return;
-
- launchcrate:
- print("launching crate");
- print("payload weight is");
- printflex(payloadweight);
- print("catvel is");
- printvector(catvel);
- donotlaunch=1;
- callcrate=0;
- detachthing(crate);
- setthingvel(crate, catvel);
- setwallcel(callsmallcrate,0);
- setwallcel(callbigcrate,0);
- call getpulsetime;
- printflex(pulsetime);
- setpulse(pulsetime);
- print("catpower is ");
- printint(catpower);
- return;
-
- getpulsetime:
- pulsetime=0.25;
- return;
-
-
- sand_add:
- if (GetWallCel(add_sand) != 1) //Nothing's already happening
- {
- SetWallCel(add_sand, 1);
- sand_inc = 1;
- c_dest = md_power + step;
- SetTimerEX(0.02,2,0,0);
- }
- return;
-
- sand_rem:
- if (GetWallCel(rem_sand) != 1) //Nothing's already happening
- {
- SetWallCel(rem_sand, 1);
- sand_inc = -1;
- c_dest = md_power - step;
- SetTimerEX(0.02,2,0,0);
- }
- return;
-
- displayweight:
- playsoundpos(clicksound, getsurfacecenter(led_tens), 0.3, -1, -1, 0);
- SetWallCel(led_ones, md_power % 10);
- SetWallCel(led_tens, (md_power / 10) % 10);
- SetWallCel(led_hund, (md_power / 100) % 10);
- catpower=(md_power/100)*12500;
- return;
-
-
-
-
-
- end
-
-
-
-
-