home *** CD-ROM | disk | FTP | other *** search
- #
- # CC_Laser.cog
- #
- # Crystal Information Center Laser script
- #
- # 03/24/98 DGS Created.
- #
- #GOAL 0 3 reflect lasers onto crystals
- #GOAL 0 1 contact Jawa on duty
- #GOAL 0 2 view crystal information
- # (C) 1998 Lucas Learning Limited All Rights Reserved
- # ========================================================================================
-
- symbols
- ## ================ Messages
- message Startup
- message activated
- message pulse
- message User0
- message User1
- message timer
- ## ================ Surfaces
- surface Switch0_s linkid=5
- surface Switch1_s linkid=5
- surface Switch2_s linkid=5
- surface Switch3_s linkid=5
- surface Switch4_s linkid=5
- surface Switch5_s linkid=5
- surface crystal_0a_s linkid=7
- surface crystal_0b_s linkid=7
- surface crystal_1a_s linkid=7
- surface crystal_1b_s linkid=7
- surface crystal_3a_s linkid=7
- surface crystal_3b_s linkid=7
- surface crystal_4a_s linkid=7
- surface crystal_4b_s linkid=7
- surface crystal_7a_s linkid=7
- surface crystal_7b_s linkid=7
-
- ## ================ Sectorz
- sector crystal_0a_z
- sector crystal_0b_z
- sector crystal_1a_z
- sector crystal_1b_z
- sector crystal_3a_z
- sector crystal_3b_z
- sector crystal_4a_z
- sector crystal_4b_z
- sector crystal_7a_z
- sector crystal_7b_z
-
-
- ## ================ Things
- thing laser_g
- thing laser_i local
- thing camera0_g
-
-
- #=================== Sounds
-
- sound laser_snd=AMB04Pulse.WAV local
- sound cry_snd=AMB02LaserLp.WAV local
- sound act_snd=SWT00LtSwch1.WAV local
- sound act2_snd=SWT00DrSwtch.WAV local
- sound deact_snd=SWT00LtSwch2.WAV local
- # ================= Misc. Variables
- int counter=0 local
- int l_color=1 local
- flex l_radius=0.005 local
- flex f_speed=0.25 local
- int active_crystal=0 local
- int active_sector=0 local
- int s_light=0 local
- int add_crystal=0 local
- int see1=0 local
- int see2=0 local
- int see3=0 local
- int got1=0 local
- int got2=0 local
- int got3=0 local
- int got4=0 local
- int got5=0 local
- int got6=0 local
- int got7=0 local
- int got8=0 local
- int got9=0 local
- int got10=0 local
-
- end
-
- # ========================================================================================
-
- code
- startup:
- player=getlocalplayerthing();
- //add_crystal = 3;
- laser_i = 0;
- global9 = 0;
- ///active_crystal = crystal_0a_s;
- //setpulse(f_speed);
- //REQUIREMENT 0 4 head with vocabulator
- if (dwCheckDroidCaps(1048576)) SetInv(player, 4, 1);// if droid has a vocab
- if ( (getinv(player, 34)>0)&&(getinv(player, 35)>0)&&(getinv(player, 36)>0) ) setinv(player, 5, 1);
- return;
-
- activated:
- // This routine hangles getting the click from the user, and then turning the laser on or off.
- // It also handles figureing out which crys
- if ( getsenderid() == 5) // iF the player pressed the laser activate button
- {
- if (laser_i == 0) call laser_on;
- else call laser_off;
- }
- else if (active_crystal > 0) //else if a crystal's active
- {
- if ((getsenderref() == crystal_0a_s) && (active_crystal == crystal_0a_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 0a");
- dwPlayMovie("SEcrystal01.san");
- SetInv(player, 2, 1);
- sleep(1);
- }
- if ((getsenderref() == crystal_0b_s) && (active_crystal == crystal_0b_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 0b");
- dwPlayMovie("crystal01.san");
- SetInv(player, 2, 1);
- sleep(1);
- if (see1 == 0)
- {
- see1 = 1;
- call update_info;
- }
- }
- if ((getsenderref() == crystal_1a_s) && (active_crystal == crystal_1a_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 1a");
- dwPlayMovie("SJcrystal02.san");
- SetInv(player, 2, 1);
- sleep(1);
- // PLay movie
- }
- if ((getsenderref() == crystal_1b_s) && (active_crystal == crystal_1b_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 1b");
- dwPlayMovie("SEcrystal02.san");
- SetInv(player, 2, 1);
- sleep(1);
- // PLay movie
- }
- if ((getsenderref() == crystal_3a_s) && (active_crystal == crystal_3a_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 3a");
- dwPlayMovie("SWcrystal03.san");
- SetInv(player, 2, 1);
- sleep(1);
- // PLay movie
- }
- if ((getsenderref() == crystal_3b_s) && (active_crystal == crystal_3b_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 3b");
- dwPlayMovie("crystal03.san");
- SetInv(player, 2, 1);
- sleep(1);
- if (see2 == 0)
- {
- see2 = 1;
- call update_info;
- }
- // PLay movie
- }
- if ((getsenderref() == crystal_4a_s) && (active_crystal == crystal_4a_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 4a");
- // PLay movie
- dwPlayMovie("crystal02.san");
- SetInv(player, 2, 1);
- sleep(1);
- if (see3 == 0)
- {
- see3 = 1;
- call update_info;
- }
- }
- if ((getsenderref() == crystal_4b_s) && (active_crystal == crystal_4b_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 4b");
- dwPlayMovie("SEcrystal03.san"); //////////////////////THIS IS THE DUPE CRYSTAL
- SetInv(player, 2, 1);
- sleep(1);
- }
- if ((getsenderref() == crystal_7a_s) && (active_crystal == crystal_7a_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 7a");
- dwPlayMovie("SWcrystal01.san");
- SetInv(player, 2, 1);
- sleep(1);
- }
- if ((getsenderref() == crystal_7b_s) && (active_crystal == crystal_7b_s))
- {
- garbage = playsoundlocal(act2_snd,1,0.0,0);
- sleep(1);
- print("Activate Movie 7b");
- dwPlayMovie("SEcrystal03.san"); //////////////////////THIS IS THE DUPE CRYSTAL
- SetInv(player, 2, 1);
- sleep(1);
- }
- }
- else
- {
- print("click");
- dwPlayCammySpeech(16037, "M4ca023.wav", 10, 0);// I don't think it worked.
- }
- return;
-
- user0:
- // Called by Mirror cogs to turn the laser off before rotation.
- call laser_off;
- return;
-
- user1:
- // This routine is called from the Jawatalking.cog and notifies this cog that another Crystal has been added.
- add_crystal = add_crystal +1; //This variable keeps track of how many crystals have been added by the Jawa.
- call laser_off;
- return;
-
- laser_on:
- // This routine controls turning the laser on.
- print("LASER ON");
- laser_i = addlaser(laser_g, l_color, l_radius);
- garbage = playsoundpos(act_snd,getsurfacecenter(getsenderref()),1,-1,-1,0);
- sounder = playsoundlocal(laser_snd,0.5,0.0,1);
- global9 = 1;
- call check_crystal;
- call set_switch;
- return;
-
- Laser_off:
- print("OFF");
- // This controls turning the laser off.
- setpulse(0);
-
- if (active_crystal != 0) //if a crystal was last hit by the laser
- {
- setwallcel(active_crystal,0); // turn it's switch off.
- active_crystal = 0;
- }
- if (active_sector != 0) //if crystal sector is lit
- {
- SetSectorLight(active_sector, 0, 1.0); // remove some light
- active_sector = 0;
- }
- print("LASER OFF");
- removelaser(laser_i);
- if (sounder >0) {stopsound(sounder,0.5); sounder = -1;}
- if (crysound >0) {stopsound(crysound,0.5); crysound = -1;}
- garbage = playsoundlocal(deact_snd,1.0,0.0,0);
-
- laser_i = 0;
- global9 = 0;
- call set_switch;
- return;
-
- set_Switch:
- //This routine sets any and all switches to the correct state
- setwallcel(switch0_s,global9);
- setwallcel(switch1_s,global9);
- setwallcel(switch2_s,global9);
- setwallcel(switch3_s,global9);
- setwallcel(switch4_s,global9);
- setwallcel(switch5_s,global9);
- return;
-
- check_crystal:
- // This routine checks the angle of all the mirrors and turns on the activation switches for each crystal.
- active_crystal = 0; // Set this to 0 so that if no crystal is being activated this will stay at 0
- if (global8 == -45) // If the laser's pointed up at towards Chamber 0
- {
- if ((global0 == 40))// Chamber 0, crystal A
- {
- print("Hit 0a");
- if (got1 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- got1 = 1;
- timermode = 2;
- settimer(10);
- setwallcel(crystal_0a_s,1);
- active_crystal = crystal_0a_s;
- active_sector = crystal_0a_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_0a_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
- setpulse(f_speed);
- }
- else if ((global0 == -20) && (add_crystal > 0)) //Chamber 0, crystal B
- {
- print("Hit 0b");
- if (got2 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
- got2 = 1;
- timermode = 2;
- settimer(10);
- setwallcel(crystal_0b_s,1);
- active_crystal = crystal_0b_s;
- active_sector = crystal_0b_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_0b_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
- setpulse(f_speed);
- }
- else if ((global0 == 0))// Back into itself
- {
- call overheat;
- }
- }
- else if (global8 == 0) // If the laser's pointed east towards Chambers 1,2,4
- {
- if ((global2 == 50))// towards Chamber 1
- {
- if ((global1 == 25))// Chamber 1, crystal A
- {
- print("Hit 1a");
- if (got3 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- got3 = 1;
- timermode = 2;
- settimer(10);
- setwallcel(crystal_1a_s,1);
- active_crystal = crystal_1a_s;
- active_sector = crystal_1a_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_1a_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global1 == -25))// Chamber 1, crystal B
- {
- print("Hit 1b");
-
- //dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- if (got4 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
- got4 = 1;
-
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_1b_s,1);
- active_crystal = crystal_1b_s;
- active_sector = crystal_1b_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_1b_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global1 == 0))// Back into itself
- {
- call overheat;
- }
- }
- else if ((global2 == -35))// towards Chamber 4
- {
- if ((global4 == 25) && (add_crystal > 1))// Chamber 4, crystal A
- {
- print("Hit 4a");
-
- if (got5 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- got5 = 1;
-
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_4a_s,1);
- active_crystal = crystal_4a_s;
- active_sector = crystal_4a_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_4a_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global4 == -35))// Chamber 4, crystal B
- {
- print("Hit 4b");
- if (got6 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
- got6 = 1;
- timermode = 2;
- settimer(10);
- setwallcel(crystal_4b_s,1);
- active_crystal = crystal_4b_s;
- active_sector = crystal_4b_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_4b_z),1.0,-1,-1,1);
- setpulse(f_speed);
- SetInv(player, 3, 1);
- }
- else if ((global4 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
- else if ((global2 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
- else if (global8 == 45) // If the laser's pointed south towards Chambers 3,5,6,7
- {
- if (global6 == 70) // Towards chamber 7
- {
- if ((global7 == 40))// Chamber 7, crystal A
- {
- print("Hit 7a");
- if (got7 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- got7 = 1;
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_7a_s,1);
- active_crystal = crystal_7a_s;
- active_sector = crystal_7a_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_7a_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
- setpulse(f_speed);
- }
- else if ((global7 == -35))// Chamber 7, crystal B
- {
- print("Hit 7b");
-
- //dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- if (got8 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
- got8 = 1;
-
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_7b_s,1);
- active_crystal = crystal_7b_s;
- active_sector = crystal_7b_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_7b_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global7 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
- else if (global6 == -45) // 6 Towards chambers 3,5
- {
- if (global5 == -60) // 5 Towards chambers 3
- {
- if ((global3 == 40))// Chamber 3, crystal A
- {
- print("Hit 3a");
- if (got10 == 0) dwPlayCammySpeech(16032, "M4ca009.wav", 10, 0); // You got it!
- got10 = 1;
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_3a_s,1);
- active_crystal = crystal_3a_s;
- active_sector = crystal_3a_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_3a_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global3 == -20) && (add_crystal > 2))// Chamber 3, crystal B
- {
- print("Hit 3b");
- if (got9 == 0) dwPlayCammySpeech(16030, "M4ca007.wav", 10, 0); // You got it!
- got9 = 1;
- timermode = 2;
- settimer(10);
-
- setwallcel(crystal_3b_s,1);
- active_crystal = crystal_3b_s;
- active_sector = crystal_3b_z;
- crysound = playsoundpos(cry_snd,getsectorcenter(crystal_3b_z),1.0,-1,-1,1);
- SetInv(player, 3, 1);
-
- setpulse(f_speed);
- }
- else if ((global3 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
- else if ((global5 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
- else if ((global6 == 0))// Back into itself
- {
- call overheat;
- }
-
- }
-
- if (active_sector > 0)
- {
- SetSectorLight(active_sector, 1.0, f_speed); // add some light
- s_light = 1;
- }
- return;
-
- overheat:
- timermode = 1;
- settimer(2);
- return;
-
- timer:
- if (timermode == 1)
- {
- call laser_off;
- dwPlayCammySpeech(16024, "M4ca021.wav", 10, 0); //Overheat
- timermode = 2;
- settimer(10);
- }
- else if (timermode == 2)
- {
- // nothing anymore
- }
-
-
- return;
- update_info:
- if (counter == 0)
- {
- counter = 1;
- dwPlayCammySpeech(16034, "M4ca010.wav", 10, 0);// You got it!
- print("play 1");
- }
- else if (counter == 1)
- {
- counter = 2;
- dwPlayCammySpeech(16035, "M4ca011.wav", 10, 0);// You got it!
- print("play 1");
- }
- else if (counter == 2)
- {
- counter = 3;
- dwPlayCammySpeech(16036, "M4ca012.wav", 10, 0);// You got it!
- SetInv(player, 1, 1);
- print("play 1");
- sleep(23);
- dwendlevel();
- }
-
- return;
-
- pulse:
- // Used to cycle the animation of the switches when they're turned on
- if (active_crystal != 0)
- {
- //setwallcel(active_crystal,1);
- setwallcel(active_crystal,1-getwallcel(active_crystal));
- s_light = 1 - s_light;
- setSectorLight(active_sector, s_light, f_speed);
- }
- end
-
-