add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
244
gamedata/scripts/inventory_upgrades.script
Normal file
244
gamedata/scripts/inventory_upgrades.script
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
---------------------------------------------------------------------------------------------
|
||||
--' funtions for upgerade items ----------------------------------------------------
|
||||
--' Made by Distemper ----------------------------------------------------------------
|
||||
--' 03.08 --------------------------------------------------------------------------------
|
||||
--' ôóíêöèÿ äîñòóïíîñòè àïãðåéäà
|
||||
--' function precondition_functor_a( param1, section )
|
||||
--' ôóíêöèÿ ïðèìåíåíèÿ àïãðåéäà (îòíèìàíèå äåíåã)
|
||||
--' function effect_functor_a( param2, section )
|
||||
--' ôóíêöèÿ îòîáðàæåíèÿ íóæíûõ ñäåäñòâ äëÿ àïãðåéäà
|
||||
--' function prereq_functor_a( param3, section )
|
||||
--' ôóíêöèÿ âðåìåííî íå èñïîëüçóåòüñÿ
|
||||
--' function prereq_tooltip_functor_a( param3 )
|
||||
--' ôóíêöèè äëÿ îòîáðàæåíèÿ ñâîéñòâ àïãðåéäîâ
|
||||
--' function property_functor_a( param1, name )
|
||||
--' function property_functor_b( param1, name )
|
||||
--' function property_functor_c( param1, name )
|
||||
--' ôóíêöèÿ äëÿ îòîáðàæåíèÿ ñïåöèàëèçàöèè òåõíèêà
|
||||
--------------------------------------------------------------------------------------------
|
||||
cur_hint = nil
|
||||
local issue_condlist = true
|
||||
local mechanic_name = ""
|
||||
local char_ini = ini_file("item_upgrades.ltx")
|
||||
local param_ini = ini_file("misc\\stalkers_upgrade_info.ltx")
|
||||
local cur_price_percent = 1
|
||||
function precondition_functor_a( param1, section )
|
||||
if(param_ini:line_exist(mechanic_name.."_upgr", section)) then
|
||||
local param = param_ini:r_string(mechanic_name.."_upgr", section)
|
||||
if(param) then
|
||||
if(param=="false") then
|
||||
return 1
|
||||
elseif(param~="true") then
|
||||
local possibility_table = xr_logic.parse_condlist(victim, mechanic_name.."_upgr", section, param)
|
||||
local possibility = xr_logic.pick_section_from_condlist(db.actor, victim, possibility_table)
|
||||
if not(possibility) or (possibility=="false") then
|
||||
return 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if(db.actor) then
|
||||
local price = math.floor(char_ini:r_u32(section, "cost")*cur_price_percent)
|
||||
local cash = db.actor:money()
|
||||
if(cash<price) then
|
||||
return 2
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function effect_functor_a( param2, section, loading ) --( string, string, int )
|
||||
if loading == 0 then
|
||||
local money = char_ini:r_u32(section, "cost")
|
||||
db.actor:give_money(math.floor(money*-1*cur_price_percent))
|
||||
end
|
||||
end
|
||||
|
||||
function get_upgrade_cost(section)
|
||||
if db.actor then
|
||||
local price = math.floor(char_ini:r_u32(section, "cost")*cur_price_percent)
|
||||
return game.translate_string("st_upgr_cost")..": "..price
|
||||
end
|
||||
return " "
|
||||
end
|
||||
|
||||
function get_possibility_string(mechanic_name, possibility_table)
|
||||
local str = ""
|
||||
if(cur_hint) then
|
||||
for k,v in pairs(cur_hint) do
|
||||
str = str.."\\n - "..game.translate_string(v)
|
||||
end
|
||||
end
|
||||
if(str=="") then
|
||||
str = " - add hints for this upgrade"
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function prereq_functor_a( param3, section )
|
||||
local str = ""
|
||||
if(param_ini:line_exist(mechanic_name.."_upgr", section)) then
|
||||
local param = param_ini:r_string(mechanic_name.."_upgr", section)
|
||||
if(param) then
|
||||
if(param=="false") then
|
||||
return str
|
||||
else
|
||||
cur_hint = nil
|
||||
local possibility_table = xr_logic.parse_condlist(victim, mechanic_name.."_upgr", section, param)
|
||||
local possibility = xr_logic.pick_section_from_condlist(db.actor, victim, possibility_table)
|
||||
if not(possibility) or (possibility=="false") then
|
||||
str = str..get_possibility_string(mechanic_name, possibility_table)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if(db.actor) then
|
||||
local price = math.floor(char_ini:r_u32(section, "cost")*cur_price_percent)
|
||||
local cash = db.actor:money()
|
||||
if(cash<price) then
|
||||
return str.."\\n - "..game.translate_string("st_upgr_enough_money")--.." "..price-cash.." RU"
|
||||
end
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function property_functor_a( param1, name )
|
||||
local prorerty_name = char_ini:r_string(name, "name")
|
||||
local t_prorerty_name = game.translate_string(prorerty_name)
|
||||
local section_table = utils.parse_names(param1)
|
||||
local section_table_n = #section_table
|
||||
local section = section_table[1]
|
||||
if(section_table_n==0) then
|
||||
return ""
|
||||
end
|
||||
local value = 0
|
||||
local sum = 0
|
||||
for i = 1,section_table_n do
|
||||
if not(char_ini:line_exist(section_table[i], "value")) or not(char_ini:r_string(section_table[i], "value")) then
|
||||
return t_prorerty_name
|
||||
end
|
||||
value = char_ini:r_string(section_table[i], "value")
|
||||
if(name~="prop_night_vision") then
|
||||
sum = sum + tonumber(value)
|
||||
else
|
||||
sum = tonumber(value)
|
||||
end
|
||||
end
|
||||
if(sum<0) then
|
||||
value = sum
|
||||
else
|
||||
value = "+"..sum
|
||||
end
|
||||
|
||||
if(name=="prop_ammo_size" or name=="prop_artefact") then
|
||||
return t_prorerty_name.." "..value
|
||||
elseif(name=="prop_restore_bleeding" or name=="prop_restore_health" or name=="prop_power") then
|
||||
if(name=="prop_power") then
|
||||
value = "+"..tonumber(value)*2
|
||||
end
|
||||
-- local str = string.format("%s %4.1f", t_prorerty_name, value)
|
||||
-- return str
|
||||
return t_prorerty_name.." "..value
|
||||
elseif(name=="prop_tonnage" or name=="prop_weightoutfit" or name=="prop_weight") then
|
||||
local str = string.format("%s %5.2f %s", t_prorerty_name, value, game.translate_string("st_kg"))
|
||||
return str
|
||||
elseif(name=="prop_night_vision") then
|
||||
if(tonumber(value)==1) then
|
||||
return t_prorerty_name
|
||||
else
|
||||
return game.translate_string(prorerty_name.."_"..tonumber(value))
|
||||
end
|
||||
elseif(name=="prop_no_buck" or name=="prop_autofire") then
|
||||
return t_prorerty_name
|
||||
end
|
||||
return t_prorerty_name.." "..value.."%"
|
||||
end
|
||||
|
||||
function property_functor_b( param1, name )
|
||||
return issue_property( param1, name )
|
||||
end
|
||||
|
||||
function property_functor_c( param1, name )
|
||||
return issue_property( param1, name )
|
||||
end
|
||||
|
||||
function need_victim(obj)
|
||||
victim = obj
|
||||
end
|
||||
|
||||
function issue_property( param1, name )
|
||||
local prorerty_name = char_ini:r_string(name, "name")
|
||||
local t_prorerty_name = game.translate_string(prorerty_name)
|
||||
local value_table = utils.parse_names(param1)
|
||||
local section = value_table[1]
|
||||
if section then
|
||||
if not char_ini:line_exist(section, "value") or not char_ini:r_string(section, "value") then
|
||||
return t_prorerty_name
|
||||
end
|
||||
local value = char_ini:r_string(section, "value")
|
||||
return t_prorerty_name.." "..string.sub(value, 2, -2)
|
||||
else
|
||||
return t_prorerty_name
|
||||
end
|
||||
end
|
||||
|
||||
local function how_much_repair( item_name, item_condition )
|
||||
local ltx = system_ini()
|
||||
local cost = ltx:r_u32(item_name, "cost")
|
||||
local class = ltx:r_string(item_name, "class")
|
||||
local cof = 0.6
|
||||
return math.floor(cost*(1-item_condition)*cof * cur_price_percent)
|
||||
end
|
||||
|
||||
function can_repair_item( item_name, item_condition, mechanic ) --( string, float, string )
|
||||
if(item_name=="pri_a17_gauss_rifle") then
|
||||
return false
|
||||
end
|
||||
local price = how_much_repair( item_name, item_condition )
|
||||
if db.actor:money() < price then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function question_repair_item( item_name, item_condition, can, mechanic ) --( string, float, bool, string )
|
||||
if(item_name=="pri_a17_gauss_rifle") then
|
||||
return game.translate_string("st_gauss_cannot_be_repaired")
|
||||
end
|
||||
local price = how_much_repair( item_name, item_condition )
|
||||
if db.actor:money() < price then
|
||||
return game.translate_string("st_upgr_cost")..": "..price.." RU\\n"..game.translate_string("ui_inv_not_enought_money")..": "..price-db.actor:money().." RU"
|
||||
end
|
||||
return game.translate_string("st_upgr_cost").." "..price.." RU. "..game.translate_string("ui_inv_repair").."?"
|
||||
end
|
||||
|
||||
function effect_repair_item( item_name, item_condition )
|
||||
if mechanic_name ~= "kat_cs_commander" then
|
||||
local price = how_much_repair( item_name, item_condition )
|
||||
db.actor:give_money(-price)
|
||||
end
|
||||
end
|
||||
|
||||
function can_upgrade_item( item_name, mechanic )
|
||||
mechanic_name = mechanic
|
||||
setup_discounts()
|
||||
if param_ini:line_exist(mechanic, "he_upgrade_nothing") then
|
||||
return false
|
||||
end
|
||||
if not param_ini:line_exist(mechanic, item_name) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function setup_discounts()
|
||||
if param_ini:line_exist(mechanic_name, "discount_condlist") then
|
||||
local condlist = param_ini:r_string(mechanic_name, "discount_condlist")
|
||||
local parsed = xr_logic.parse_condlist(db.actor, nil, nil, condlist)
|
||||
xr_logic.pick_section_from_condlist(db.actor, nil, parsed)
|
||||
end
|
||||
end
|
||||
|
||||
function mech_discount(perc)
|
||||
cur_price_percent = perc
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue