From abeecfd7baf716dd3f0c4eb7c4783af70aa6c232 Mon Sep 17 00:00:00 2001 From: ChronoVortex <33610911+ChronoVortex@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:27:38 -0700 Subject: [PATCH] HS 1.11 updates --- data/vertex_module/misc/shipBlueprints.lua | 4 ++-- data/vertex_module/particlesInit.lua | 15 +++++++-------- data/vertex_module/tags/lockdownBeam.lua | 6 +++--- data/vertex_module/tags/mindControl.lua | 6 +++--- data/vertex_module/tags/noPowerFix.lua | 2 +- data/vertex_module/tags/particleEmitters.lua | 2 +- data/vertex_module/tags/stealth.lua | 2 +- data/vertex_module/util.lua | 7 +++---- mod-appendix/metadata.xml | 2 +- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/data/vertex_module/misc/shipBlueprints.lua b/data/vertex_module/misc/shipBlueprints.lua index 76dae02..46fa8a0 100644 --- a/data/vertex_module/misc/shipBlueprints.lua +++ b/data/vertex_module/misc/shipBlueprints.lua @@ -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 diff --git a/data/vertex_module/particlesInit.lua b/data/vertex_module/particlesInit.lua index 21e401e..e588fe3 100644 --- a/data/vertex_module/particlesInit.lua +++ b/data/vertex_module/particlesInit.lua @@ -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 -- @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/data/vertex_module/tags/lockdownBeam.lua b/data/vertex_module/tags/lockdownBeam.lua index 1d41b3c..7f078e3 100644 --- a/data/vertex_module/tags/lockdownBeam.lua +++ b/data/vertex_module/tags/lockdownBeam.lua @@ -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 diff --git a/data/vertex_module/tags/mindControl.lua b/data/vertex_module/tags/mindControl.lua index 9cd5ffa..ec4ee7f 100644 --- a/data/vertex_module/tags/mindControl.lua +++ b/data/vertex_module/tags/mindControl.lua @@ -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 @@ -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 @@ -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 diff --git a/data/vertex_module/tags/noPowerFix.lua b/data/vertex_module/tags/noPowerFix.lua index ece8a0e..786e0b9 100644 --- a/data/vertex_module/tags/noPowerFix.lua +++ b/data/vertex_module/tags/noPowerFix.lua @@ -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 diff --git a/data/vertex_module/tags/particleEmitters.lua b/data/vertex_module/tags/particleEmitters.lua index a7e6abb..cea5d93 100644 --- a/data/vertex_module/tags/particleEmitters.lua +++ b/data/vertex_module/tags/particleEmitters.lua @@ -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) diff --git a/data/vertex_module/tags/stealth.lua b/data/vertex_module/tags/stealth.lua index 327759d..3c8eefd 100644 --- a/data/vertex_module/tags/stealth.lua +++ b/data/vertex_module/tags/stealth.lua @@ -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 diff --git a/data/vertex_module/util.lua b/data/vertex_module/util.lua index dffb685..e140034 100644 --- a/data/vertex_module/util.lua +++ b/data/vertex_module/util.lua @@ -1,5 +1,4 @@ mods.vertexutil = {} -local INT_MAX = 2147483647 ---------------------------- -- MISC UTILITY FUNCTIONS -- @@ -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 @@ -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 diff --git a/mod-appendix/metadata.xml b/mod-appendix/metadata.xml index 962d98e..4a7d642 100644 --- a/mod-appendix/metadata.xml +++ b/mod-appendix/metadata.xml @@ -2,7 +2,7 @@