home *** CD-ROM | disk | FTP | other *** search
- #-----------------------------------------------------------------------------
- # Droidworks
- # Sample cog for a simple conversation with Bob.
- #-----------------------------------------------------------------------------
-
- symbols
- message converse
- message startup
- message arrived
- message user2
- message user3
- message timer
- message pulse
-
- thing Gonk
- thing player local
-
- int MetGonk=0 local
- int ConversationActive=0 local
- int gonkcurframe=0 local
- int ResponseID local
- int wait_time=2 local
-
- cog fulcrumcog
- sector ts1
- sector ts2
- vector thrustvector
- vector target local
- thing gGhost1
- thing gGhost2
- thing gGhost3
- thing gGhost4
- thing gGhost5
- thing gGhost6
- thing gGhost7
- thing gGhost8
-
- end
-
-
- code
- startup:
- gonkisresetting=0;
- player=getlocalplayerthing();
- gonkcurframe=1;
- gonkspeed=2.0;
- AISetLookFrame(gonk, 1);
- AISetMoveFrame(gonk, 1);
- AISetMoveSpeed(gonk, gonkspeed);
- // if (getdifficulty()==1) settimer(4);
- hastalked=0;
- target=gpos1;
- gPos1=getthingpos(gGhost1);
- gPos2=getthingpos(gGhost2);
- gPos3=getthingpos(gGhost3);
- gPos4=getthingpos(gGhost4);
- gPos5=getthingpos(gGhost5);
- gPos6=getthingpos(gGhost6);
- gPos7=getthingpos(gGhost7);
- gPos8=getthingpos(gGhost8);
- setactorflags(Gonk, 8);
-
-
- return;
-
- timer:
- setthingmass(gonk, 150);
- setsectorthrust(ts1, thrustvector, 4);
- setsectorthrust(ts2, thrustvector, 4);
- return;
-
- converse:
- # What response did the player select?
- dwplayplayerresponse();
- ResponseID = dwGetPlayerResponse();
-
-
- if (ResponseID == 0 && !ConversationActive)
- {
- ConversationActive = 1;
- playsong(0,0,0);
- dwfreezeplayer();
- if (Metgonk)
- {
- dwplaycharacterspeech("GKC002", "t6gk009.wav"); # gonk: Hello again!
- if (gonkcurframe==1) dwAddResponse(1, "GKP070", "M1xx040.wav", 60); # Help me, Gonk!
- dwAddResponse(20, "GKP020", "t6xx007.wav", 72); # Where is Jabba?
- dwAddResponse(40, "GKP040", "", 20); # Goodbye.
- }
- else
- {
- dwplaycharacterspeech("GKC000", "t6gk007.wav"); # gonk: Hi, my name's Gonk.
- # TODO: Play and wait for the appropriate wave
- dwAddResponse(1, "GKP070", "M1xx040.wav", 60); # Help me, Gonk!
- dwAddResponse(20, "GKP020", "t6xx007.wav", 72); # Where is Jabba?
- dwAddResponse(40, "GKP040", "", 20); # Goodbye.
- Metgonk = 1;
- }
- }
-
- else if (ResponseID == 1)
- {
- dwplaycharacterspeech("GKC001", "t6gk008.wav"); # gonk: I'll go stand on that thing.
- dwAddResponse(50, "GKP050", "t6xx010.wav", 60);
- }
- else if (ResponseID == 10)
- {
- dwplaycharacterspeech("GKC002", "t6gk009.wav"); # gonk: Hello again!
- if (gonkcurframe==1) dwAddResponse(1, "GKP070", "M1xx040.wav", 71); # Where is Jabba?
- dwAddResponse(20, "GKP020", "t6xx007.wav", 72);
- dwAddResponse(40, "GKP040", "", 20); # Goodbye.
- }
- else if (ResponseID == 20)
- {
- dwplaycharacterspeech("GKC020", "t6gk010.wav"); # gonk: I'll go stand on that thing.
- dwAddResponse(10, "GKP002", "t6xx006.wav", 60);
- gonkftf=0;
- }
- else if (ResponseID == 40)
- {
- dwplaycharacterspeech("GKC040", "t6gk012.wav");
- dwcleardialog();
- conversationactive=0;
- shuffletracks(2, 3, 4, 5);
- dwunfreezeplayer();
- }
- else if (ResponseID == 50)
- {
- dwplaycharacterspeech("GKC230", "t6gk003.wav"); # gonk: I'll go stand on that thing.
- dwAddResponse(7, "GKP060", "t6xx011.wav", 30);
- gonkftf=1;
- }
-
-
- else if (ResponseID == 7)
- {
-
- dwplaycharacterspeech("GKC100", "t6gk013.wav");
- #PLAYER: Gotta go!
-
- dwcleardialog();
- # Terminate the conversation
- ConversationActive=0;
- shuffletracks(2, 3, 4, 5);
- # Enable the player
- dwunfreezeplayer();
- if (gonkftf==1) {
- gonkftf=0;
- gonkcurframe=0;
- call gonkhelpsout;
- }
- }
- return;
-
- //gonkhelpsout:
- // AIclearmode(0xffff);
- // print("gonk helps out");
- // gonkcurframe=2;
- // return;
-
-
- #arrived:
- printint(gonkcurframe);
- if (gonkcurframe==1) {
- sendmessage(fulcrumcog, user5);
- setthingmass(gonk, 0);
- setsectorthrust(ts1, thrustvector, 0);
- setsectorthrust(ts2, thrustvector, 0);
- }
- if (gonkcurframe==2) {
- if (gonkisresetting==1) {
- print("I just jumped off the fulcrum and gir=");
- printint(gonkisresetting);
- gonkisresetting=0;
- sendmessage(fulcrumcog, user2);
- }
- else {
- print("moving on like i'm supposed to.");
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 3);
- AISetMoveFrame(gonk, 3);
- gonkcurframe=3;
- }
- }
- else if (gonkcurframe==3) {
- print("here I am at frame 3");
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 4);
- AISetMoveFrame(gonk, 4);
- gonkcurframe=4;
- }
- else if (gonkcurframe==4) {
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 5);
- AISetMoveFrame(gonk, 5);
- gonkcurframe=5;
- }
- else if (gonkcurframe==5) {
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 6);
- AISetMoveFrame(gonk, 6);
- gonkcurframe=6;
- }
- else if (gonkcurframe==6) {
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 7);
- AISetMoveFrame(gonk, 7);
- gonkcurframe=7;
- }
- else if (gonkcurframe==7) {
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 8);
- AISetMoveFrame(gonk, 8);
- gonkcurframe=8;
- sendmessage(fulcrumcog, user0);
- }
-
- return;
-
-
- user2:
- print("Medium gonk is going!");
- AISetMoveSpeed(gonk, gonkspeed);
- AISetLookFrame(gonk, 9);
- AISetMoveFrame(gonk, 9);
- gonkcurframe=9;
- return;
-
- user3:
- print("gt2 user3 received");
- gonkisresetting=1;
- gonkcurframe=0;
- setthingmass(gonk, 150);
- call gonkhelpsout;
- return;
-
-
- pulse:
- if (vectordist(getthingpos(gonk), target) < .1) {
- setpulse(0);
- if (gonkcurframe==8) {
- print("GONK IS HERE, BABEEE!!!");
- sendmessage(fulcrumcog, user0);
- }
- else if ( (gonkcurframe==1)&&(gonkisresetting==1) ) {
- setthingmass(gonk, 0);
- print("I'm back, son.");
- sendmessage(fulcrumcog, user2);
- gonkisresetting=0;
- }
- else {
- call gonkhelpsout;
- }
- }
- return;
-
- gonkhelpsout:
- setsectorthrust(ts1, thrustvector, 0);
- setsectorthrust(ts2, thrustvector, 0);
- if (gonkcurframe==8) return;
- setpulse(0.01);
- AIclearmode(0xffff);
- print("gonk helps out");
- if (gonkcurframe==0) target=gpos1;
- else if (gonkcurframe==1) target=gpos2;
- else if (gonkcurframe==2) target=gpos3;
- else if (gonkcurframe==3) target=gpos4;
- else if (gonkcurframe==4) target=gpos5;
- else if (gonkcurframe==5) target=gpos6;
- else if (gonkcurframe==6) target=gpos7;
- else if (gonkcurframe==7) target=gpos8;
- AISetMoveSpeed(gonk, 1.5);
- AISetLookPos(gonk, target);
- AISetMovePos(gonk, target);
- gonkcurframe=gonkcurframe+1;
- print("now gonk wants to go to frame");
- printint(gonkcurframe);
- return;
-
-
-
-
-
-
-
-
-
-
-
-
- end
-
-
-