Skip to content

Commit

Permalink
onion04: more WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Apr 19, 2024
1 parent cf4eb10 commit 133994a
Showing 1 changed file with 131 additions and 9 deletions.
140 changes: 131 additions & 9 deletions dat/missions/onion/onion04.lua
Expand Up @@ -8,7 +8,8 @@
<done>Onion Society 03</done>
<cond>
local c = spob.cur()
if not c:tags("generic") then
local f = c:faction()
if not f or not f:tags("generic") then
return false
end
return true
Expand All @@ -33,6 +34,7 @@ local love_shaders = require "love_shaders"
local lmisn = require "lmisn"
local fleet = require "fleet"
local pltai = require "pilotai"
local der = require 'common.derelict'
--local lg = require "love.graphics"
-- Action happens on the jump from Action happens Overture to Dohriabi on the Overture side
Expand All @@ -41,6 +43,7 @@ local swapspb, swapsys = spob.getS("Fuzka")
local targetspb, targetsys = spob.getS("Nexus Shipyards HQ")
local jmpsys = system.get("Dohriabi")
local jmp = jump.get( ambushsys, jmpsys )
local runjmp = jump.get( ambushsys, system.get("Nartur") )
--local money_reward = onion.rewards.misn04
Expand All @@ -49,10 +52,11 @@ local title = _("Onion Bank Heist")
--[[
Mission States
0: mission accepted
1: take one-time pad
2: ship cargo swapped at XXX
3: mini-game done
4: escaped
1: took one-time pad
2: (optional) landed once before swapspb
3: ship cargo swapped at swapspb
4: mini-game done
5: escaped
--]]
mem.state = 0
Expand All @@ -79,6 +83,7 @@ function accept ()
vn.scene()
local l337 = vn.newCharacter( onion.vn_l337b01{pos="left"} )
local trixie = vn.newCharacter( onion.vn_trixie{pos="right"} )
vn.music( onion.loops.hacker )
vn.transition("electric")
vn.na(_([[You answer the incoming connection and some familiar holograms appear on-screen.]]))
l337(fmt.f(_([["Heyo, how's it going {player}?"]]),
Expand Down Expand Up @@ -133,6 +138,45 @@ function accept ()
end

function land ()
local cspb = spob.cur()
if mem.state==1 or mem.state==2 and cspb==swapspb then
-- TODO use an NPC
-- Cargo swap cutscene
vn.clear()
vn.scene()
local l337 = vn.newCharacter( onion.vn_l337b01{pos="left"} )
local trixie = vn.newCharacter( onion.vn_trixie{pos="right"} )
vn.music( onion.loops.hacker )
vn.transition("electric")
l337()
trixie()
vn.done("electric")
vn.run()

misn.osdCreate( title, {
fmt.f(_([[Break into {spb} ({sys} system)]]),
{spb=targetspb, sys=targetsys}),
} )
mem.state = 3
elseif mem.state==1 then
-- Small extra cutscene
vn.clear()
vn.scene()
local l337 = vn.newCharacter( onion.vn_l337b01{pos="left"} )
local trixie = vn.newCharacter( onion.vn_trixie{pos="right"} )
vn.music( onion.loops.hacker )
vn.transition("electric")
l337()
trixie()
vn.done("electric")
vn.run()
-- Advance internal state
mem.state = 2

elseif mem.state==3 and cspb==targetspb then
-- TODO probably use an NPC
mem.state = 4
end
end

function enter ()
Expand All @@ -143,7 +187,7 @@ function enter ()
end

local convoyspawn
local distlim = 3e3
local distlim = 5e3
local mrk
function prepare ()
-- Skip talk if jumping in from jmpsys
Expand All @@ -164,6 +208,7 @@ function wait ()
hook.timer( 1, "wait" )
end

local enemies, spam
function convoyspawn ()
if mrk then
system.markerRm( mrk )
Expand All @@ -178,6 +223,9 @@ function convoyspawn ()
"Gawain", -- has the cargo
"Pacifier",
"Pacifier",
"Pacifier",
"Admonisher",
"Admonisher",
"Admonisher",
"Admonisher",
"Admonisher",
Expand All @@ -193,14 +241,88 @@ function convoyspawn ()
for k,s in ipairs(ships) do
names[k] = fmt.f(_("Nexus {ship}"), {ship=ship.name(s)})
end
local plts = fleet.add( 1, ships, fct, jmp, names )
enemies = fleet.add( 1, ships, fct, jmp, names )

local l = plts[1]
local minspeed = math.huge
for k,p in ipairs(enemies) do
minspeed = math.min( p:stats().speed_max * 0.95, minspeed )
end

local l = enemies[1]
hook.pilot( l, "board", "board" )
hook.pilot( l, "death", "death" )
hook.pilot( l, "land", "gawain_lost" )
hook.pilot( l, "jump", "gawain_lost" )
l:setHilight(true)
l:setVisplayer(true)
l:control(true)
l:jump(runjmp)
l:setSpeedLimit( minspeed )
hook.timer( 8, "heartbeat" )
spam = 0
end

function gawain_lost ()
lmisn.fail(_([[You lost track of the target!!!]]))
end

function heartbeat ()
local l = enemies[1]
local _a, _s, _ss, dis = l:health()
if dis then
-- Player already disabled, nothing to do
return
end
if l:dist( player.pos() ) < 1500 then
local fct = faction.dynAdd( "Dummy", "_onion_nexus_hacked", _("Nexus IT (Hacked)"), { ai="baddie" } )
l:disable()
local dohack = { 3, 6, 8, 11, 14 } -- IDs of ships to hack
for k,p in ipairs(enemies) do
if p:exists() then
local hacked = inlist( dohack, k )
if hacked then
p:effectAdd("Onionized")
p:setFaction( fct )
p:setFriendly(true)
else
p:setHostile(true)
end
end
end
player.msg(_("l337_b01: Script deployed! Time to cry!"), true )
return
end
spam = spam-1
if spam < 0 then
player.msg(fmt.f(_("trixie: See the {p}? Get closer!"),{p=l}), true )
end
hook.timer( 1, "heartbeat" )
end

function board( p )
vn.clear()
vn.scene()
vn.transition()
vn.sfx( der.sfx.board )
vn.na(fmt.f(_([[Your ship approaches the {shp}, and you rip off the cargo pod and make your way.]]),
{shp=p}))
vn.sfx( der.sfx.unboard )
vn.run()

-- Give the player the cargo
local c = commodity.new( N_("Nexus Cargo Pod"), N_("Cargo taken from Nexus Shipyards.") )
mem.cargo = misn.cargoAdd( c, 0 )

mem.state = 1
misn.osdActive(2)
misn.markerRm()
misn.markerAdd( swapspb )

hook.timer( 5, "postboard" )
end

function board ()
function postboard ()
player.msg(fmt.f(_("l337_b01: Got the goods, on to {spb}!"),{spb=swapspb}), true )
end

function death ()
Expand Down

0 comments on commit 133994a

Please sign in to comment.