home *** CD-ROM | disk | FTP | other *** search
- #standard type magnetic tram cog.
- #don't forget to set blocking walls to "no move"
- symbols
- message startup
- message arrived
- message crossed
- message entered
- message timer
-
- thing newtram linkid=4
- thing crateG
- thing teleport1
- thing teleport2
-
- template crateT
-
- sector thrustsector linkid=5
- sector checksector linkid=1
- sector startsector linkid=2
-
- surface triggeradjoin mask=0xfff
- surface tram1block1 nolink
- surface tram1block2 nolink
- surface tram1block3 nolink
- surface tram1block4 nolink
-
- vector cratepos local
- vector trampos local
- vector thrustvector
-
- surface conv0
- surface conv1
- surface conv2
- surface conv3
- surface conv4
- surface conv5
-
- vector slidevector
-
- end
-
- ## Code Section
- code
- startup:
- player=getlocalplayerthing();
- setthinglight(newtram, 1.0, 0);
- if (dwcheckdroidcaps(16)!=0) magneticthrust=8; //droid is magnetic
- else magneticthrust=0;
- call belton;
- isattached=0;
- return;
-
- belton:
- anim0=slidewall(conv0, slidevector, 5.0);
- anim1=slidewall(conv1, slidevector, 5.0);
- anim2=slidewall(conv2, slidevector, 5.0);
- anim3=slidewall(conv3, slidevector, 5.0);
- anim4=slidewall(conv4, slidevector, 5.0);
- anim5=slidewall(conv5, slidevector, 5.0);
- return;
-
- beltoff:
- stopanim(anim0);
- stopanim(anim1);
- stopanim(anim2);
- stopanim(anim3);
- stopanim(anim4);
- stopanim(anim5);
- return;
-
- crossed:
- print("crossed");
- if ( (getcurframe(newtram)==2)&&(dwcheckdroidcaps(16)!=0) ) {
- print("trying to attach droid");
- hangoffset=('0,0,0');
- achthing=getsourceref();
- call movetram;
- }
- return;
-
- movetram:
- print("attaching crate");
- isattached=1;
- call clrajnflgs;
- totalradius = GetThingRadius(achthing) + GetThingRadius(magnettram);
- VectorSet(hangoffset, 0, 0, -totalradius);
- // hangoffset = VectorAdd(hangoffset, GetThingInsertOffset(magnettram));
- hangoffset = VectorSub(hangoffset, GetThingInsertOffset(achthing));
- SetThingPos(achthing, VectorAdd(GetThingPos(newtram), hangoffset));
- AttachThingToThingEx(achthing, newtram, 8);
- movetoframe(newtram, 1, 4);
- movetoframe(newcrate, 2, 5);
- setsectorthrust(thrustsector, thrustvector, 0);
- return;
-
- arrived:
- //when the tram has arrived, drop the achthing and reset to stop 0
- if (getsenderid()==4) {
- if (getcurframe(newtram)==1) {
- print("reached dropoff frame");
- if (isattached==1) {
- print("detachting thing");
- isattached=0;
- sleep(2);
- detachthing(achthing);
- setthingvel(achthing, '0,0,0.5');
- movetoframe(newtram, 0, 4);
- dwenablejump();
- }
- else movetoframe(newtram, 0, 4);
- }
- else if (getcurframe(newtram)==2) {
- call setajnflags;
- print("sector thrust on!");
- setsectorthrust(thrustsector, thrustvector, magneticthrust);
- settimer(5);
- }
- else if (getcurframe(newtrame)==0) print("let's stop now.");
- }
- else {
- if (getcurframe(newcrate)==2) {
- destroything(newcrate);
- if (getthingsector(player)==checksector) {
- teleportthing(player, teleport1);
- print("teleporting player out");
- }
- else call createcrate;
- }
- else if (getcurframe(newcrate)==1) {
- call setajnflgs;
- sleep(2);
- print("here comes the tram");
- movetoframe(newtram, 2, 4);
- // playsoundthing(t1tramstart, newtram, 1, -1, 80, 0);
- // movechannel=playsoundthing(t1trammove, newtram, 1, -1, 80, 0x1);
- call beltoff;
- }
- }
- return;
-
- entered:
- if (getsenderid()==2) {
- call createcrate;
- print("you're in the factory");
- if (magneticthrust!=0) dwdisablejump();
- }
- return;
-
- timer:
- if ( (getcurframe(newtram)==2)&&(isthingmoving(newtram)==0) ) {
- print("you blew it.");
- movetoframe(newtram, 0, 4);
- movetoframe(newcrate, 2, 5);
- setsectorthrust(thrustsector, thrustvector, 0);
- call clrajnflgs;
- call belton;
- }
- return;
-
-
- clrajnflgs:
- print("clearing flags");
- setadjoinflags(tram1block1, 2);
- setadjoinflags(tram1block2, 2);
- setadjoinflags(tram1block3, 2);
- setadjoinflags(tram1block4, 2);
- return;
-
- setajnflgs:
- print("setting flags");
- clearadjoinflags(tram1block1, 2);
- clearadjoinflags(tram1block2, 2);
- clearadjoinflags(tram1block3, 2);
- clearadjoinflags(tram1block4, 2);
- return;
-
- createcrate:
- newcrate=CreateThing(crateT, crateG);
- CaptureThing(newcrate);
- movetoframe(newcrate, 1, 5);
- return;
-
-
-
-
- end
-
-
-