home *** CD-ROM | disk | FTP | other *** search
- #
- # gen_MoveObj.cog
- #
- #
- # A hack for pushing blocks around. Inspired by Reed Derleth, but actually executed by me.
- # Because Reed is too lazy right now.
- #
- # IMPORTANT. Make sure you attach the cog to a valid object.
- # Make sure that the ghostthing is assigned to a ghost object.
- #
- # [SXC]
- #
- # 3/22/98 MST Ripped the cog apart and added the setthingvel to fake pushing
- # Also added part to jump on this thing and have it spin
- # (Yecchh, what a hack.)
- # Watch for a future implementation of this script in a future LECLLC 3D game!
- #
- # (C) 1998 LucasLearningLimited All Rights Reserved
- # ========================================================================================
-
- symbols
- message startup
- message timer
- message entered
- message pulse
- message exited
- message user0
- message user4
- message arrived
- message activate
- message touched
-
- vector playervec local
- vector newthingvec local
- vector newvector local
-
- thing fulcrum linkid=1
- thing lever linkid=2 mask=0xfff
- thing crateghost
-
- int direction=0 local
-
- float playery=0 local
- float playerx=0 local
-
- sector gensector local
- sector ds1
-
- template crateT
- thing crateG
-
- surface moveleft linkid=3
- surface moveright linkid=4
-
- vector supervector
- vector leftvector
- vector rightvector
-
- surface track
-
- sound fulcrumstart=mcht6fulcstrt.wav
- sound fulcrumstop=mcht6fulcstp.wav
- sound fulcrumloop=mcht6fulclp.wav
- sound switchbeep=swt00ltswch2.wav
-
- vector goodriddancevector
-
- sound dave=mch00tmchst02.wav
-
- end
-
-
-
- # ========================================================================================
-
- code
-
- startup:
- cooltoflip=0;
- crateishere=0;
- supervector=vectorscale(supervector, 5.0);
- print("startup");
- player=getlocalplayerthing();
- call createmovelever;
- sxc=1.0;
- timertime=0.1;
- leverisdown=1;
- playerison=0;
- attachthingtothing(lever, fulcrum);
- // call raiseit;
- launchem=0;
-
- return;
-
- touched:
- if ( (getsenderref()==crate)&&(getsourceref()==player) ) {
- print("ten story love song");
- DamageThing(player, 9999, 0x2, player); // self-inflicted damage
- }
- return;
-
- user4:
- print("ring a ding ding ding I'm going down");
- crate=creatething(crateT, crateghost);
- capturething(crate);
- setthingvel(crate, '0,0,-1');
- settimerEX(0.5, 1, 0, 0);
- crateishere=1;
- return;
-
-
-
- # .....................................................................................
-
- entered:
- fulcrumx=(Vectorx(GetThingPos(fulcrum)));
- playerx=(Vectorx(GetThingPos(player)));
- if (getsenderid()==2) {
- if (getsourceref()==player) {
- print("player entered");
- setpulse(0.1);
- playerison=1;
- }
- else if (getsourceref()==crate) {
- print("the crate hit it");
- setthingvel(crate, goodriddancevector);
- settimerEX(0.05, 3, -1, -1);
- if ( (leverisdown==0)&&(cooltoflip==1) ) {
- if ( (playerison==1)&&(playerx>fulcrumx) )launchem=1;
- print("and it's movin'");
- rotatepivot(lever, 1, -.1);
- // destroything(crate);
- }
- }
- }
- return;
-
- exited:
- if ( (getsenderid()==2)&&(getsourceref()==player) ) {
- setpulse(0);
- playerison=0;
- }
- return;
-
- activate:
- if (getwallcel(moveleft)==1) return;
- if (getwallcel(moveright)==1) return;
- curframe=getcurframe(fulcrum);
- printint(curframe);
- if (getsenderid()==3) {
- setwallcel(moveleft, 1);
- print("move left!");
- playsoundlocal(switchbeep, 1.0, 0.0, 0);
- if (curframe==0) {
- sleep(0.2);
- call waterfall;
- }
- else {
- playsoundthing(fulcrumstart, fulcrum, 1.0, -1, -1, 0);
- sleep(0.17);
- floop=playsoundthing(fulcrumloop, fulcrum, 1.0, -1, -1, 0x1);
- movetoframe(fulcrum, curframe-1, 2);
- anim=slidewall(track, leftvector, 2);
- }
- }
- else if (getsenderid()==4) {
- print("move right!");
- setwallcel(moveright, 1);
- playsoundlocal(switchbeep, 1.0, 0.0, 0);
- if (curframe==9) {
- sleep(0.2);
- call waterfall;
- }
- else {
- playsoundthing(fulcrumstart, fulcrum, 1.0, -1, -1, 0);
- sleep(0.17);
- floop=playsoundthing(fulcrumloop, fulcrum, 1.0, -1, -1, 0x1);
- movetoframe(fulcrum, curframe+1, 2);
- anim=slidewall(track, rightvector, 2);
- }
- }
- return;
-
- # .....................................................................................
-
- timer:
- if (getsenderid()==1) {
- if (getthingsector(crate)==ds1) {
- destroything(crate);
- crateishere=0;
- }
- else settimerEX(0.5, 1, 0, 0);
- }
- else if (getsenderid()==3) {
- print("get rid of that crate!");
- setthingvel(crate, goodriddancevector);
- if (crateishere!=0) settimerEX(0.05, 3, -1, -1);
- }
- return;
- # .....................................................................................
- pulse:
- fulcrumx=(Vectorx(GetThingPos(fulcrum)));
- playerx=(Vectorx(GetThingPos(player)));
- playerZ=(vectorZ(GetthingPos(player)));
- if ((playerx<fulcrumx)&&(leverisdown==0)) call lowerit;
- else if ((playerx>fulcrumx)&&(leverisdown==1)) call raiseit;
- return;
-
- raiseit:
- print("leverisdown=0");
- playsoundthing(fulcrumstart, fulcrum, 1.0, -1, -1, 0);
- leverisdown=0;
- cooltoflip=1;
- rotatepivot(lever, 1, 0.25);
- return;
-
- lowerit:
- print("leverisdown=1");
- playsoundthing(fulcrumstart, fulcrum, 1.0, -1, -1, 0);
- leverisdown=1;
- rotatepivot(lever, 1, -0.25);
- return;
- # .....................................................................................
-
- waterfall:
- setwallcel(moveleft, 0);
- setwallcel(moveright, 0);
- return;
-
- arrived:
- print("arrived");
- if (getsenderid()==1) {
- stopsound(floop, 0.75);
- playsoundthing(fulcrumstop, fulcrum, 1.0, -1, -1, 0);
- setwallcel(moveleft, 0);
- setwallcel(moveright, 0);
- stopanim(anim);
- }
- else {
- print("launchem is ");
- printint(launchem);
- print("playerison is");
- printint(playerison);
- print("cooltoflip is");
- printint(cooltoflip);
- if(crateishere==1) {
- cooltoflip=0;
- setthingvel(crate, goodriddancevector);
- crateishere=0;
- leverisdown=1;
- }
- if (launchem==1) {
- print("here we go");
- detachthing(player);
- setthingvel(player, supervector);
- launchem=0;
- }
- }
- return;
-
- # .....................................................................................
-
-
- end
-