Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Conditional Hooks
- $State: GS_STATE_GAME_PLAY
- $On Frame:
- [
- if booleanInitScroll == true then
- objectPlayer = hv.Player
- if objectPlayer:isValid() then --Player Validity Check
- --Get Position and Orientation and Speed
- vectorCurrentPos = objectPlayer.Position
- --floatPlayerSpeed = objectPlayer.Physics:getSpeed()
- vectorPlayerVelocity = objectPlayer.Physics.Velocity
- --Horizontal Position Limit
- if objectPlayer.Position["x"] > floatHLimit then
- vectorPlayerVelocity["x"] = 300
- elseif vectorCurrentPos["x"] < floatHRLimit then
- vectorPlayerVelocity["x"] = -300
- end
- --Vertical Position Limit
- if objectPlayer.Position["y"] > floatVLimit then
- vectorPlayerVelocity["y"] = -300
- elseif vectorCurrentPos["y"] < floatVRLimit then
- vectorPlayerVelocity["y"] = 300
- end
- --Forward Position Limit
- if objectPlayer.Position["z"] > floatFLimit then
- vectorPlayerVelocity["z"] = -300
- objectPlayer.Physics.Velocity = vectorPlayerVelocity
- -- x = gr.getVectorFromCoords(0,0)
- -- vectorCurrentPos["z"] = x["x"]+10
- objectPlayer:kill(objectPlayer)
- elseif vectorCurrentPos["z"] < floatFRLimit then
- vectorPlayerVelocity["z"] = 300
- objectPlayer:kill(objectPlayer)
- end
- --Update Player Rotational Velocity, Position
- objectPlayer.Physics.Velocity = vectorPlayerVelocity
- --The ideal code that doesn't work...
- --local x = gr.getVectorFromCoords(vectorCurrentPos["x"],vectorCurrentPos["y"])
- --local lx,ly = x:getScreenCoords()
- --ba.error(type(x:getScreenCoords()))
- --if lx < 0 then
- -- x = gr.getVectorFromCoords(0,0)
- -- vectorCurrentPos["z"] = x["x"]+10
- --elseif lx > gr.getScreenWidth() then
- -- x = gr.getVectorFromCoords(gr.getScreenWidth(),0)
- -- vectorCurrentPos["z"] = x["x"]-10
- --else
- --Do nothing
- --end
- --if ly < 0 or ly == false then
- -- x = gr.getVectorFromCoords(0,0)
- -- vectorCurrentPos["y"] = x["y"]
- --elseif ly > gr.getScreenHeight() then
- -- x = gr.getVectorFromCoords(0,gr.getScreenHeight())
- -- vectorCurrentPos["y"] = x["y"]
- --end
- --AndrewofDoom's mod: addition of scrolling
- if booleanInitScroll == true then --double check to see if this still is really true.
- local ft = ba.getFrametime(false)
- intSavedCamPosX = intSavedCamPosX + (floatScrollX)
- intSavedCamPosY = intSavedCamPosY + (floatScrollY)
- intSavedCamPosZ = intSavedCamPosZ + (floatScrollZ)
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- objectCCamera:setPosition(vectorCCameraPos)
- floatHLimit = floatHLimit + floatScrollX
- floatVLimit = floatVLimit + floatScrollY
- floatFLimit = floatFLimit + floatScrollZ
- ---Set movement limits again for the rear. The original version makes the assumption that the player's postion will be along the origin and thus symmetrical, which will not be the case if the camera is scrolling.
- floatHRLimit = floatHRLimit + floatScrollX
- floatVRLimit = floatVRLimit + floatScrollY
- floatFRLimit = floatFRLimit + floatScrollZ
- for i=1, #slaveShips do
- local scrollS = slaveShips[i]
- if scrollS ~= nil then --If this ship is null, don't bother playing with it.
- local pos = scrollS.Position
- if slaveToX[i] == true then
- pos["x"] = pos["x"] + (floatScrollX)
- end
- if slaveToY[i] == true then
- pos["y"] = pos["y"] + (floatScrollY)
- end
- if slaveToZ[i] == true then
- pos["z"] = pos["z"] + (floatScrollZ)
- end
- scrollS.Position = pos
- slaveShips[i] = scrollS
- end
- end
- ---enforce projectile positions relative to scrolling.
- for i=1, mn.#Weapons do
- local wep = mn.Weapons[i]
- local wPos = wep.Position
- wPos["x"] = wPos["x"] + (floatScrollX)
- wPos["y"] = wPos["y"] + (floatScrollY)
- wPos["z"] = wPos["z"] + (floatScrollZ)
- wep.Position = wPos
- mn.Weapons[i] = wep
- end
- ---Keep player moving relative to camera
- --vectorCurrentPos["x"] = vectorCurrentPos["x"] + (floatScrollX)
- --vectorCurrentPos["y"] = vectorCurrentPos["y"] + (floatScrollY)
- --vectorCurrentPos["z"] = vectorCurrentPos["z"] + (floatScrollZ)
- --objectPlayer.Position = vectorCurrentPos
- end
- end --Player Validity Check
- end
- function initShmup()
- --These are the slaves to our scrolling system. Every ship and associated boolean must all be aligned to the same index!
- slaveShips = {}
- slaveToX = {}
- slaveToY = {}
- slaveToZ = {}
- ---Create 'blank' orientation
- ---these rotations are in RADIANS, not degrees.
- orientationBlank = mn.Ships[1].Orientation
- orientationBlank["p"] = 0
- orientationBlank["b"] = 0
- orientationBlank["h"] = -1.57
- intSavedCamPosX = 250
- intSavedCamPosY = 0
- intSavedCamPosZ = 0
- ---Set movement box limits
- floatHLimit = 30
- floatVLimit = 88
- floatFLimit = 160
- --- Set movement limits again for the rear. The original version makes the assumption that the player's postion will be
- --- along the origin and thus symmetrical, which will not be the case if the camera is scrolling.
- floatHRLimit = -30
- floatVRLimit = -88
- floatFRLimit = -160
- ---Scroll rates for each axis
- floatScrollX = 0
- floatScrollY = 0
- floatScrollZ = 0
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- orientationCCamera = orientationBlank
- ---Create chase camera
- objectCCamera = gr.createCamera("Chase Camera",vectorCCameraPos,orientationCCamera)
- ---Use the new chase camera
- gr.setCamera(objectCCamera)
- booleanInitScroll = true
- end
- ---Modifies the scroll speed of the camera on any axes a man desires..
- function setScrollSpeed(x,y,z)
- floatScrollX = x
- floatScrollY = y
- floatScrollZ = z
- end
- ---Sets the current Status of the camera scrolling. initShmup must be called first to avoid funny stuff from happening.
- ---True turns it on, false to turn it off and rest the camera view to the player ship.
- function setScrollingActive(booleanSwitch)
- if booleanSwitch == true then
- vectorCCameraPos = ba.createVector((objectPlayer.Position["x"]-250),objectPlayer.Position["y"],objectPlayer.Position["z"])
- objectCCamera:setPosition(vectorCCameraPos)
- gr.setCamera(objectCCamera)
- --Do NOT assume the play's position hasn't changed, therefore reset the bounds.
- floatHLimit = objectPlayer.Position["x"] + 30
- floatVLimit = objectPlayer.Position["y"] + 88
- floatFLimit = objectPlayer.Position["z"] + 160
- floatHRLimit = objectPlayer.Position["x"] - 30
- floatVRLimit = objectPlayer.Position["y"] - 90
- floatFRLimit = objectPlayer.Position["z"] - 160
- --Everything's set. Time to start scrolling again.
- booleanInitScroll = true
- elseif booleanSwitch == false then
- --Disable camera and scrolling, probably for a cutscene or something of that matter.
- booleanInitScroll = false
- gr.setCamera()
- else
- --nothing
- end
- end
- --This crap won't work if the camera isn't the player's
- --Guess I gotta use subtitles now. =|
- --function drawPlayerHP()
- -- local ship = mn.Ships[1]
- -- local shipHP = ship.HitpointsLeft
- -- if shipHP <= 30 then
- -- gr.setColor(255,0,0)
- -- else
- -- gr.setColor(0,255,0)
- -- end
- -- gr.drawString(shipHP,200,100)
- --end
- --Will cause the specified ship to be slaved to scrolling system and will move relative to the camera instead for the specified axes
- --Note that these ships still do not adhere to the boundary enclosure like the player is.
- function sTSC(shipToSlave,booleanSlaveXAxis,booleanSlaveYAxis,booleanSlaveZAxis)
- local toAdd = mn.Ships[shipToSlave]
- slaveShips[(#slaveShips+1)] = toAdd
- slaveToX[(#slaveToX+1)] = booleanSlaveXAxis
- slaveToY[(#slaveToY+1)] = booleanSlaveYAxis
- slaveToZ[(#slaveToZ+1)] = booleanSlaveZAxis
- end
- ]
- $On Death:
- [
- local dyingShip = hv.Self
- if dyingShip == hv.Player then --Do not disable the scrolling system if it's not the player who's blowing up!!
- booleanInitScroll = false
- end
- ]
- #End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement