Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- actor_statistic = {
- recieved_quests = 0,
- completed_quests = 0,
- failed_quests = 0,
- killed_monsters = 0,
- killed_stalkers = 0,
- founded_secrets = 0,
- recieved_money = 0,
- spent_money = 0,
- }
- local killPointsLookup = {
- neutral_novice = 1, neutral_experienced = 2, neutral_veteran = 3, neutral_master = 4,
- monolith_novice = 1, monolith_experienced = 2, monolith_veteran = 3, monolith_master = 4,
- military_novice = 1, military_experienced = 2, military_veteran = 3, military_master = 4,
- killer_novice = 1, killer_experienced = 2, killer_veteran = 3, killer_master = 4,
- ecolog_novice = 1, ecolog_experienced = 2, ecolog_veteran = 3, ecolog_master = 4,
- dolg_novice = 1, dolg_experienced = 2, dolg_veteran = 3, dolg_master = 4,
- freedom_novice = 1, freedom_experienced = 2, freedom_veteran = 3, freedom_master = 4,
- bandit_novice = 1, bandit_experienced = 2, bandit_veteran = 3, bandit_master = 4,
- zombied_novice = 1, zombied_experienced = 2, zombied_veteran = 3, zombied_master = 4,
- tushkano_weak = 1,
- flesh_weak = 1, flesh_normal = 2, flesh_strong = 3,
- boar_weak = 1, boar_normal = 2, boar_strong = 3,
- dog_weak = 1, dog_normal = 2, dog_strong = 3,
- pseudodog_weak = 1, pseudodog_normal = 2, pseudodog_strong = 3,
- psy_dog_weak = 1, psy_dog_normal = 2, psy_dog_strong = 3,
- snork_weak = 2, snork_normal = 3, snork_strong = 4,
- poltergeist_weak = 2,
- pseudo_gigant_weak = 4,
- controller_weak = 4,
- bloodsucker_weak = 1, bloodsucker_normal = 2, bloodsucker_strong = 3
- }
- local killNameAlias = {
- tushkano_normal = "tushkano_weak", tushkano_strong = "tushkano_weak",
- poltergeist_normal = "poltergeist_weak", poltergeist_strong = "poltergeist_weak",
- pseudo_gigant_normal = "pseudo_gigant_weak", pseudo_gigant_strong = "pseudo_gigant_weak",
- controller_normal = "controller_weak", controller_strong = "controller_weak",
- psy_dog_weak = "psy_dog", psy_dog_normal = "psy_dog",
- psy_dog_strong = "psy_dog", rad_psy_dog = "psy_dog"
- }
- local clsidToMonsterMap = {
- [clsid.tushkano_s ] = "tushkano",
- [clsid.flesh_s ] = "flesh",
- [clsid.boar_s ] = "boar",
- [clsid.dog_s ] = "dog",
- [clsid.pseudodog_s ] = "pseudodog",
- [clsid.psy_dog_s ] = "psy_dog",
- [clsid.psy_dog_phantom_s] = "NIL",
- [clsid.snork_s ] = "snork",
- [clsid.poltergeist_s ] = "poltergeist",
- [clsid.gigant_s ] = "pseudo_gigant",
- [clsid.controller_s ] = "controller",
- [clsid.bloodsucker_s ] = "bloodsucker"
- }
- -- This excludes the 'army', which is a special case.
- local nonNeutralCommunities = {
- bandit = true,
- dolg = true,
- ecolog = true,
- freedom = true,
- killer = true,
- monolith = true,
- zombied = true
- }
- local IsStalker, rankGetByName, gameStatsAddPoints
- = IsStalker, ranks.get_obj_rank_name, actor_stats.add_points
- local npcTypeFormat = '%s_%s'
- local function getNpcType(npc)
- local clsid, rank, community = npc:clsid(), rankGetByName(npc)
- if IsStalker(npc, clsid) then
- community = npc:character_community()
- if community == 'army' then
- community = 'military'
- elseif nonNeutralCommunities[community] == nil then
- community = 'neutral'
- end
- return "stalkerkills", npcTypeFormat:format(community, rank)
- else
- community = clsidToMonsterMap[clsid]
- if community == nil then
- abort("[xr_statistic.getNpcType]: Missing clsid-to-monster mapping from clsid '%d' to '%s'.",
- clsid, npc:section())
- end
- if community == "NIL" then
- return nil, nil
- end
- return "monsterkills", npcTypeFormat:format(community, rank)
- end
- end
- function addKillCount(npc)
- local statName, section = getNpcType(npc)
- if statName == nil then
- return
- end
- local killName = killNameAlias[section]
- if killName == nil then
- killName = section
- end
- local points = killPointsLookup[killName]
- if points == nil then
- return
- end
- gameStatsAddPoints(statName, killName, 1, points)
- local act = db.actor
- act:set_character_rank(act:character_rank() + points)
- end
- function inc_recieved_quests_counter()
- actor_statistic.recieved_quests = actor_statistic.recieved_quests + 1
- end
- function inc_completed_quests_counter()
- actor_statistic.completed_quests = actor_statistic.completed_quests + 1
- end
- function inc_failed_quests_counter()
- actor_statistic.failed_quests = actor_statistic.failed_quests + 1
- end
- function inc_killed_monsters_counter()
- actor_statistic.killed_monsters = actor_statistic.killed_monsters + 1
- end
- function inc_killed_stalkers_counter()
- actor_statistic.killed_stalkers = actor_statistic.killed_stalkers + 1
- end
- function inc_founded_secrets_counter()
- actor_statistic.founded_secrets = actor_statistic.founded_secrets + 1
- end
- function inc_recieved_money_counter(amount)
- actor_statistic.recieved_money = actor_statistic.recieved_money + amount
- end
- function inc_spent_money_counter(amount)
- actor_statistic.spent_money = actor_statistic.spent_money + amount
- end
- function save(package)
- package:w_u16(actor_statistic.recieved_quests)
- package:w_u16(actor_statistic.completed_quests)
- package:w_u16(actor_statistic.failed_quests)
- package:w_u32(actor_statistic.killed_monsters)
- package:w_u32(actor_statistic.killed_stalkers)
- package:w_u16(actor_statistic.founded_secrets)
- package:w_u32(actor_statistic.recieved_money)
- package:w_u32(actor_statistic.spent_money)
- end
- function load(package)
- actor_statistic = {
- recieved_quests = package:r_u16(),
- completed_quests = package:r_u16(),
- failed_quests = package:r_u16(),
- killed_monsters = package:r_u32(),
- killed_stalkers = package:r_u32(),
- founded_secrets = package:r_u16(),
- recieved_money = package:r_u32(),
- spent_money = package:r_u32()
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement