add game&rawdata

This commit is contained in:
Vasily Petrov 2026-06-17 23:06:51 +03:00
parent 0133cd976c
commit 49b34b5546
45731 changed files with 709831 additions and 0 deletions

View file

@ -0,0 +1,344 @@
-- îòíîøåíèå ïåðñîíàæà ê àêòåðó (èëè äðóãîìó NPC) âû÷èñëÿåòñÿ ïî ôîðìóëå:
-- attitude = personal_goodwill + -- ëè÷íîå îòíîøåíèå ïåðñîíàæà ê àêòåðó (åñëè ðàíüøå íå âñòðå÷àëèñü, òî 0)
-- community_goodwill + -- îòíîøåíèå ãðóïïèðîâêè ïåðñîíàæà ëè÷íî ê àêòåðó (åñëè ðàíüøå êîíòàêòîâ íå áûëî, òî 0)
-- community_to_community + -- îòíîøåíèå ãðóïïèðîâêè ïåðñîíàæà ê ãðóïïèðîâêå àêòåðà èç [communities_relations]
-- reputation_goodwill + -- îòíîøåíèå ðåïóòàöèè ïåðñîíàæà ê ðåïóòàöèè àêòåðà èç [reputation_relations]
-- rank_goodwill -- îòíîøåíèå ðàíãà ïåðñîíàæà ê ðàíãó àêòåðà èç [rank_relations]
FRIENDS = 1000
NEUTRALS = 0
ENEMIES = -1000
default_sympathy = 0.01
game_relations_by_num = { [0] = "friend",
[1] = "neutral",
[2] = "enemy",
}
temp_goodwill_table = {}
function set_factions_community(faction, faction_to, new_community)
if(faction~=nil) and (faction~="none") and (faction_to~="none") then
local community = 0
if(new_community=="enemy") then
community = -5000
elseif(new_community=="friend") then
community = 5000
end
set_factions_community_num(faction, faction_to, community)
else
--printf("No such faction community: "..tostring(faction))
end
end
function set_factions_community_num(faction, faction_to, new_community_num)
if(faction~=nil) and (faction~="none") and (faction_to~="none") then
relation_registry.set_community_relation(faction, faction_to, new_community_num)
else
--printf("No such faction community: "..tostring(faction))
end
end
function change_factions_community_num(faction_name, obj_id, delta)
if(faction_name~=nil) and (faction_name~="none") and (obj_id ~= nil) then
relation_registry.change_community_goodwill(faction_name, obj_id, delta)
else
printf("No such faction community: "..tostring(faction))
end
end
function get_factions_community(faction, faction_to)
if(faction~=nil) and (faction~="none") and (faction_to~="none") then
return relation_registry.community_relation(faction, faction_to)
else
--printf("No such faction community: "..tostring(faction))
return nil
end
end
function is_factions_friends(faction, faction_to)
if(faction~=nil) and (faction~="none") and (faction_to~="none") then
return relation_registry.community_relation(faction, faction_to)>=FRIENDS
else
--printf("No such faction community: "..tostring(faction))
return false
end
end
function is_factions_enemies(faction, faction_to)
if(faction~=nil) and (faction~="none") and (faction_to~="none") then
return relation_registry.community_relation(faction, faction_to)<=ENEMIES
else
--printf("No such faction community: "..tostring(faction))
return false
end
end
function get_npcs_relation(npc1, npc2)
return npc1 and npc2 and npc1:relation(npc2)
end
function set_npcs_relation(npc1, npc2, new_relation)
local goodwill = 0
if(new_relation=="enemy") then
goodwill = -1000
elseif(new_relation=="friend") then
goodwill = 1000
end
if npc1 and npc2 then
npc1:force_set_goodwill(goodwill, npc2)
else
abort("Npc not set in goodwill function!!!")
end
end
function get_npc_sympathy(npc)
return npc:sympathy()
end
function set_npc_sympathy(npc, new_sympathy)
if(new_sympathy<0) then
new_sympathy = 0
elseif(new_sympathy>1) then
new_sympathy = 1
end
if npc then
npc:set_sympathy(new_sympathy)
else
abort("Npc not set in sympathy function!!!")
end
end
function set_squad_goodwill(squad_id, new_goodwill)
printf("Applying new game relation [%s] between squad [%s] and npc [%s] !", new_goodwill, squad_id, "actor")
local squad = get_story_squad(squad_id)
if squad == nil then
if type(squad_id) == "string" then
printf("there is no story squad with id [%s]", squad_id)
return
else
squad = alife():object(squad_id)
end
end
if squad then
squad:set_squad_relation(new_goodwill)
else
abort("There is no squad [%s] in sim_board", squad_id)
end
end
function set_squad_goodwill_to_npc(npc, squad_id, new_goodwill)
printf("Applying new game relation [%s] between squad [%s] and npc [%s] !", new_goodwill, squad_id, npc:name())
local goodwill = 0
if(new_goodwill=="enemy") then
goodwill = -1000
elseif(new_goodwill=="friend") then
goodwill = 1000
end
local squad = get_story_squad(squad_id)
if squad == nil then
if type(squad_id) == "string" then
printf("there is no story squad with id [%s]", squad_id)
return
else
squad = alife():object(squad_id)
end
end
if squad then
for k in squad:squad_members() do
if npc then
k.object:force_set_goodwill(goodwill, npc:id())
alife():object(npc:id()):force_set_goodwill(goodwill, k.id)
end
end
else
abort("There is no squad [%s] in sim_board", squad_id)
end
end
function set_squad_community_goodwill(squad_id, community, new_goodwill)
local goodwill = 0
if(new_goodwill=="enemy") then
goodwill = -1000
elseif(new_goodwill=="friend") then
goodwill = 1000
end
local squad = get_story_squad(squad_id)
if squad == nil then
if type(squad_id) == "string" then
printf("there is no story squad with id [%s]", squad_id)
return
else
squad = alife():object(squad_id)
end
end
if squad then
for k in squad:squad_members() do
local obj = db.storage[k.id] and db.storage[k.id].object
if(obj) then
obj:set_community_goodwill(community, goodwill)
end
end
else
abort("There is no squad [%s] in sim_board", squad_id)
end
end
function set_level_faction_community(obj)
if(temp_goodwill_table.communities~=nil) then
for k,v in pairs(temp_goodwill_table.communities) do
if(character_community(obj)==k) then
for kk,vv in pairs(v) do
if(kk==obj:id()) and db.actor then
relation_registry.set_community_goodwill(k, db.actor:id(), vv)
-- run_string xr_effects.set_level_faction_community(nil, nil, {"bandit", "peacemaker_selo", "friend"})
obj:force_set_goodwill(vv, db.actor)
v[kk] = nil
end
end
end
end
end
end
function check_all_squad_members(squad_name, goodwill)
local squad = get_story_squad(squad_name)
if squad == nil then return false end
if db.actor == nil then return false end
for k in squad:squad_members() do
local is_enemy
if goodwill == "enemy" then
--printf("npc id = [%s]", k)
-- if (db.storage[k] ~= nil) and (db.storage[k].object ~= nil) then
-- printf("goodwill is [%s]", tostring(db.storage[k].object:general_goodwill(db.actor)))
--end
is_enemy = db.storage[k.id] and db.storage[k.id].object and db.storage[k.id].object:general_goodwill(db.actor)<=ENEMIES
else
is_enemy = db.storage[k.id] and db.storage[k.id].object and db.storage[k.id].object:general_goodwill(db.actor)>=FRIENDS
end
if is_enemy then
return true
end
end
return false
end
function get_squad_goodwill_to_actor_by_id(squad_id)
local squad = alife():object(squad_id)
if(squad==nil) then
abort("No such squad %s in board", tostring(squad_id))
return false
end
if(squad.relationship~=nil) then
--printf(" squad_relation %s", tostring(squad.relationship))
return squad.relationship
else
local goodwill = "neutral"
if(relation_registry.community_relation(squad:get_squad_community(), alife():actor():community())>=FRIENDS) then
goodwill = "friend"
elseif(relation_registry.community_relation(squad:get_squad_community(), alife():actor():community())<=ENEMIES) then
goodwill = "enemy"
end
return goodwill
end
end
function get_squad_goodwill_to_actor(squad_name)
local squad = get_story_squad(squad_name)
if(squad==nil) then
abort("No such squad %s in board", tostring(squad_name))
return false
end
if(squad.relationship~=nil) then
--printf(" squad_relation %s", tostring(squad.relationship))
return squad.relationship
else
local goodwill = "neutral"
if(relation_registry.community_relation(squad:get_squad_community(), alife():actor():community())>=FRIENDS) then
goodwill = "friend"
elseif(relation_registry.community_relation(squad:get_squad_community(), alife():actor():community())<=ENEMIES) then
goodwill = "enemy"
end
return goodwill
end
end
function is_squad_enemy_to_actor(squad_name)
return get_squad_goodwill_to_actor(squad_name)=="enemy"
end
function is_squad_friend_to_actor(squad_name)
return get_squad_goodwill_to_actor(squad_name)=="friend"
end
function is_squad_neutral_to_actor(squad_name)
return get_squad_goodwill_to_actor(squad_name)=="neutral"
end
function set_gulag_relation_actor(smart_name, relation)
local gulag = xr_gulag.get_gulag_by_name(smart_name)
local goodwill = 0
if(relation=="enemy") then
goodwill = -1000
elseif(relation=="friend") then
goodwill = 1000
end
for k,v in pairs(gulag.npc_info) do
local object = db.storage[v.se_obj.id] and db.storage[v.se_obj.id].object
if(object) then
object:force_set_goodwill(goodwill, db.actor)
object:set_community_goodwill(character_community(db.actor), goodwill)
end
end
end
function get_gulag_relation_actor(smart_name, relation)
local gulag = xr_gulag.get_gulag_by_name(smart_name)
if gulag then
local goodwill = 0
local npc_count = 0
for k,v in pairs(gulag.npc_info) do
local object = db.storage[v.se_obj.id] and db.storage[v.se_obj.id].object
if object and db.actor then
goodwill = goodwill + object:general_goodwill(db.actor)
npc_count = npc_count + 1
end
end
if npc_count ~= 0 then
local delta = goodwill/npc_count
if relation == "enemy" and delta <= ENEMIES then
return true
elseif relation == "friend" and delta >= FRIENDS then
return true
elseif relation == "neutral" and delta < FRIENDS and delta > ENEMIES then
return true
end
end
end
return false
end
function get_squad_relation_to_actor_by_id(squad_id)
local squad = alife():object(squad_id)
if(squad==nil) then
abort("No such squad %s in board", tostring(squad_id))
end
local goodwill = 0
local npc_count = 0
for k in squad:squad_members() do
local object = db.storage[k.id] and db.storage[k.id].object
if object and db.actor then
goodwill = goodwill + object:general_goodwill(db.actor)
npc_count = npc_count + 1
end
end
if npc_count ~= 0 then
local delta = goodwill/npc_count
if delta <= ENEMIES then
return "enemy"
elseif delta >= FRIENDS then
return "friends"
elseif delta < FRIENDS and delta > ENEMIES then
return "neutral"
end
end
return "enemy"
end