home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / Doubleshotz / Doubleshotz.dcr / Internal_12_PlayerCar.ls < prev    next >
Encoding:
Text File  |  2007-09-27  |  31.5 KB  |  806 lines

  1. property pKeyDir, pRamp, kPower, kBoost, pMyScore, pMyBonus, pMember, pSprite, spriteNum, pCarShell, pChassisName, pCarCollider, pCarBody, pLocalDown, pLocalForward, pLocalRight, forwardVel, pUserCar, pCarName, pCarShadow, pBumperPos, pWheelNameA, pWheelNameB, pWheelNameC, pWheelNameD, pwidth, pFrontWheelBase, pBackWheelBase, pWheelRadius, pStrength, pDamping, pHoverDist, pMaxWheelTurn, pWheelSpinCoeff, pWheelList, pWheelPointList, pIsHoveringList, pHoverDistList, pChassisRB, pChassisMDL, pCarMass, pChassisMass, pChassisWeigth, pGravityStrength, pWheelTurn, pWheelSpin, pLastCarTransform, pCarFlame, pBodyOffset, pExhaustDummy, pDoubleshotLight, p3DWorld, pMotivator, pThrustor, pEmitterRegionList, pDirection, pRotation, pthrust, pIsLanding, pIsPrepared, pIsStarted, pIsReady, pHasFinished, pIsJumping, pPlayerID, pEnemyID, pKeyIsDn, pKeyPower, pKeyTimer, pGear, pIsFinished, pHasHitRamp, pImFinished, pEnemyFinished, angDashpot, pJumperSpin, pJumperSpinIncr, pRocketBuild, pHasStarted, pRocketMaxBuild, pBaseScore, pWasFinished, pMyFrame
  2. global isPlaying, gHavok, g3DWorld, gTextures, gCarsPrepared, gCarsReady, gTrackZ, gCarName, gHasStarted, p1score, p2score, gP1Event_1_score, gP1Event_2_score, gP1Event_3_score, gP2Event_1_score, gP2Event_2_score, gP2Event_3_score, gP1Finished, gP2Finished, gFrameCounter, gWinner, ovTxt, ovFader, ovBackdrop, ovDial_1, ovDial_2, ovWinner_1, ovWinner_2, ovNeedle_1, ovNeedle_2, ovDSLight_1, ovDSLight_2, ovP1Score_1, ovP1Score_2, ovP1Score_3, ovP1Score_4, ovP1Score_5, ovP2Score_1, ovP2Score_2, ovP2Score_3, ovP2Score_4, ovP2Score_5, ovKey_1_1, ovKey_1_2, ovKey_2_1, ovKey_2_2, mCamera, mTrack, mFinish, SndC_Music, SndC_Grnd, SndC_FX1, SndC_FX2, SndC_Engine, SndC_EnemyFX, gEngineSndList, gCar1Used, gPlayerKeysList, gEventID, gScoresList, ovResultsPanel_1, ovResultsPanel_2, ovP1Results_1, ovP1Results_2, ovP1Results_3, ovP1Results_4, ovP1Results_5, ovP2Results_1, ovP2Results_2, ovP2Results_3, ovP2Results_4, ovP2Results_5, gUserFramePlay, gUserFrameRecord, gGameMODE
  3.  
  4. on doUpdateScore me
  5.   if (pWasFinished = 1) and (g3DWorld.model("Collider_1").userData.isFinished = 1) and (g3DWorld.model("Collider_2").userData.isFinished = 1) then
  6.     if pMyBonus = 1000 then
  7.       gEngineSndList[pPlayerID].play(member("teletype"))
  8.       gFrameCounter = 0
  9.       SndC_Music.fadeOut(2000)
  10.     end if
  11.     if pMyBonus >= 10 then
  12.       pMyBonus = max(0, pMyBonus - 10)
  13.       pMyScore = pMyScore + 10
  14.     else
  15.       gEngineSndList[pPlayerID].stop()
  16.     end if
  17.   end if
  18.   tScore = max(0, integer(gScoresList[gEventID][pPlayerID]))
  19.   t5 = floor(tScore / 10000)
  20.   tScore = tScore - (t5 * 10000)
  21.   t4 = floor(tScore / 1000.0)
  22.   tScore = tScore - (t4 * 1000)
  23.   t3 = floor(tScore / 100.0)
  24.   tScore = tScore - (t3 * 100)
  25.   t2 = floor(tScore / 10.0)
  26.   tScore = tScore - (t2 * 10)
  27.   t1 = floor(tScore / 1.0)
  28.   tScore = tScore - (t1 * 1)
  29.   mCamera.overlay[value("ovP" & pPlayerID & "Score_5")].source = gTextures.getProp("Digit_" & t1)
  30.   mCamera.overlay[value("ovP" & pPlayerID & "Score_4")].source = gTextures.getProp("Digit_" & t2)
  31.   mCamera.overlay[value("ovP" & pPlayerID & "Score_3")].source = gTextures.getProp("Digit_" & t3)
  32.   mCamera.overlay[value("ovP" & pPlayerID & "Score_2")].source = gTextures.getProp("Digit_" & t4)
  33.   mCamera.overlay[value("ovP" & pPlayerID & "Score_1")].source = gTextures.getProp("Digit_" & t5)
  34.   gScoresList[gEventID][pPlayerID] = integer(pMyScore)
  35. end
  36.  
  37. on doUpdateResult me
  38.   mCamera.overlay[value("ovResultsPanel_" & pPlayerID)].blend = 100
  39.   mCamera.overlay[value("ovP" & pPlayerID & "Results_1")].blend = 100
  40.   mCamera.overlay[value("ovP" & pPlayerID & "Results_2")].blend = 100
  41.   mCamera.overlay[value("ovP" & pPlayerID & "Results_3")].blend = 100
  42.   mCamera.overlay[value("ovP" & pPlayerID & "Results_4")].blend = 100
  43.   mCamera.overlay[value("ovP" & pPlayerID & "Results_5")].blend = 100
  44.   tScore = max(0, integer(gScoresList[gEventID][pPlayerID]))
  45.   t5 = floor(tScore / 10000)
  46.   tScore = tScore - (t5 * 10000)
  47.   t4 = floor(tScore / 1000.0)
  48.   tScore = tScore - (t4 * 1000)
  49.   t3 = floor(tScore / 100.0)
  50.   tScore = tScore - (t3 * 100)
  51.   t2 = floor(tScore / 10.0)
  52.   tScore = tScore - (t2 * 10)
  53.   t1 = floor(tScore / 1.0)
  54.   tScore = tScore - (t1 * 1)
  55.   mCamera.overlay[value("ovP" & pPlayerID & "Results_5")].source = gTextures.getProp("Digit_" & t1)
  56.   mCamera.overlay[value("ovP" & pPlayerID & "Results_4")].source = gTextures.getProp("Digit_" & t2)
  57.   mCamera.overlay[value("ovP" & pPlayerID & "Results_3")].source = gTextures.getProp("Digit_" & t3)
  58.   mCamera.overlay[value("ovP" & pPlayerID & "Results_2")].source = gTextures.getProp("Digit_" & t4)
  59.   mCamera.overlay[value("ovP" & pPlayerID & "Results_1")].source = gTextures.getProp("Digit_" & t5)
  60. end
  61.  
  62. on beginSprite me
  63.   if gGameMODE = 1 then
  64.     gUserFrameRecord = value(member("recorder_" & gCarName).text)
  65.   end if
  66.   gUserFramePlay = []
  67.   pMyFrame = 1
  68.   tdoBoost = 0
  69.   pKeyDir = 1
  70.   pWasFinished = 0
  71.   pRocketMaxBuild = 1
  72.   pHasStarted = 0
  73.   pRocketBuild = 0
  74.   pJumperSpin = 0
  75.   pJumperSpinIncr = 20
  76.   if gCar1Used = 0 then
  77.     gCar1Used = 1
  78.     pPlayerID = 1
  79.     pEnemyID = 2
  80.     kPower = string(gPlayerKeysList[1])
  81.     kBoost = string(gPlayerKeysList[2])
  82.   else
  83.     pPlayerID = 2
  84.     pEnemyID = 1
  85.     kPower = string(gPlayerKeysList[3])
  86.     kBoost = string(gPlayerKeysList[4])
  87.   end if
  88.   pHasHitRamp = 0
  89.   pSuspensionOn = 1
  90.   gWinner = 0
  91.   pDoubleshotLight = 0
  92.   gP1Finished = 0
  93.   gP2Finished = 0
  94.   pMyScore = 0
  95.   pMyBonus = 0
  96.   pGear = 1
  97.   pKeyTimer = 0
  98.   pKeyIsDn = 0
  99.   pOldWheelTurn = 0
  100.   pWheelTurn_3 = 0
  101.   pWheelTurn_4 = 0
  102.   pWheelSpin2 = 0
  103.   pSprite = sprite(me.spriteNum)
  104.   pMember = pSprite.member
  105.   pIsFinished = 0
  106.   pIsPrepared = 0
  107.   pIsStarted = 0
  108.   pIsReady = 0
  109.   pIsJumping = 0
  110.   pIsLanding = 0
  111.   gCarsPrepared = 0
  112.   gCarsReady = 0
  113.   pCarMass = 1000
  114.   pStrength = 3
  115.   pDamping = 0.06
  116.   pScalar = 1.0
  117.   pHoverDist = 1.5
  118.   pMaxWheelTurn = 45
  119.   pWheelSpinCoeff = 2
  120.   pBrakeGain = 0.29999999999999999
  121.   pAccGain = 0.12
  122.   pDecGain = 0.03
  123.   pTurnBuild = 0
  124.   pMaxSpeed = 65.0
  125.   pTurnBuildFactor = 20
  126.   pGripFactor = 1
  127.   pGrip = 1.0
  128.   pDrag = 0.0
  129.   gTrackZ = 0
  130.   case gCarName of
  131.     "Dragster":
  132.       pFrontWheelBase = 2
  133.       pBackWheelBase = 1.69999999999999996
  134.       pwidth = 1.89999999999999991
  135.       pWheelRadius = 0.59999999999999998
  136.       pBodyOffset = -0.05
  137.     "Jumper":
  138.       pFrontWheelBase = 1.80000000000000004
  139.       pBackWheelBase = 1.85000000000000009
  140.       pwidth = 1.89999999999999991
  141.       pWheelRadius = 0.69999999999999996
  142.       pBodyOffset = -0.29999999999999999
  143.     "Rocket":
  144.       pFrontWheelBase = 1.80000000000000004
  145.       pBackWheelBase = 1.85000000000000009
  146.       pwidth = 1.89999999999999991
  147.       pWheelRadius = 0.46999999999999997
  148.       pBodyOffset = 0
  149.   end case
  150. end
  151.  
  152. on exitFrame me
  153.   if pIsStarted = 0 then
  154.     return 
  155.   end if
  156.   me.updateCar()
  157. end
  158.  
  159. on startCar me
  160.   pIsStarted = 1
  161. end
  162.  
  163. on checkPrepared me
  164.   if pIsPrepared = 0 then
  165.     gCarsPrepared = 0
  166.   end if
  167. end
  168.  
  169. on checkReady me
  170.   if pIsReady = 0 then
  171.     gCarsReady = 0
  172.   end if
  173. end
  174.  
  175. on prepareCar me
  176.   pKeyPower = 0
  177.   pLocalDown = vector(0, 0, -1)
  178.   pLocalForward = vector(0, 1, 0)
  179.   pCarBody = g3DWorld.model("Collider_" & pPlayerID)
  180.   pCarBody.addModifier(#meshDeform)
  181.   pCarBody.visibility = #none
  182.   pCarBody.userData.addProp(#kind, "userCar")
  183.   pCarBody.userData.addProp(#isFinished, 0)
  184.   pCarBody.userData.addProp(#hasJumped, 0)
  185.   pCarBody.userData.addProp(#myX, pCarBody.transform.position.x)
  186.   pChassisName = pCarBody.name
  187.   pCarShell = g3DWorld.model(gCarName & "_Body").cloneDeep(gCarName & "_Body_" & pPlayerID)
  188.   put pCarShell.shaderList
  189.   if pPlayerID = 2 then
  190.     case gCarName of
  191.       "Dragster":
  192.         pCarShell.shaderList[1].diffuse = rgb(0, 100, 255)
  193.       "Jumper":
  194.         pCarShell.shaderList[3].diffuse = rgb(0, 100, 255)
  195.       "Rocket":
  196.         pCarShell.shaderList[1].diffuse = rgb(0, 100, 255)
  197.     end case
  198.   end if
  199.   pExhaustDummy = g3DWorld.model(gCarName & "_Dummy").clone(gCarName & "_Dummy_" & pPlayerID)
  200.   pExhaustDummy.visibility = #none
  201.   if gCarName = "Rocket" then
  202.     pCarShadow = g3DWorld.model("Shadow_" & pPlayerID)
  203.     pCarShadow.visibility = #none
  204.   else
  205.     pCarShadow = g3DWorld.model("Shadow_" & pPlayerID)
  206.     pCarShadow.shader.texture.renderFormat = #rgba4444
  207.     pWheelA = g3DWorld.model(gCarName & "_Wheel_FL").clone(gCarName & "_Wheel_FL_" & pPlayerID)
  208.     pWheelB = g3DWorld.model(gCarName & "_Wheel_FR").clone(gCarName & "_Wheel_FR_" & pPlayerID)
  209.     pWheelC = g3DWorld.model(gCarName & "_Wheel_RL").clone(gCarName & "_Wheel_RL_" & pPlayerID)
  210.     pWheelD = g3DWorld.model(gCarName & "_Wheel_RR").clone(gCarName & "_Wheel_RR_" & pPlayerID)
  211.     pWheelA.visibility = #both
  212.     pWheelB.visibility = #both
  213.     pWheelC.visibility = #both
  214.     pWheelD.visibility = #both
  215.     pWheelNameA = pWheelA.name
  216.     pWheelNameB = pWheelB.name
  217.     pWheelNameC = pWheelC.name
  218.     pWheelNameD = pWheelD.name
  219.   end if
  220.   pCarFlame = g3DWorld.model("Flame").clone("Flame_" & pPlayerID)
  221.   pCarFlame.transform.position = pCarShell.transform.position
  222.   pCarFlame.visibility = #none
  223.   pCarFlame.shader.texture.renderFormat = #rgba4444
  224.   pCarFlame.shader.emissive = rgb(255, 255, 0)
  225.   if gCarName = "Jumper" then
  226.     pRamp = g3DWorld.model("RAMP_" & pPlayerID)
  227.   end if
  228.   gHavok.makeMovableRigidBody(pCarBody.name, pCarMass, 1, #box)
  229.   pChassisRB = gHavok.rigidBody(pCarBody.name)
  230.   pChassisMass = pChassisRB.mass
  231.   pChassisRB.restitution = 0
  232.   pChassisRB.friction = 0
  233.   pGravityStrength = gHavok.gravity.length
  234.   pChassisWeigth = pChassisMass * pGravityStrength
  235.   pChassisMDL = pCarBody
  236.   pWheelList = [pWheelA, pWheelB, pWheelD, pWheelC]
  237.   pIsHoveringList = [0, 0, 0, 0]
  238.   pHoverDistList = [0.0, 0.0, 0.0, 0.0, 0.0]
  239.   com = pChassisRB.centerOfMass
  240.   pLocalForward.normalize()
  241.   pLocalDown.normalize()
  242.   pLocalRight = pLocalDown.cross(pLocalForward)
  243.   pLocalRight.normalize()
  244.   posA = com + (pFrontWheelBase * pLocalForward) + (pwidth * 0.5 * -pLocalRight)
  245.   posB = com + (pFrontWheelBase * pLocalForward) + (pwidth * 0.5 * pLocalRight)
  246.   posC = com + (pBackWheelBase * -pLocalForward) + (pwidth * 0.5 * pLocalRight)
  247.   posD = com + (pBackWheelBase * -pLocalForward) + (pwidth * 0.5 * -pLocalRight)
  248.   pWheelPointList = [posA, posB, posC, posD]
  249.   pFrontBumperPos = com + ((pFrontWheelBase + 0.5) * pLocalForward)
  250.   pThrustor = g3DWorld.newModelResource("Thrustor" & pPlayerID, #particle)
  251.   tParticles = g3DWorld.newModel("ThrustGas" & pPlayerID, pThrustor)
  252.   pDirection = vector(0, 0, 1)
  253.   tVector_1 = vector(-0.5, -3, 0)
  254.   tVector_2 = vector(0.5, -3, 0)
  255.   pEmitterRegionList = [tVector_1, tVector_2]
  256.   tParticleTexture = member("Smoke")
  257.   tRenderFormat = #rgba4444
  258.   pThrustor.emitter.numParticles = 50
  259.   pThrustor.emitter.angle = 35
  260.   pThrustor.lifeTime = 500
  261.   pThrustor.sizeRange.start = 0.40000000000000002
  262.   pThrustor.sizeRange.end = 3.0
  263.   pThrustor.gravity = vector(0, 0, 0)
  264.   pThrustor.wind = vector(0, 0, 0)
  265.   pThrustor.emitter.distribution = #gaussian
  266.   pThrustor.blendRange.start = 0
  267.   pThrustor.blendRange.end = 0
  268.   pThrustor.emitter.maxSpeed = 3
  269.   pThrustor.emitter.minSpeed = 1
  270.   pThrustor.emitter.region = pEmitterRegionList
  271.   pThrustor.emitter.direction = pDirection
  272.   ttexture = g3DWorld.newTexture("ParticleTexture_" & pPlayerID)
  273.   ttexture.member = tParticleTexture
  274.   ttexture.renderFormat = tRenderFormat
  275.   pThrustor.texture = ttexture
  276.   pRotation = vector()
  277.   pIsPrepared = 1
  278. end
  279.  
  280. on updateCar me
  281.   tTrans = pCarBody.transform
  282.   tPosition = tTrans.position
  283.   tRotation = tTrans.rotation
  284.   tempTrans = tTrans.duplicate()
  285.   if tempTrans = VOID then
  286.     tempTrans = pLastCarTransform.duplicate()
  287.   end if
  288.   tempTrans2 = tempTrans.duplicate()
  289.   tempTrans.position = vector(0, 0, 0)
  290.   tempTrans.scale = vector(1, 1, 1)
  291.   worldAxis = tempTrans * -pLocalDown
  292.   worldForward = tempTrans * pLocalForward
  293.   worldRight = worldForward.cross(worldAxis)
  294.   worldDownDir = tempTrans * pLocalDown
  295.   worldAxis.normalize()
  296.   worldForward.normalize()
  297.   worldRight.normalize()
  298.   worldDownDir.normalize()
  299.   chassisPos = pChassisRB.position + pChassisRB.centerOfMass
  300.   linVel = pChassisRB.linearVelocity
  301.   forwardVel = linVel.dot(worldForward)
  302.   angVel = pChassisRB.angularVelocity
  303.   tAngVel = pChassisRB.angularVelocity.z
  304.   tAngMom = pChassisRB.angularmomentum.z
  305.   if forwardVel = 0 then
  306.     forwardVel = 0.0001
  307.   end if
  308.   pPowerCoeff = pIsHoveringList[1] + pIsHoveringList[2] + pIsHoveringList[3] + pIsHoveringList[4]
  309.   if not pPowerCoeff = 0 then
  310.     pIsReady = 1
  311.     pPowerCoeff = pPowerCoeff / 4.0
  312.   end if
  313.   if isPlaying = 1 then
  314.     if pPlayerID = 1 then
  315.       pImFinished = g3DWorld.model("Collider_1").userData.isFinished
  316.       pEnemyFinished = g3DWorld.model("Collider_2").userData.isFinished
  317.       gP1Finished = pImFinished
  318.       gP2Finished = pEnemyFinished
  319.       if (pWasFinished = 0) and (pImFinished = 1) then
  320.         pBaseScore = pMyScore
  321.         pWasFinished = 1
  322.         put "FINISHED " & pPlayerID
  323.         doUpdateResult()
  324.       end if
  325.     else
  326.       pImFinished = g3DWorld.model("Collider_2").userData.isFinished
  327.       pEnemyFinished = g3DWorld.model("Collider_1").userData.isFinished
  328.       gP2Finished = pImFinished
  329.       gP1Finished = pEnemyFinished
  330.       if (pWasFinished = 0) and (pImFinished = 1) then
  331.         pBaseScore = pMyScore
  332.         pWasFinished = 1
  333.         put "FINISHED " & pPlayerID
  334.         doUpdateResult()
  335.       end if
  336.     end if
  337.     case gCarName of
  338.       "Dragster":
  339.         if (pImFinished = 0) and (pCarShell.transform.position.y > mFinish.transform.position.y) then
  340.           pImFinished = 1
  341.           pCarBody.userData.isFinished = 1
  342.           g3DWorld.model("Collider_1").userData.isFinished = 1
  343.           g3DWorld.model("Collider_2").userData.isFinished = 1
  344.           if pEnemyFinished = 0 then
  345.             mCamera.overlay[value("ovWinner_" & pPlayerID)].blend = 100
  346.             pMyScore = pMyScore + (forwardVel * 0.10000000000000001)
  347.             pMyBonus = 1000
  348.             pEnemyFinished = 1
  349.           end if
  350.           pGear = 10
  351.         else
  352.           if (pImFinished = 0) and (pEnemyFinished = 0) then
  353.             pMyScore = pMyScore + (forwardVel * 0.10000000000000001)
  354.           end if
  355.         end if
  356.       "Jumper":
  357.         if (pImFinished = 1) and (pEnemyFinished = 1) then
  358.           pImFinished = 1
  359.           pEnemyFinished = 1
  360.           g3DWorld.model("Collider_1").userData.isFinished = 1
  361.           g3DWorld.model("Collider_2").userData.isFinished = 1
  362.           if (gScoresList[gEventID][pPlayerID] > gScoresList[gEventID][pEnemyID]) and (gWinner = 0) then
  363.             gWinner = pPlayerID
  364.             mCamera.overlay[value("ovWinner_" & pPlayerID)].blend = 100
  365.             pMyBonus = 1000
  366.           end if
  367.         end if
  368.       "Rocket":
  369.         pMyScore = max(pMyScore, pCarShell.transform.position.y)
  370.         if (pImFinished = 0) and (pCarShell.transform.position.y < (pMyScore - 2)) then
  371.           put pCarShell & "IS FINISHED"
  372.           pImFinished = 1
  373.           pCarBody.userData.isFinished = 1
  374.           pGear = 10
  375.         end if
  376.         if (pImFinished = 1) and ((pEnemyFinished = 1) or (gScoresList[gEventID][pEnemyID] < 35)) then
  377.           pImFinished = 1
  378.           pEnemyFinished = 1
  379.           g3DWorld.model("Collider_1").userData.isFinished = 1
  380.           g3DWorld.model("Collider_2").userData.isFinished = 1
  381.           if (gScoresList[gEventID][pPlayerID] > gScoresList[gEventID][pEnemyID]) and (gWinner = 0) then
  382.             gWinner = pPlayerID
  383.             mCamera.overlay[value("ovWinner_" & pPlayerID)].blend = 100
  384.             pMyBonus = 1000
  385.           else
  386.             if (gScoresList[gEventID][pPlayerID] = gScoresList[gEventID][pEnemyID]) and (gWinner = 0) then
  387.               pMyScore = pMyScore + pPlayerID
  388.               gWinner = 1
  389.               doUpdateScore()
  390.               mCamera.overlay[value("ovWinner_1")].blend = 100
  391.               pMyBonus = 1000
  392.             end if
  393.           end if
  394.         end if
  395.     end case
  396.     if (pPlayerID = 1) or (gGameMODE = 2) then
  397.       case pGear of
  398.         1:
  399.           if keyPressed(kPower) then
  400.             if pKeyIsDn = 0 then
  401.               pHasStarted = 1
  402.               gHasStarted = 1
  403.               if gEngineSndList[pPlayerID].isBusy() = 0 then
  404.                 gEngineSndList[pPlayerID].play(member("Snd_Engine_1"))
  405.               end if
  406.               pKeyTimer = the ticks
  407.               pKeyIsDn = 1
  408.               if gCarName = "Rocket" then
  409.                 pRocketBuild = min(pRocketMaxBuild, pRocketBuild + 0.02)
  410.                 imp = 2.5 * pChassisMass * pRocketBuild
  411.                 pChassisRB.applyImpulse(imp * worldForward)
  412.                 if pPlayerID = 1 then
  413.                   gUserFramePlay.append(1)
  414.                 end if
  415.               else
  416.                 imp = 2.5 * pChassisMass
  417.                 pChassisRB.applyImpulse(imp * worldForward)
  418.                 if pPlayerID = 1 then
  419.                   gUserFramePlay.append(1)
  420.                 end if
  421.               end if
  422.             end if
  423.           else
  424.             pKeyIsDn = 0
  425.             if pPlayerID = 1 then
  426.               gUserFramePlay.append(0)
  427.             end if
  428.           end if
  429.           if pChassisMDL.transform.position.y > 800 then
  430.             pRocketMaxBuild = max(-1, pRocketMaxBuild - 0.20000000000000001)
  431.           end if
  432.           if the ticks > (pKeyTimer + 30) then
  433.             imp = -forwardVel * pChassisMass
  434.             pChassisRB.applyImpulse(0.02 * imp * worldForward)
  435.             if (pHasStarted = 1) and (gCarName = "Rocket") then
  436.               pRocketMaxBuild = max(-1, pRocketMaxBuild - 0.20000000000000001)
  437.               if pChassisMDL.transform.position.y > 0.01 then
  438.                 imp = -pChassisMass
  439.                 pChassisRB.applyImpulse(imp * worldForward)
  440.               else
  441.                 pChassisRB.linearMomentum = vector(0, 0, 0)
  442.               end if
  443.             end if
  444.           end if
  445.           if keyPressed(kBoost) and (forwardVel > 144) then
  446.             gEngineSndList[pPlayerID].play(member("Snd_Engine_2"))
  447.             pKeyTimer = the ticks + (60 * 5)
  448.             pGear = 2
  449.             pCarFlame.visibility = #both
  450.             pCarFlame.shader.blend = 0
  451.             if pPlayerID = 1 then
  452.               gUserFramePlay.append(3)
  453.             end if
  454.           end if
  455.         2:
  456.           if the ticks > pKeyTimer then
  457.             pGear = 3
  458.           else
  459.             imp = 2.5 * pChassisMass
  460.             pChassisRB.applyImpulse(imp * worldForward)
  461.             pCarFlame.shader.blend = min(70, pCarFlame.shader.blend + 10)
  462.           end if
  463.         3:
  464.           if pCarFlame.visibility = #both then
  465.             pCarFlame.shader.blend = max(0, pCarFlame.shader.blend - 5)
  466.             if pCarFlame.shader.blend = 0 then
  467.               pCarFlame.visibility = #none
  468.             end if
  469.           end if
  470.           imp = -forwardVel * pChassisMass
  471.           pChassisRB.applyImpulse(0.02 * imp * worldForward)
  472.           if gCarName = "Rocket" then
  473.             imp = -pChassisMass
  474.             pChassisRB.applyImpulse(imp * worldForward)
  475.             pCarShell.rotate(2, 0.025, 0)
  476.             if pChassisMDL.transform.position.y < 0 then
  477.               pChassisRB.linearMomentum = vector(0, 0, 0)
  478.             end if
  479.           end if
  480.         10:
  481.           mCamera.overlay[ovKey_1_1].blend = 0
  482.           mCamera.overlay[ovKey_1_2].blend = 0
  483.           mCamera.overlay[ovKey_2_1].blend = 0
  484.           mCamera.overlay[ovKey_2_2].blend = 0
  485.           if pCarFlame.visibility = #both then
  486.             pCarFlame.shader.blend = max(0, pCarFlame.shader.blend - 5)
  487.             if pCarFlame.shader.blend = 0 then
  488.               pCarFlame.visibility = #none
  489.             end if
  490.           end if
  491.           imp = -forwardVel * pChassisMass
  492.           pChassisRB.applyImpulse(0.03 * imp * worldForward)
  493.           if gCarName = "Rocket" then
  494.             pCarShell.rotate(2, 0.025, 0)
  495.             if pChassisMDL.transform.position.y < 0 then
  496.               pChassisRB.linearMomentum = vector(0, 0, 0)
  497.             end if
  498.           end if
  499.       end case
  500.     else
  501.       case pGear of
  502.         1:
  503.           if pMyFrame > gUserFrameRecord.count then
  504.             put "EXTENDING RECORDING"
  505.             pMyFrame = 1
  506.             tdoBoost = 1
  507.           end if
  508.           if gUserFrameRecord[pMyFrame] = 1 then
  509.             if pKeyIsDn = 0 then
  510.               pHasStarted = 1
  511.               gHasStarted = 1
  512.               if gEngineSndList[pPlayerID].isBusy() = 0 then
  513.                 gEngineSndList[pPlayerID].play(member("Snd_Engine_1"))
  514.               end if
  515.               pKeyTimer = the ticks
  516.               pKeyIsDn = 1
  517.               if gCarName = "Rocket" then
  518.                 pRocketBuild = min(pRocketMaxBuild, pRocketBuild + 0.02)
  519.                 imp = 2.5 * pChassisMass * pRocketBuild
  520.                 pChassisRB.applyImpulse(imp * worldForward)
  521.               else
  522.                 imp = 2.5 * pChassisMass
  523.                 pChassisRB.applyImpulse(imp * worldForward)
  524.               end if
  525.             end if
  526.           else
  527.             pKeyIsDn = 0
  528.           end if
  529.           if pChassisMDL.transform.position.y > 800 then
  530.             pRocketMaxBuild = max(-1, pRocketMaxBuild - 0.20000000000000001)
  531.           end if
  532.           if the ticks > (pKeyTimer + 30) then
  533.             imp = -forwardVel * pChassisMass
  534.             pChassisRB.applyImpulse(0.02 * imp * worldForward)
  535.             if (pHasStarted = 1) and (gCarName = "Rocket") then
  536.               pRocketMaxBuild = max(-1, pRocketMaxBuild - 0.20000000000000001)
  537.               if pChassisMDL.transform.position.y > 0.01 then
  538.                 imp = -pChassisMass
  539.                 pChassisRB.applyImpulse(imp * worldForward)
  540.               else
  541.                 pChassisRB.linearMomentum = vector(0, 0, 0)
  542.               end if
  543.             end if
  544.           end if
  545.           if (tdoBoost = 1) and (gUserFrameRecord[gUserFrameRecord.count] = 3) and (forwardVel > 144) then
  546.             gEngineSndList[pPlayerID].play(member("Snd_Engine_2"))
  547.             pKeyTimer = the ticks + (60 * 5)
  548.             pGear = 2
  549.             pCarFlame.visibility = #both
  550.             pCarFlame.shader.blend = 0
  551.           end if
  552.         2:
  553.           if the ticks > pKeyTimer then
  554.             pGear = 3
  555.           else
  556.             imp = 2.5 * pChassisMass
  557.             pChassisRB.applyImpulse(imp * worldForward)
  558.             pCarFlame.shader.blend = min(70, pCarFlame.shader.blend + 10)
  559.           end if
  560.         3:
  561.           if pCarFlame.visibility = #both then
  562.             pCarFlame.shader.blend = max(0, pCarFlame.shader.blend - 5)
  563.             if pCarFlame.shader.blend = 0 then
  564.               pCarFlame.visibility = #none
  565.             end if
  566.           end if
  567.           imp = -forwardVel * pChassisMass
  568.           pChassisRB.applyImpulse(0.02 * imp * worldForward)
  569.           if gCarName = "Rocket" then
  570.             imp = -pChassisMass
  571.             pChassisRB.applyImpulse(imp * worldForward)
  572.             pCarShell.rotate(2, 0.025, 0)
  573.             if pChassisMDL.transform.position.y < 0 then
  574.               pChassisRB.linearMomentum = vector(0, 0, 0)
  575.             end if
  576.           end if
  577.         10:
  578.           mCamera.overlay[ovKey_1_1].blend = 0
  579.           mCamera.overlay[ovKey_1_2].blend = 0
  580.           mCamera.overlay[ovKey_2_1].blend = 0
  581.           mCamera.overlay[ovKey_2_2].blend = 0
  582.           if pCarFlame.visibility = #both then
  583.             pCarFlame.shader.blend = max(0, pCarFlame.shader.blend - 5)
  584.             if pCarFlame.shader.blend = 0 then
  585.               pCarFlame.visibility = #none
  586.             end if
  587.           end if
  588.           imp = -forwardVel * pChassisMass
  589.           pChassisRB.applyImpulse(0.03 * imp * worldForward)
  590.           if gCarName = "Rocket" then
  591.             pCarShell.rotate(2, 0.025, 0)
  592.             if pChassisMDL.transform.position.y < 0 then
  593.               pChassisRB.linearMomentum = vector(0, 0, 0)
  594.             end if
  595.           end if
  596.       end case
  597.       pMyFrame = pMyFrame + 1
  598.     end if
  599.     if forwardVel > 144 then
  600.       if pDoubleshotLight = 0 then
  601.         mCamera.overlay[value("ovDSLight_" & pPlayerID)].blend = 100
  602.         pDoubleshotLight = 1
  603.         gEngineSndList[pPlayerID].play(member("Snd_DS"))
  604.         mCamera.overlay[value("ovKey_" & pPlayerID & "_1")].blend = 30
  605.         mCamera.overlay[value("ovKey_" & pPlayerID & "_2")].blend = 100
  606.       end if
  607.     else
  608.       mCamera.overlay[value("ovDSLight_" & pPlayerID)].blend = max(0, mCamera.overlay[value("ovDSLight_" & pPlayerID)].blend - 5)
  609.       if pDoubleshotLight = 1 then
  610.         pDoubleshotLight = 0
  611.         mCamera.overlay[value("ovKey_" & pPlayerID & "_1")].blend = 100
  612.         mCamera.overlay[value("ovKey_" & pPlayerID & "_2")].blend = 30
  613.       end if
  614.     end if
  615.     t1 = mCamera.overlay[value("ovNeedle_" & pPlayerID)].rotation
  616.     t2 = max(0, min(180, forwardVel))
  617.     t3 = ((t2 - t1) * 0.14999999999999999) + t1
  618.     mCamera.overlay[value("ovNeedle_" & pPlayerID)].rotation = t3
  619.     doUpdateScore()
  620.   end if
  621.   tPos = pChassisMDL.transform.position
  622.   rotx = pChassisMDL.transform.rotation.x
  623.   roty = pChassisMDL.transform.rotation.y
  624.   rotz = pChassisMDL.transform.rotation.z
  625.   if gCarName = "Jumper" then
  626.     pChassisMDL.transform.position.x = pCarBody.userData.myX
  627.   end if
  628.   if pPowerCoeff = 0 then
  629.     pIsLanding = 1
  630.     if (gCarName = "Jumper") and (pHasHitRamp = 1) then
  631.       pMyScore = max(pMyScore, (tPos.y - pRamp.transform.position.y) * 10)
  632.       pChassisRB.applyAngularImpulse(-pChassisRB.angularmomentum * 0.5)
  633.       pJumperSpin = pJumperSpin + pJumperSpinIncr
  634.       if pJumperSpin >= 360 then
  635.         pJumperSpin = 360
  636.       else
  637.         if pJumperSpin >= (360 - 91) then
  638.           pJumperSpinIncr = pJumperSpinIncr - 2
  639.         end if
  640.       end if
  641.       pChassisMDL.transform.rotation.y = pJumperSpin
  642.     end if
  643.   else
  644.     if pIsLanding = 1 then
  645.       pIsJumping = 0
  646.       pIsLanding = 0
  647.       if (gCarName = "Jumper") and (pHasHitRamp = 1) then
  648.         pChassisRB.linearMomentum = vector(0, 0, 0)
  649.         put pPlayerID & " FINISH LAND"
  650.         pCarBody.userData.isFinished = 1
  651.         pHasHitRamp = 0
  652.         pGear = 10
  653.         gEngineSndList[pPlayerID].stop()
  654.         pChassisRB.attemptMoveTo(vector(pCarBody.userData.myX, tPos.y, 1), [vector(1, 1, 1), 0])
  655.         pChassisRB.applyAngularImpulse(-pChassisRB.angularmomentum)
  656.       end if
  657.     else
  658.       pChassisRB.applyAngularImpulse(vector(0, 0, -tAngMom * 0.20000000000000001))
  659.       slideSpeed = worldRight.dot(linVel)
  660.       imp = worldRight * (-slideSpeed * pChassisMass)
  661.       pChassisRB.applyImpulse(imp)
  662.     end if
  663.   end if
  664.   if (tPos.z < 0) or ((gCarName = "Jumper2") and (pCarBody.userData.isFinished = 1)) then
  665.     T = pChassisRB.attemptMoveTo(vector(pCarBody.userData.myX, tPos.y, 1), [vector(1, 1, 1), 0])
  666.     put "ATTEMPT TO CORRECT = " & T
  667.   end if
  668.   pLastCarTransform = pChassisMDL.transform.duplicate()
  669.   repeat with i = 1 to pWheelPointList.count
  670.     pIsHoveringList[i] = 0
  671.     worldWheelPoint = tempTrans2 * pWheelPointList[i]
  672.     tUseHover = 0
  673.     if gCarName = "Jumper" then
  674.       details = pMember.modelsUnderRay(worldWheelPoint, worldDownDir, [#maxNumberOfModels: 1, #levelOfDetail: #detailed, #modelList: [pRamp, mTrack], #maxDistance: 2])
  675.       if details <> [] then
  676.         if (pPowerCoeff = 1) and (details[1][1] = mTrack) then
  677.           hoverDst = worldWheelPoint.z - 0
  678.           hoverPnt = vector(worldWheelPoint.x, worldWheelPoint.y, 0)
  679.           tUseHover = 1
  680.         else
  681.           hoverDst = details[1][2]
  682.           hoverPnt = details[1][3]
  683.           tUseHover = 1
  684.         end if
  685.       end if
  686.     else
  687.       hoverDst = worldWheelPoint.z - 0
  688.       hoverPnt = vector(worldWheelPoint.x, worldWheelPoint.y, 0)
  689.       tUseHover = 1
  690.     end if
  691.     if tUseHover = 1 then
  692.       if hoverDst < pHoverDist then
  693.         pointVelocity = linVel + angVel.cross(worldWheelPoint - chassisPos)
  694.         diff = hoverPnt - worldWheelPoint
  695.         f = -pStrength * (pHoverDist - hoverDst)
  696.         f = f - (pDamping * pointVelocity.dot(diff))
  697.         pChassisRB.applyImpulseAtPoint(diff * f * pChassisMass, pWheelPointList[i])
  698.         pIsHoveringList[i] = 1
  699.         pHoverDistList[i] = hoverDst
  700.       end if
  701.       next repeat
  702.     end if
  703.     pHoverDistList[i] = pHoverDist
  704.   end repeat
  705.   t1 = (pChassisMDL.transform * pWheelPointList[3]) + (pHoverDistList[3] * worldDownDir) - (pWheelRadius * worldDownDir)
  706.   t2 = (pChassisMDL.transform * pWheelPointList[4]) + (pHoverDistList[4] * worldDownDir) - (pWheelRadius * worldDownDir)
  707.   mid = ((t2 - t1) * 0.5) + t1
  708.   if gCarName = "Jumper" then
  709.     details = pMember.modelsUnderRay(mid, vector(0, 0, -1), [#maxNumberOfModels: 1, #levelOfDetail: #detailed, #modelList: [pRamp, mTrack], #maxDistance: 2])
  710.   else
  711.     details = pMember.modelsUnderRay(mid, vector(0, 0, -1), [#maxNumberOfModels: 1, #levelOfDetail: #detailed, #modelList: [mTrack], #maxDistance: 2])
  712.   end if
  713.   if gCarName <> "Rocket" then
  714.     if details = [] then
  715.       nothing()
  716.     else
  717.       hoverDst = details[1][2]
  718.       shadowPoint = details[1][3]
  719.       if (pHasHitRamp = 0) and (details[1][1] = pRamp) then
  720.         pHasHitRamp = 1
  721.         pJumperSpin = 0
  722.       end if
  723.       pCarShadow.transform.position = details[1][3] + vector(0, 0, 0.05)
  724.       pCarShadow.transform.rotation.z = pCarShell.transform.rotation.z
  725.     end if
  726.     pCarShell.transform.position = pChassisMDL.transform.position
  727.     pCarShell.transform.rotation = pChassisMDL.transform.rotation
  728.     pCarShell.translate(0, 0, pBodyOffset)
  729.   else
  730.     pCarShell.transform.position = pChassisMDL.transform.position
  731.     pCarShell.rotate(0, forwardVel * 0.025, 0)
  732.   end if
  733.   if gCarName <> "Rocket" then
  734.     pWheelSpin = pWheelSpin - (forwardVel * pWheelSpinCoeff)
  735.     if pWheelSpin > 360 then
  736.       pWheelSpin = pWheelSpin - 360
  737.     else
  738.       if pWheelSpin < -360 then
  739.         pWheelSpin = pWheelSpin - 360
  740.       end if
  741.     end if
  742.     repeat with i = 1 to 4
  743.       worldWheelPoint = pChassisMDL.transform * pWheelPointList[i]
  744.       T = pHoverDistList[i]
  745.       pWheelList[i].transform.position = worldWheelPoint + (T * worldDownDir) - (pWheelRadius * worldDownDir)
  746.       pWheelList[i].transform.rotation = pChassisMDL.transform.rotation
  747.       pWheelList[i].rotate(pWheelSpin, 0, 0)
  748.     end repeat
  749.   end if
  750.   if isPlaying = 1 then
  751.     tTrans = pCarShell.getWorldTransform()
  752.     pExhaustDummy.transform.position = pCarShell.transform.position
  753.     pExhaustDummy.translate(0, 0, 0)
  754.     pExhaustDummy.transform.rotation = pCarShell.transform.rotation
  755.     tTrans = pExhaustDummy.getWorldTransform()
  756.     tEmitterRegionList = pEmitterRegionList.duplicate()
  757.     repeat with i = 1 to tEmitterRegionList.count
  758.       tEmitterRegionList[i] = tTrans * tEmitterRegionList[i]
  759.     end repeat
  760.     pThrustor.emitter.region = tEmitterRegionList
  761.     tTrans.position = vector(0, 0, 0)
  762.     if (pHasStarted = 1) and (gCarName = "Rocket") and (pCarShell.transform.position.y <= 2) then
  763.       newSmoke = 100
  764.       pThrustor.blendRange.start = min(newSmoke, pThrustor.blendRange.start + 3)
  765.       pThrustor.wind = vector(0, 8, 5)
  766.     else
  767.       newSmoke = 40 * min(1, abs(forwardVel) / 55)
  768.       pThrustor.blendRange.start = max(newSmoke, pThrustor.blendRange.start - 1.5)
  769.       pThrustor.wind = vector(0, 0, 0)
  770.     end if
  771.   else
  772.     pThrustor.blendRange.start = max(0, pThrustor.blendRange.start - 2)
  773.   end if
  774.   pCarFlame.transform.position = pExhaustDummy.transform.position
  775.   pCarFlame.translate(0, -4, 0)
  776.   pCarFlame.transform.rotation = pExhaustDummy.transform.rotation
  777.   tOverlayID = value("ovKey_" & pPlayerID & "_1")
  778.   if mCamera.overlay[tOverlayID].blend > 30 then
  779.     if pKeyDir = 1 then
  780.       mCamera.overlay[tOverlayID].blend = min(100, mCamera.overlay[tOverlayID].blend + 10)
  781.       if mCamera.overlay[tOverlayID].blend = 100 then
  782.         pKeyDir = -1
  783.       end if
  784.     else
  785.       mCamera.overlay[tOverlayID].blend = max(31, mCamera.overlay[tOverlayID].blend - 10)
  786.       if mCamera.overlay[tOverlayID].blend = 31 then
  787.         pKeyDir = 1
  788.       end if
  789.     end if
  790.   end if
  791.   tOverlayID = value("ovKey_" & pPlayerID & "_2")
  792.   if mCamera.overlay[tOverlayID].blend > 30 then
  793.     if pKeyDir = 1 then
  794.       mCamera.overlay[tOverlayID].blend = min(100, mCamera.overlay[tOverlayID].blend + 10)
  795.       if mCamera.overlay[tOverlayID].blend = 100 then
  796.         pKeyDir = -1
  797.       end if
  798.     else
  799.       mCamera.overlay[tOverlayID].blend = max(31, mCamera.overlay[tOverlayID].blend - 10)
  800.       if mCamera.overlay[tOverlayID].blend = 31 then
  801.         pKeyDir = 1
  802.       end if
  803.     end if
  804.   end if
  805. end
  806.