home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Cog Script
- #
- # 00_ThrownSaber.COG
- #
- # This is the class cog of the object that is created
- # at the instant of the explosion on the wall.
- # This object will only live for a frame, but it will
- # create the real saber if it is running on the server.
- # Sadly, this will be lag dependent, but since the object
- # created is a powerup the server should create it...
- #
- # [YB]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
- flags=0x40
-
- symbols
-
- int parent local
- int saberDummy local
- int saber local
-
- template saber_tpl=+fSaberReturns local
-
- message created
- message timer
-
- end
-
- # ========================================================================================
-
- code
-
- created:
- saberDummy = GetSenderRef();
- parent = GetThingParent(saberDummy);
-
- if(!IsMulti() || IsServer())
- {
- // we cannot use CreateThing because the explosion thing
- // is already dead when the message arrives in multi...
-
- saber = CreateThingAtPos(saber_tpl,
- GetThingSector(saberDummy),
- GetThingPos(saberDummy),
- '0 0 0');
-
- SetThingUserData(saber, parent);
-
- SetTimerEx(0.1, 1 , 0, 0);
- SetTimerEx(1.5, 2 , 0, 0);
- }
-
- DestroyThing(saberDummy);
-
- Return;
-
- # ........................................................................................
-
- timer:
-
- if(GetSenderId() == 1)
- {
- // Returning the saber now...
-
- // Much faster if both the parent and the saber is in the water
- if((GetSectorFlags(GetThingSector(parent)) & 2) && (GetSectorFlags(GetThingSector(saber)) & 2))
- SetThingVel(saber, VectorScale(VectorNorm(VectorSub(GetThingPos(parent), GetThingPos(saber))), 15));
- else
- // Faster if only one of the parent or the saber is in the water
- if((GetSectorFlags(GetThingSector(parent)) & 2) || (GetSectorFlags(GetThingSector(saber)) & 2))
- SetThingVel(saber, VectorScale(VectorNorm(VectorSub(GetThingPos(parent), GetThingPos(saber))), 9));
- // Normal speed of return if both are out of the water
- else
- SetThingVel(saber, VectorScale(VectorNorm(VectorSub(GetThingPos(parent), GetThingPos(saber))), 3));
- }
- else
- if(GetSenderId() == 2)
- {
- // Add Gravity in case it was missed by the player
- SetPhysicsFlags(saber, 0x1);
- SyncThingPos(saber);
- }
-
- Return;
-
- end
-
-