Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Global Hooks
- $Simulation:
- [
- --Main loop that begins once initShmup() is executed.
- if booleanInitScroll == true then
- if objectPlayer:isValid() then --Player Validity Check
- --Get Position and Orientation and Speed
- vectorCurrentPos = objectPlayer.Position
- vectorPlayerVelocity = objectPlayer.Physics.Velocity
- --Horizontal Position Limit
- if objectPlayer.Position["x"] > floatHLimit then
- local playPos = ba.createVector((floatHLimit - 1), objectPlayer.Position["y"], objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- elseif objectPlayer.Position["x"] < floatHRLimit then
- local playPos = ba.createVector((floatHRLimit + 1), objectPlayer.Position["y"], objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- end
- --Vertical Position Limit
- if objectPlayer.Position["y"] > floatVLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],(floatVLimit - 1), objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- elseif objectPlayer.Position["y"] < floatVRLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],(floatVRLimit + 1), objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- end
- --Forward Position Limit
- if objectPlayer.Position["z"] > floatFLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],objectPlayer.Position["y"],(floatFLimit - 1))
- objectPlayer.Position = playPos
- elseif vectorCurrentPos["z"] < floatFRLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],objectPlayer.Position["y"],(floatFRLimit + 1))
- objectPlayer.Position = playPos
- end
- forceOrient = ba.createOrientation(0,0,0)
- --Update Player Rotational Velocity, Position
- objectPlayer.Physics.Orientation = forceOrientation
- --AndrewofDoom's mod: addition of scrolling
- if booleanInitScroll == true then --double check to see if this still is really true.
- ft = ba.getFrametime(false)
- intSavedCamPosX = intSavedCamPosX + (floatScrollX*ft)
- intSavedCamPosY = intSavedCamPosY + (floatScrollY*ft)
- intSavedCamPosZ = intSavedCamPosZ + (floatScrollZ*ft)
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- objectCCamera:setPosition(vectorCCameraPos)
- floatHLimit = floatHLimit + (floatScrollX*ft)
- floatVLimit = floatVLimit + (floatScrollY*ft)
- floatFLimit = floatFLimit + (floatScrollZ*ft)
- ---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*ft)
- floatVRLimit = floatVRLimit + (floatScrollY*ft)
- floatFRLimit = floatFRLimit + (floatScrollZ*ft)
- --all scrolling related to slaved ships.
- for i=1,#slaveShips do
- if slaveShips[i] ~= nil then
- 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*ft)
- end
- if slaveToY[i] == true then
- pos["y"] = pos["y"] + (floatScrollY*ft)
- end
- if slaveToZ[i] == true then
- pos["z"] = pos["z"] + (floatScrollZ*ft)
- end
- scrollS.Position = pos
- slaveShips[i] = scrollS
- end
- end
- end
- ---enforce projectile positions relative to scrolling and cull offscreen projectiles.
- local numWeps = #mn.Weapons
- for i=1,numWeps do
- local wep = mn.Weapons[i]
- local wPos = wep.Position
- if wep.Parent == hv.Player or wep.Target == hv.Player then
- --Check for out of bounds
- if wPos["y"] > floatVLimit or wPos["y"] < floatVRLimit or wPos["z"] > floatFLimit or wPos["z"] < floatFRLimit then
- wep.LifeLeft = 0.0 --Terminate weapon
- end
- if wep.LifeLeft > 0 then
- --if still in bounds, apply scrolling.
- wPos["x"] = wPos["x"] + (floatScrollX*ft)
- wPos["y"] = wPos["y"] + (floatScrollY*ft)
- wPos["z"] = wPos["z"] + (floatScrollZ*ft)
- wep.Position = wPos
- end
- end
- if wep.LifeLeft > 0 then --if this projectile is dead, then don't bother.
- --force these projectiles from these ships to have their scrolling force to player position and 0'd x component velocities.
- --May seem like an ugly O(n^2) algorithm, but this stuff is usually reserved for important enemies. Namely, bosses which are usually one, MAYBE two, in count.
- for j=1, #forcedProjShipsToPlayerAxis do
- if forcedProjShipsToPlayerAxis[j] ~= nil then --if there is no one here, then don't bother.
- if wep.Parent == forcedProjShipsToPlayerAxis[j] then
- local wepPos = ba.createVector(objectPlayer.Position["x"],wep.Position["y"],wep.Position["z"])
- wep.Position = wepPos
- local wepVel = ba.createVector(0,wep.Physics.Velocity["y"],wep.Physics.Velocity["z"])
- wep.Physics.Velocity = wepVel
- wep.Physics.VelocityDesired = wepVel
- wep.Physics.VelocityMax = wepVel
- local wepOrient = ba.createOrientation(wep.Orientation["p"],wep.Orientation["b"],0)
- wep.Orientation = wepOrient
- end
- end
- end
- end
- mn.Weapons[i] = wep --Apply weapon change
- end
- end
- end --Player Validity Check
- end
- ]
- #End
Advertisement
Add Comment
Please, Sign In to add comment