Skip to content

Commit

Permalink
v0.1-beta.7
Browse files Browse the repository at this point in the history
  • Loading branch information
bellyillish committed Sep 30, 2024
1 parent 30c629b commit 128a552
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 89 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ Overhauls the companion system for Anomaly/GAMMA. It includes a new UI, fixes se
#### 1. Default Combat
The original, engine-based combat system that companions used before.

#### 3. Monolith Combat
This existed in the code but was disabled. And for good reason as it was rudimentary and very buggy. I've completely rewritten this scheme but tried to keep the spirit of what the original author intended:

#### 3. Offensive Combat
1. When far from the enemy, the companion will move to a spot (random but roughly half way) between them and the enemy. They will use cover if possible.
2. At medium distance, they will move directly to a spot that's at close range to the enemy (random but roughly 20m). Again they will use cover if possible.
3. At close range they will keep moving around the enemy using any close cover.
Expand All @@ -59,14 +57,12 @@ This existed in the code but was disabled. And for good reason as it was rudimen
6. When reloading they will duck or move behind close cover.
7. They will crouch behind low cover and stand behind high cover when engaging.

#### 4. Camper Combat
Like Monolith Combat, this also existed but was disabled. I also rewrote this trying to keep the spirit of the original:

#### 4. Defensive Combat
1. If not "prone", companions will look for cover near their initial position.
2. If significantly injured, they will retreat to a safe place and recover. They will keep moving if pursued.
3. Every so often they will move to a new position but will always be tethered to within ~8m of their initial position.

**Note:** for Monolith and Camper Combat, companions "share" enemy positions with each other. If a companion loses sight of an enemy while fighting, as long as any other companion (or the player) sees that enemy they will be aware of the enemy's current position.
**Note:** for Offensive and Defensive Combat, companions "share" enemy positions with each other. If a companion loses sight of an enemy while fighting, as long as any other companion (or the player) sees that enemy they will be aware of the enemy's current position.

### Choose Between 3 Combat Readiness Modes:
---
Expand Down Expand Up @@ -97,7 +93,7 @@ Also, this mod enables the features below for companions only and disables them
- Fixes various issues with "prone" animations.
- Fixes issue with companions stopping at their last patrol waypoint.
- Fixes many (but not all or even most) issues with companions getting stuck behind obstacles/objects while moving to a destination.
- Fixes a bug causing companions to get stuck in scripted combat permanently and become unresponsive.
- Fixes a potential bug causing npcs to get stuck in a scripted combat scheme and ignore their condlist.
- Fixes a bug causing companions and enemies to ignore eachother when the companion is sneaking and they are within 30m of each other.
- Fixes various issues/inconsistencies with companion state setters in `axr_companions` and `dialogs_axr_companion`. It does so by using its own code lib to manage companion states.
- Fixes various issues with incorrect/bad values in various ltx files in both Anomaly and GAMMA.
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/scripts/mod_beh_companion_idiots.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on_combat = combat


![combat]
combat_type = {+npcx_beh_combat_tactics_camper} camper, {+npcx_beh_combat_tactics_monolith} monolith, nil
combat_type = {+npcx_beh_combat_tactics_offensive} offensive, {+npcx_beh_combat_tactics_defensive} defensive, {+npcx_beh_combat_tactics_camper} camper, {+npcx_beh_combat_tactics_monolith} monolith, nil


![beh@general]
Expand Down
6 changes: 6 additions & 0 deletions gamedata/configs/text/eng/idiots.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
<string id="st_idiots_combat_default">
<text>Default Combat</text>
</string>
<string id="st_idiots_combat_offensive">
<text>Offensive Combat</text>
</string>
<string id="st_idiots_combat_defensive">
<text>Defensive Combat</text>
</string>
<string id="st_idiots_combat_monolith">
<text>Monolith Combat</text>
</string>
Expand Down
21 changes: 19 additions & 2 deletions gamedata/configs/text/eng/idiots_mcm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@
<text>Enables/disables the tab number indicators that appear above companions when the UI is open.</text>
</string>

<!-- Combat Options -->
<string id="ui_mcm_idiots_subtitle_options_combat">
<text>Combat Options</text>
</string>
<string id="ui_mcm_idiots_options_oldCombat">
<text>Enable "Camper" and "Monolith" combat commands.</text>
</string>
<string id="ui_mcm_idiots_options_oldCombat_desc">
<text>Enables/disables commands to put companions into "Camper" and "Monolith" combat schemes. These schemes came with Anomaly but were disabled. Note that they can be buggy and are thus unsupported. You can assign keybinds to them but they can't be activated by the "Cycle Combat" keybind.</text>
</string>

<!-- Jobs Options -->
<string id="ui_mcm_idiots_subtitle_options_jobs">
<text>Looting and Gathering Options</text>
Expand All @@ -63,10 +74,10 @@
<string id="ui_mcm_idiots_options_jobs_note">
<text>NOTE: For looting and gathering to work properly in GAMMA, "311 NPC Stop Looting Dead Bodies" must be disabled.</text>
</string>
<string id="ui_mcm_idiots_options_npcLooting">
<string id="ui_mcm_idiots_options_noNpcLooting">
<text>Only Companions Can Loot and Gather Items</text>
</string>
<string id="ui_mcm_idiots_options_npcLooting_desc">
<string id="ui_mcm_idiots_options_noNpcLooting_desc">
<text>Enables/disables the ability for non-companion NPCs to loot and gather items. To preserve existing behavior, this would be ticked for GAMMA and unticked for Anomaly.</text>
</string>
<string id="ui_mcm_idiots_options_artifacts">
Expand Down Expand Up @@ -168,6 +179,12 @@
<string id="ui_mcm_idiots_subtitle_default">
<text>Default</text>
</string>
<string id="ui_mcm_idiots_subtitle_offensive">
<text>Offensive</text>
</string>
<string id="ui_mcm_idiots_subtitle_defensive">
<text>Defensive</text>
</string>
<string id="ui_mcm_idiots_subtitle_monolith">
<text>Monolith</text>
</string>
Expand Down
20 changes: 13 additions & 7 deletions gamedata/configs/text/rus/idiots.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<!-- Movement -->
<string id="st_idiots_movement">
<text>Movement</text>
<text>Äâèæåíèå</text>
</string>
<string id="st_idiots_follow">
<text>Ñëåäîâàòü</text>
Expand All @@ -47,7 +47,7 @@

<!-- Stances -->
<string id="st_idiots_stance">
<text>Stance</text>
<text>Ïîëîæåíèå</text>
</string>
<string id="st_idiots_stand">
<text>Ñòîÿòü</text>
Expand All @@ -61,7 +61,7 @@

<!-- Distance -->
<string id="st_idiots_distance">
<text>Distance</text>
<text>Äèñòàíöèÿ</text>
</string>
<string id="st_idiots_cover">
<text>Âñòàòü â óêðûòèå</text>
Expand All @@ -75,11 +75,17 @@

<!-- Combat -->
<string id="st_idiots_combat">
<text>Combat</text>
<text>Áîé</text>
</string>
<string id="st_idiots_combat_default">
<text>Îáû÷íûé áîé</text>
</string>
<string id="st_idiots_combat_offensive">
<text>Ðåæèì "Offensive"</text>
</string>
<string id="st_idiots_combat_defensive">
<text>Ðåæèì "Defensive"</text>
</string>
<string id="st_idiots_combat_monolith">
<text>Ðåæèì "Ìîíîëèò"</text>
</string>
Expand All @@ -89,7 +95,7 @@

<!-- Readiness -->
<string id="st_idiots_readiness">
<text>Readiness</text>
<text>Ïîâåäåíèå</text>
</string>
<string id="st_idiots_attack">
<text>Àòàêîâàòü âñåõ</text>
Expand All @@ -103,7 +109,7 @@

<!-- Jobs -->
<string id="st_idiots_jobs">
<text>Jobs</text>
<text>Çàäà÷è</text>
</string>
<string id="st_idiots_loot_items">
<text>Ñîáèðàòü ïðåäìåòû</text>
Expand All @@ -120,7 +126,7 @@

<!-- Formations -->
<string id="st_idiots_formation">
<text>Formation</text>
<text>Ïîñòðîåíèå</text>
</string>
<string id="st_idiots_bunch">
<text>Äâèãàòüñÿ âìåñòå</text>
Expand Down
21 changes: 19 additions & 2 deletions gamedata/configs/text/rus/idiots_mcm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@
<text>Enables/disables the tab number indicators that appear above companions when the UI is open.</text>
</string>

<!-- Combat Options -->
<string id="ui_mcm_idiots_subtitle_options_combat">
<text>Combat Options</text>
</string>
<string id="ui_mcm_idiots_options_oldCombat">
<text>Enable "Camper" and "Monolith" combat commands.</text>
</string>
<string id="ui_mcm_idiots_options_oldCombat_desc">
<text>Enables/disables commands to put companions into "Camper" and "Monolith" combat schemes. These schemes came with Anomaly but were disabled. Note that they can be buggy and are thus unsupported. You can assign keybinds to them but they can't be activated by the "Cycle Combat" keybind.</text>
</string>

<!-- Jobs Options -->
<string id="ui_mcm_idiots_subtitle_options_jobs">
<text>Looting and Gathering Options</text>
Expand All @@ -63,10 +74,10 @@
<string id="ui_mcm_idiots_options_jobs_note">
<text>NOTE: For looting and gathering to work properly in GAMMA, "311 NPC Stop Looting Dead Bodies" must be disabled.</text>
</string>
<string id="ui_mcm_idiots_options_npcLooting">
<string id="ui_mcm_idiots_options_noNpcLooting">
<text>Only Companions Can Loot and Gather Items</text>
</string>
<string id="ui_mcm_idiots_options_npcLooting_desc">
<string id="ui_mcm_idiots_options_noNpcLooting_desc">
<text>Enables/disables the ability for non-companion NPCs to loot and gather items. To preserve existing behavior, this would be ticked for GAMMA and unticked for Anomaly.</text>
</string>
<string id="ui_mcm_idiots_options_artifacts">
Expand Down Expand Up @@ -168,6 +179,12 @@
<string id="ui_mcm_idiots_subtitle_default">
<text>Îáû÷íûé áîé</text>
</string>
<string id="ui_mcm_idiots_subtitle_offensive">
<text>Ðåæèì "Offensive"</text>
</string>
<string id="ui_mcm_idiots_subtitle_defensive">
<text>Ðåæèì "Defensive"</text>
</string>
<string id="ui_mcm_idiots_subtitle_monolith">
<text>Ðåæèì "Ìîíîëèò"</text>
</string>
Expand Down
2 changes: 2 additions & 0 deletions gamedata/configs/ui/idiots_ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

<col group="combat">
<default />
<offensive />
<defensive />
<monolith />
<camper />
</col>
Expand Down
10 changes: 6 additions & 4 deletions gamedata/scripts/a_idiots_config.script
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package.path = package.path .. ".\\gamedata\\scripts\\?.lua;..\\gamedata\\scripts\\?.lua;"


MDATA_VER = "0.1-beta.5"
MDATA_VER = "0.1-beta.7"
MDATA_KEY = "USEFUL_IDIOTS"

-- companion state config
Expand Down Expand Up @@ -39,9 +39,11 @@ ACTIONS = {
name = "combat",
cycle = true,
actions = {
{name = "default", next = "monolith", default = true},
{name = "monolith", next = "camper", info = "npcx_beh_combat_tactics_monolith"},
{name = "camper", next = "default", info = "npcx_beh_combat_tactics_camper"},
{name = "default", next = "offensive", default = true},
{name = "offensive", next = "defensive", info = "npcx_beh_combat_tactics_offensive"},
{name = "defensive", next = "default", info = "npcx_beh_combat_tactics_defensive"},
{name = "monolith", info = "npcx_beh_combat_tactics_monolith"},
{name = "camper", info = "npcx_beh_combat_tactics_camper"},
}
},
{
Expand Down
27 changes: 20 additions & 7 deletions gamedata/scripts/modxml_idiots_ui.script
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,18 @@ end


function applyOptions(XML, config)
if not config.oldCombat then
local monolith = XML:queryOne("monolith")
local camper = XML:queryOne("camper")

if monolith then
XML:removeElement(monolith)
end
if camper then
XML:removeElement(camper)
end
end

if not config.jobs then
local jobs = XML:queryOne("col[group=jobs]")
if jobs then
Expand Down Expand Up @@ -480,13 +492,14 @@ function onReadHUDXML(name, XML)
end

local config = {
jobs = ui_mcm.get("idiots/options/jobs"),
artifacts = ui_mcm.get("idiots/options/artifacts"),
font = ui_mcm.get("idiots/options/font"),
scaleX = ui_mcm.get("idiots/options/scaleX"),
scaleY = ui_mcm.get("idiots/options/scaleY"),
offsetX = ui_mcm.get("idiots/options/offsetX"),
offsetY = ui_mcm.get("idiots/options/offsetY"),
oldCombat = ui_mcm.get("idiots/options/oldCombat"),
jobs = ui_mcm.get("idiots/options/jobs"),
artifacts = ui_mcm.get("idiots/options/artifacts"),
font = ui_mcm.get("idiots/options/font"),
scaleX = ui_mcm.get("idiots/options/scaleX"),
scaleY = ui_mcm.get("idiots/options/scaleY"),
offsetX = ui_mcm.get("idiots/options/offsetX"),
offsetY = ui_mcm.get("idiots/options/offsetY"),
}

DXML.extendXMLObject(XML)
Expand Down
49 changes: 32 additions & 17 deletions gamedata/scripts/z_idiots_combat.script
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
local U = z_idiots_utils
local C = z_idiots_companions


EVAL_FACER = xrs_facer.evid_facer
EVAL_FACER_STEAL_UP = xrs_facer.evid_steal_up_facer
EVAL_ENEMY = stalker_ids.property_enemy
EVAL_LOGIC = xr_evaluators_id.state_mgr + 4
EVAL_CAMPER = xr_evaluators_id.combat_camper_base
EVAL_MONOLITH = xr_evaluators_id.combat_monolith_base
ACTION_CAMPER = xr_actions_id.combat_camper_base
ACTION_MONOLITH = xr_actions_id.combat_monolith_base


local U = z_idiots_utils
local C = z_idiots_companions
local OFFENSIVE = z_idiots_combat_offensive
local DEFENSIVE = z_idiots_combat_defensive
local __combat_evaluate = xr_combat.evaluator_check_combat.evaluate
local __is_enemy = xr_combat_ignore.is_enemy
local __add_to_binder = xr_combat.add_to_binder
EVAL_FACER = xrs_facer.evid_facer
EVAL_FACER_STEAL_UP = xrs_facer.evid_steal_up_facer
EVAL_ENEMY = stalker_ids.property_enemy
EVAL_LOGIC = xr_evaluators_id.state_mgr + 4


-- utils: combat --
Expand Down Expand Up @@ -69,7 +64,7 @@ COMBAT_ANIMATIONS = {
}


function U.updateEnemy(npc, st)
function U.updateEnemy(npc, st, forcePos)
local enemy = npc:best_enemy()

st.enemyID = nil
Expand All @@ -85,7 +80,7 @@ function U.updateEnemy(npc, st)
return
end

st.enemySeen = npc:see(enemy)
st.enemySeen = npc:see(enemy) or forcePos
st.enemyPredict = st.seeTime and time_global() <= st.seeTime

local newPos = nil
Expand Down Expand Up @@ -243,7 +238,8 @@ end


-- fix: update combat type before evaluating
-- prevents NPCs from getting permanently stuck in scripted combat
-- makes condlists work with combat types
-- which prevents NPCs from getting stuck in scripted combat
function xr_combat.evaluator_check_combat:evaluate()
xr_combat.set_combat_type(self.object, db.actor, self.st)
return __combat_evaluate(self)
Expand Down Expand Up @@ -306,3 +302,22 @@ function xr_combat_ignore.is_enemy(npc, enemy, no_memory)

return isEnemy
end


function xr_combat.add_to_binder(npc, ini, scheme, section, storage, temp)
__add_to_binder(npc, ini, scheme, section, storage, temp)

if not U.isCompanion(npc) then
return
end

local manager = npc:motivation_action_manager()
if not manager then
return
end

if temp.section then
OFFENSIVE.add_to_binder(npc, ini, storage, manager, temp)
DEFENSIVE.add_to_binder(npc, ini, storage, manager, temp)
end
end
Loading

0 comments on commit 128a552

Please sign in to comment.