Skip to content

Commit d055f05

Browse files
Add detailed weapon status (holstered/wielding)
1 parent c1fc176 commit d055f05

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

gamedata/scripts/talker_game_queries.script

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,48 @@ function get_weapon(npc)
216216
return try(npc.active_item, npc)
217217
end
218218

219+
function get_weapon_info(npc)
220+
must_exist(npc, "get_weapon_info")
221+
222+
-- Check unstrapped state
223+
local is_unstrapped = try(npc.weapon_unstrapped, npc)
224+
225+
local weapon_str = nil
226+
local state = nil
227+
228+
-- Get best weapon (the one they would use)
229+
local best_weapon = try(npc.best_weapon, npc)
230+
-- Get active item (what is in hands)
231+
local active_item = try(npc.active_item, npc)
232+
233+
if is_unstrapped == true then
234+
-- Wielding
235+
local weapon_obj = (active_item and is_weapon(active_item)) and active_item or best_weapon
236+
if weapon_obj then
237+
weapon_str = get_item_description(weapon_obj)
238+
state = "wielding"
239+
end
240+
elseif is_unstrapped == false then
241+
-- Holstered (explicitly false)
242+
if best_weapon then
243+
weapon_str = get_item_description(best_weapon)
244+
state = "holstered"
245+
end
246+
else
247+
-- is_unstrapped returned nil (function missing or error)
248+
-- Fallback to active_item check
249+
if active_item and is_weapon(active_item) then
250+
weapon_str = get_item_description(active_item)
251+
state = "wielding"
252+
elseif best_weapon then
253+
weapon_str = get_item_description(best_weapon)
254+
state = "holstered"
255+
end
256+
end
257+
258+
return weapon_str, state
259+
end
260+
219261
-- RELATIONS
220262

221263
function get_relations(observer, target)

0 commit comments

Comments
 (0)