Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hired Escorts reimplemented as Hireable Vagabonds with mini-personalities #2152

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e03d599
Add files via upload
ThrosturX Jun 30, 2022
9bbf3c0
Update scavenger_event.lua
ThrosturX Jun 30, 2022
ff7be69
Update faction.xml
ThrosturX Jun 30, 2022
9af6b90
Add files via upload
ThrosturX Jun 30, 2022
34e7e08
Add files via upload
ThrosturX Jun 30, 2022
bda543a
Add files via upload
ThrosturX Jun 30, 2022
46cd412
Add files via upload
ThrosturX Jun 30, 2022
e6aefbb
Update scavenger_event.lua
ThrosturX Jul 1, 2022
4cc214b
Add files via upload
ThrosturX Jul 1, 2022
ada96e4
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 1, 2022
eaa6548
Update wrapper.lua
ThrosturX Jul 1, 2022
0a5243b
Update escort.lua
ThrosturX Jul 1, 2022
419d1a8
Update escort.lua
ThrosturX Jul 1, 2022
47d789e
Update scavenger_event.lua
ThrosturX Jul 1, 2022
88dc772
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 4, 2022
9f638f3
Add files via upload
ThrosturX Jul 4, 2022
bc6aa8a
Add files via upload
ThrosturX Jul 4, 2022
fc12498
Add files via upload
ThrosturX Jul 4, 2022
ca79441
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 7, 2022
7eddc56
Add files via upload
ThrosturX Jul 7, 2022
373d9b7
Add files via upload
ThrosturX Jul 7, 2022
3ec765a
Add files via upload
ThrosturX Jul 7, 2022
b77cf6d
Delete escort.lua
ThrosturX Jul 7, 2022
0f1196f
Add files via upload
ThrosturX Jul 7, 2022
fdf688f
Add files via upload
ThrosturX Jul 7, 2022
ea6bb81
Add files via upload
ThrosturX Jul 7, 2022
8cd1beb
Update wrapper.lua
ThrosturX Jul 7, 2022
ebb7973
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 7, 2022
5918050
Add files via upload
ThrosturX Jul 7, 2022
ac8ccb2
Add files via upload
ThrosturX Jul 8, 2022
3f8b957
Add files via upload
ThrosturX Jul 8, 2022
e2c7b9c
Create placeholder.png
ThrosturX Jul 10, 2022
06b65bb
Add files via upload
ThrosturX Jul 10, 2022
f1fc17d
Delete dat/gui/gfx/portraits/neutral/unique directory
ThrosturX Jul 10, 2022
322e22e
Create placeholder.png
ThrosturX Jul 10, 2022
79bf216
Add files via upload
ThrosturX Jul 10, 2022
0c76dd4
Add files via upload
ThrosturX Jul 10, 2022
02b0e34
Create escort_menu.png
ThrosturX Jul 10, 2022
5776c85
Add files via upload
ThrosturX Jul 10, 2022
9a08cba
Add files via upload
ThrosturX Jul 10, 2022
f0df05c
Add files via upload
ThrosturX Jul 10, 2022
43ab692
hopefully all the changes
ThrosturX Jul 10, 2022
d9f8735
Merge branch 'main' into ThrosturX-escorts
ThrosturX Jul 10, 2022
9319b62
Merge pull request #1 from naev/main
ThrosturX Jul 10, 2022
02507e6
typos mostly
ThrosturX Jul 10, 2022
0878b2c
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 11, 2022
b5bfa4d
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 12, 2022
4a513fc
mem.autoleader
ThrosturX Jul 12, 2022
d42d046
various fixes and improvements
ThrosturX Jul 13, 2022
659a2ab
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 13, 2022
3c00ab1
fix wrong portrait bug
ThrosturX Jul 13, 2022
dc1691f
Merge branch 'ThrosturX-escorts' of https://github.com/ThrosturX/naev…
ThrosturX Jul 13, 2022
6012bb9
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 14, 2022
3021826
minor fixes
ThrosturX Jul 14, 2022
e066129
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Jul 22, 2022
122774d
Update human.lua
ThrosturX Jul 22, 2022
dd7e4a7
Update artwork
ThrosturX Jul 22, 2022
a53b188
Merge branch 'ThrosturX-escorts' of https://github.com/ThrosturX/naev…
ThrosturX Jul 22, 2022
ebaf737
fix some luacheck errors
ThrosturX Aug 1, 2022
dfc2b38
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Aug 1, 2022
3a09aa1
more luacheck stuff
ThrosturX Aug 1, 2022
7ebdbfd
Merge branch 'ThrosturX-escorts' of https://github.com/ThrosturX/naev…
ThrosturX Aug 1, 2022
8d6f66e
Update scavenger_event.lua
ThrosturX Aug 1, 2022
c8ffdc1
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Aug 1, 2022
b41e1fa
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Aug 1, 2022
3a0b521
outfits -> outfitsList
ThrosturX Aug 14, 2022
d0ebe6e
Merge branch 'naev:main' into ThrosturX-escorts
ThrosturX Aug 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dat/ai/core/control/generic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ mem.form_pos = nil -- Position in formation (for follower)
mem.leadermaxdist = nil -- Distance from leader to run back to leader
mem.gather_range = 800 -- Radius in which the pilot looks for gatherables
mem.lanes_useneutral = false -- Whether or not to use neutral lanes
mem.autoleader = true -- automatically find a leader

--[[Control parameters: mem.radius and mem.angle are the polar coordinates
of the point the pilot has to follow when using follow_accurate.
Expand Down Expand Up @@ -465,7 +466,7 @@ function control ()

-- Select new leader
local l = p:leader()
if not mem.carried then -- carried ships don't change
if not mem.carried and mem.autoleader then -- carried ships don't change
if l == nil then
local candidate = ai.getBoss()
if candidate ~= nil and candidate:exists() then
Expand Down
135 changes: 135 additions & 0 deletions dat/ai/escort_guardian.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
require 'ai.escort'

-- Settings
mem.aggressive = true
mem.guardbrake = 350
mem.guarddodist = 3000 -- distance at which to start activities
mem.guardreturndist = 6000 -- distance at which to return
mem.enemyclose = mem.guarddodist
mem.atk_board = true
mem.send_escort = true
mem.autoleader = false

function create ()
create_pre()

local p = ai.pilot()
local ps = p:ship()

-- Default range stuff
mem.guarddodist = 1000 + 200 * ps:size()
mem.guardreturndist = mem.guarddodist + 2000
mem.enemyclose = mem.guarddodist

-- Finish up creation
create_post()
end

-- is it close to me or my protectee?
local function gdist( t )
return math.min(
player.pilot():pos():dist( t:pos() ),
ai.pilot():pos():dist( t:pos() )
)
end

local _should_attack = should_attack
function should_attack( enemy, si )
if _should_attack( enemy, si ) and gdist(enemy) < mem.guarddodist then
return true
end
return false
end

-- luacheck: globals idle (AI Task functions passed by name)
function idle ()

local pp = player.pilot()
local me = ai.pilot()
local subordinates = me:followers()

local hostiles = pp:getHostiles(mem.guarddodist, me:pos(), true, false, false)
local detected_hostile = nil
local can_send = rnd.rnd(1, #subordinates * 2) == #subordinates

for i, enemy in ipairs(hostiles) do
if should_attack(enemy) then
local dangerous = false
if enemy:ship():size() >= 3 then
dangerous = true
end

if dangerous then
for j, under in ipairs(subordinates) do
me:msg(under, "e_attack", enemy)
-- under:pushtask( "attack", enemy )
end
ai.pushtask( "attack", enemy )
return
else
-- send a random escort
if (can_send or mem.send_escort) and #subordinates > 0 then
me:msg(subordinates[rnd.rnd(1, #subordinates)], "e_attack", enemy)
mem.send_escort = false
end
end
end
end

-- get distance
local guarddist = ai.dist(pp:pos())
if guarddist > mem.guardreturndist then
ai.iface(pp)
ai.accel(1)
return
end

-- find something to board
hostiles = pilot.getInrange(me:pos(), mem.guarddodist)
for _i, target in ipairs(hostiles) do
if target:hostile() then
if mem.atk_board and ai.canboard(target) then
ai.pushtask("board", target )
return
elseif (should_attack(target) or (mem.aggressive and not ai.canboard(target))) and rnd.rnd(0, 1) == 0 then
-- a pot shot or two
ai.settarget( target )
ai.aim(target)
ai.shoot()
end
end
end

-- find nearby enemy
local enemy = detected_hostile
if not enemy then
enemy = ai.getenemy()
end
if enemy ~= nil then
for k, v in ipairs(me:followers()) do
me:msg ( v, "e_attack", enemy )
end
ai.pushtask("attack", enemy)
end

mem.send_escort = true

if guarddist < mem.guardbrake then
-- let him drift a bit
if rnd.rnd() > (guarddist / mem.guardbrake) then
-- brake
ai.brake()
else
-- just don't accelerate
ai.accel(0)
end
return
elseif guarddist < mem.guarddodist then
ai.face( pp, nil, true )
ai.accel((guarddist / mem.guarddodist) * rnd.rnd()) -- fun variability
return
end

ai.iface(pp)
ai.accel()
end
Loading