Skip to content

Commit

Permalink
HS 1.11 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronoVortex committed Apr 28, 2024
1 parent cbe9ad2 commit abeecfd
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions data/vertex_module/misc/shipBlueprints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ local setMapIcon = false
script.on_init(function() setMapIcon = true end) -- Handle icon on game start
script.on_internal_event(Defines.InternalEvents.ON_TICK, function() -- Reset icon
if not (setMapIcon and Hyperspace.ships.player) then return end
local starMap = Hyperspace.Global.GetInstance():GetCApp().world.starMap
local starMap = Hyperspace.App.world.starMap
starMap.ship = mapIconBase
starMap.shipNoFuel = mapIconBaseFuel
end, 100)
script.on_internal_event(Defines.InternalEvents.ON_TICK, function() -- Set custom icon
if not (setMapIcon and Hyperspace.ships.player) then return end
setMapIcon = false
local starMap = Hyperspace.Global.GetInstance():GetCApp().world.starMap
local starMap = Hyperspace.App.world.starMap
local playerShipName = Hyperspace.ships.player.myBlueprint.blueprintName
for iconShipName, icons in pairs(mapIcons) do
if playerShipName == iconShipName then
Expand Down
15 changes: 7 additions & 8 deletions data/vertex_module/particlesInit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mods.vertexparts = {}
local vter = mods.vertexutil.vter
local Children = mods.vertexdata.Children
local parse_xml_bool = mods.vertexdata.parse_xml_bool
local INT_MAX = 2147483647

----------------------
-- HELPER FUNCTIONS --
Expand All @@ -13,7 +12,7 @@ local function seconds_per_tick()
end

local function rand_range(min, max)
return (Hyperspace.random32()/INT_MAX)*(max - min) + min
return math.random()*(max - min) + min
end

local function lerp(a, b, amount)
Expand Down Expand Up @@ -87,11 +86,11 @@ function particles:Create(typeName, x, y, space, layer, rotate, mirror)
particle.layer = layer
particle.rotate = rotate
particle.mirror = mirror
particle.anim = Hyperspace.Global.GetInstance():GetAnimationControl():GetAnimation(particle.type.anim.name)
particle.anim = Hyperspace.Animations:GetAnimation(particle.type.anim.name)
particle.anim.position.x = -particle.anim.info.frameWidth/2
particle.anim.position.y = -particle.anim.info.frameHeight/2
if particle.type.anim.random then
particle.anim:SetCurrentFrame(Hyperspace.random32()%particle.anim.info.numFrames)
particle.anim:SetCurrentFrame(math.random(particle.anim.info.numFrames) - 1)
end
if particle.type.anim.animated then
particle.anim.tracker.loop = true
Expand Down Expand Up @@ -387,7 +386,7 @@ end
local function generate_shape_offset(emitter)
local offsetX, offsetY
if emitter.shape == emitterShapes.LINE then
local offsetMagnitude = Hyperspace.random32()/INT_MAX
local offsetMagnitude = math.random()
offsetX = offsetMagnitude*emitter.width
offsetY = offsetMagnitude*emitter.height
elseif emitter.shape == emitterShapes.RECT then
Expand All @@ -403,8 +402,8 @@ local function generate_shape_offset(emitter)
end
elseif emitter.shape == emitterShapes.ELLIPSE then
local halfWidth = emitter.width/2
local r = halfWidth*math.sqrt(Hyperspace.random32()/INT_MAX)
local theta = 2*math.pi*(Hyperspace.random32()/INT_MAX)
local r = halfWidth*math.sqrt(math.random())
local theta = 2*math.pi*(math.random())
offsetX = halfWidth + r*math.cos(theta)
offsetY = (halfWidth + r*math.sin(theta))*(emitter.height/emitter.width)
end
Expand All @@ -425,7 +424,7 @@ function particleEmitters:Emit(emitter, event, weapon, posX, posY, shipId)

-- Calculate weapon coodinates
local weaponAnim = weapon.weaponVisual
local ship = Hyperspace.Global.GetInstance():GetShipManager(weapon.iShipId).ship
local ship = Hyperspace.ships(weapon.iShipId).ship
local shipGraph = Hyperspace.ShipGraph.GetShipInfo(weapon.iShipId)
local slideOffset = weaponAnim:GetSlide()
emitPointX = emitPointX + ship.shipImage.x + shipGraph.shipBox.x + weaponAnim.renderPoint.x + slideOffset.x
Expand Down
6 changes: 3 additions & 3 deletions data/vertex_module/tags/lockdownBeam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ end
-----------
local function logic()
script.on_internal_event(Defines.InternalEvents.DAMAGE_BEAM, function(shipManager, projectile, location, damage, realNewTile, beamHitType)
local lockdown = weaponInfo[Hyperspace.Get_Projectile_Extend(projectile).name]["lockdownBeam"]
local lockdown = weaponInfo[projectile.extend.name]["lockdownBeam"]
if lockdown.doLockdown then
local doLockdown =
not lockdown.chance or
lockdown.chance >= 10 or
(lockdown.chance > 0 and lockdown.chance > Hyperspace.random32()%10)
(lockdown.chance > 0 and lockdown.chance > math.random(10) - 1)
if doLockdown and beamHitType == Defines.BeamHit.NEW_ROOM then
shipManager.ship:LockdownRoom(get_room_at_location(shipManager, location, true), location)
if #(lockdown.sounds) > 0 then
Hyperspace.Global.GetInstance():GetSoundControl():PlaySoundMix(lockdown.sounds[Hyperspace.random32()%#(lockdown.sounds) + 1], 1, false)
Hyperspace.Sounds:PlaySoundMix(lockdown.sounds[math.random(#(lockdown.sounds))], -1, false)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions data/vertex_module/tags/mindControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local function logic()
if mcTable.mcTime == 0 then
crewmem:SetMindControl(false)
if mcTable.mcEndSound then
Hyperspace.Global.GetInstance():GetSoundControl():PlaySoundMix(mcTable.mcEndSound, 1, false)
Hyperspace.Sounds:PlaySoundMix(mcTable.mcEndSound, -1, false)
end
mcTable.mcTime = nil
mcTable.mcEndSound = nil
Expand All @@ -79,7 +79,7 @@ local function logic()

-- Handle mind control beams
script.on_internal_event(Defines.InternalEvents.DAMAGE_BEAM, function(shipManager, projectile, location, damage, realNewTile, beamHitType)
local mindControl = weaponInfo[Hyperspace.Get_Projectile_Extend(projectile).name]["mindControl"]
local mindControl = weaponInfo[projectile.extend.name]["mindControl"]
if mindControl and mindControl.duration then -- Doesn't check realNewTile anymore 'cause the beam kept missing crew that were on the move
for i, crewmem in ipairs(get_ship_crew_point(shipManager, location.x, location.y)) do
if can_be_mind_controlled(crewmem) then
Expand All @@ -98,7 +98,7 @@ local function logic()
-- Handle other mind control weapons
script.on_internal_event(Defines.InternalEvents.DAMAGE_AREA_HIT, function(shipManager, projectile, location, damage, shipFriendlyFire)
local mindControl = nil
pcall(function() mindControl = weaponInfo[Hyperspace.Get_Projectile_Extend(projectile).name]["mindControl"] end)
pcall(function() mindControl = weaponInfo[projectile.extend.name]["mindControl"] end)
if mindControl and mindControl.duration then
local roomId = get_room_at_location(shipManager, location, true)
local mindControlledCrew = 0
Expand Down
2 changes: 1 addition & 1 deletion data/vertex_module/tags/noPowerFix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local function logic()
if noPowerFix and noPowerFix.doFix then
local projectile = weapon:GetProjectile()
while projectile do
Hyperspace.Global.GetInstance():GetCApp().world.space.projectiles:push_back(projectile)
Hyperspace.App.world.space.projectiles:push_back(projectile)
projectile = weapon:GetProjectile()
end
end
Expand Down
2 changes: 1 addition & 1 deletion data/vertex_module/tags/particleEmitters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ local function logic()
particles:Render(ship.iShipId, particleLayers.TOP)
end)
script.on_internal_event(Defines.InternalEvents.ON_TICK, function()
if not Hyperspace.Global.GetInstance():GetCApp().world.space.gamePaused then
if not Hyperspace.App.world.space.gamePaused then
particles:Update()
end
end)
Expand Down
2 changes: 1 addition & 1 deletion data/vertex_module/tags/stealth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local function logic()
script.on_internal_event(Defines.InternalEvents.PROJECTILE_FIRE, function(projectile, weapon)
local stealth = weaponInfo[weapon.blueprint.name]["stealth"]
if stealth and stealth.doStealth then
local ship = Hyperspace.Global.GetInstance():GetShipManager(weapon.iShipId)
local ship = Hyperspace.ships(weapon.iShipId)
if ship.cloakSystem and ship.cloakSystem.bTurnedOn and ship:HasAugmentation("CLOAK_FIRE") == 0 and is_first_shot(weapon, true) then
local timer = ship.cloakSystem.timer
timer.currTime = timer.currTime - timer.currGoal/5
Expand Down
7 changes: 3 additions & 4 deletions data/vertex_module/util.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mods.vertexutil = {}
local INT_MAX = 2147483647

----------------------------
-- MISC UTILITY FUNCTIONS --
Expand Down Expand Up @@ -81,7 +80,7 @@ end
function mods.vertexutil.under_mind_system(crewmem)
local controlledCrew = nil
local otherShipId = (crewmem.iShipId + 1)%2
pcall(function() controlledCrew = Hyperspace.Global.GetInstance():GetShipManager(otherShipId).mindSystem.controlledCrew end)
pcall(function() controlledCrew = Hyperspace.ships(otherShipId).mindSystem.controlledCrew end)
if controlledCrew then
for crew in vter(controlledCrew) do
if crewmem == crew then
Expand Down Expand Up @@ -171,8 +170,8 @@ end

-- Generate a random point within the radius of a given point
function mods.vertexutil.random_point_radius(origin, radius)
local r = radius*math.sqrt(Hyperspace.random32()/INT_MAX)
local theta = 2*math.pi*(Hyperspace.random32()/INT_MAX)
local r = radius*math.sqrt(math.random())
local theta = 2*math.pi*(math.random())
return Hyperspace.Pointf(origin.x + r*math.cos(theta), origin.y + r*math.sin(theta))
end

Expand Down
2 changes: 1 addition & 1 deletion mod-appendix/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<title><![CDATA[ Vertex Tags and Utility Functions ]]></title>
<threadUrl><![CDATA[ https://github.com/ChronoVortex/FTL-HS-Vertex ]]></threadUrl>
<author><![CDATA[ Vertaalfout, Chrono Vortex, Pepson ]]></author>
<version><![CDATA[ 5.10 ]]></version>
<version><![CDATA[ 6.0 ]]></version>
<description>
<![CDATA[
This mod has no content, instead adding new tags and LUA utility functions for other mods to build off of.
Expand Down

0 comments on commit abeecfd

Please sign in to comment.