Info portions and timer based event

Posts: 10
Joined: 11 Oct 2015, 12:41

Info portions and timer based event

Postby kcs123 » 19 Oct 2015, 12:31

Some background info why I asking for this in the first place.

Stripped off all info portions from game is blessing and curse at the same time. Reason why storyline is not compleatly removed from some mods is just that - so you can use info portions to control available equipment from traders and control smart terrain spawns.
Based on info portions, what quest actor is already finished or not, does some dangerous squad still exist in game world or not, you can "measure" progress in game and set smart terrain spawns based on those, set what kind of stuff you can buy from trader or should be able to hire some companions or not.

Before you add some storyline info portions, I would like to add some info portions based how bad or good actor reputation is towards other factions.
There is some function to check if NPC is enemy, neutral or friendly towards actor, but you can't figure out how good friend is actor toward faction/NPC or how much some faction/NPC hate actor.

When you start a game, based on chosen faction, actor is in some kind of relation to other factions. It is measured by relationship points that is in range from -5000 to 5000. For example, this is already in "game_relations.ltx" file:

Code: Select all

;              |actor|bandit| dolg|ecolog|freedom|killer|    army|monolith|monster|stalker| zombied|  csky |trader| actor_stalker | actor_bandit | actor_dolg | actor_freedom | actor_csky | actor_ecolog | actor_killer | actor_army | actor_monolith | actor_zombied
actor         =     0, -1100,    0,     0,      0, -2000,   -1000,   -5000,  -5000,      0,   -5000,     0,   0,         0,         0,            0,            0,         0,         0,            0,            0,            0,         -5000
bandit        = -1100,  5000,-5000,     0,  -5000, -5000,   -5000,   -5000,  -5000,  -1000,   -5000, -1000,   0,      -1100,        1000,         -5000,         -5000,      -1000,      -1000,         -1000,         -5000,         -5000,         -5000
dolg          =     0, -5000, 5000,     0,  -5000, -5000,       0,   -5000,  -5000,      0,   -5000,     0,   0,         0,      -5000,           1000,         -5000,          0,         0,         -1000,             0,         -5000,         -5000 
ecolog        =     0,     0,    0,     0,      0,     0,       0,   -5000,  -5000,      0,   -5000,     0,   0,         0,         0,            0,            0,         0,       1000,            0,            0,         -5000,         -5000
freedom       =     0, -5000,-5000,     0,   5000, -5000,   -5000,   -5000,  -5000,      0,   -5000,     0,   0,         0,      -5000,         -5000,           1000,         0,          0,         -1000,         -5000,         -5000,         -5000
killer        = -2000, -5000,-5000,     0,  -5000,     0,   -5000,   -5000,  -5000,  -1000,   -5000, -5000,   0,      -2000,      -5000,         -5000,         -5000,      -2000,         0,           1000,         -5000,         -5000,         -5000
army           = -1000, -5000,    0,     0,  -5000, -5000,    1000,   -5000,  -5000,  -1000,   -5000, -1000,   0,      -1100,      -5000,            0,         -2000,      -1000,         0,         -1000,           1000,         -5000,         -5000
monolith      = -5000, -5000,-5000, -5000,  -5000, -5000,   -5000,    1000,  -5000,  -5000,    1000, -5000,   0,      -5000,      -5000,         -5000,         -5000,      -5000,      -5000,         -5000,         -5000,           1000,          1000
monster       = -5000, -5000,-5000, -5000,  -5000, -5000,   -5000,   -5000,      0,  -5000,   -5000, -5000,   0,      -5000,      -5000,         -5000,         -5000,      -5000,      -5000,         -5000,         -5000,         -5000,            0
stalker       =     0, -1000,    0,     0,      0, -1000,   -1000,   -5000,  -5000,      0,   -5000,     0,   0,        500,      -1000,            0,            0,         0,         0,            0,         -1000,         -5000,         -5000

First thing, I would like to add info portion for each 1000 relationship points. For example for -5000 points you have "rel_bandit_0" info portion. If you are good to them, points are increasing and when you raise it to -4000 you get new info portion "rel_bandit_1" and so on, to max number of points of 5000 when you will get "rel_bandit_10" info portion.

But at the same time as you get new info portion for relationship, other info portions for that faction relationship should be removed, to make whole logic in trader config files and smart terrain config files easier to some degree.

Please correct me if I'm wrong, but to accomplish this, you need to add descriptions about those info portions in file "info_portions.xml"
Besides that, you also need to put some function that will make some calculations and give or remove those info portions in "xr_conditions.script".

Now, my question is, is it enough to add that new function in "xr_conditions.script" or some other script or there is also need to make some adjustment to game engine, so game engine can recognize those properly ?

Now, second part of thread title is about timer.
What I need is event that will be executed once per day in game or every couple of ingame hours, but every 24h should be good to start with and adjust later on if needed.

When timer triggers, new function should be executed that calculates actor-faction relationship points and reduce/raise those points towards original relationship points that were set when player is started game.
For example, you start with -1000 relationship points toward bandit faction, you have helped them somehow and raised points to +1000.
When timer executes, function should lower points by 100, so you end with +900 points after execution. But, if you are at -1000, same value as you started game, function should not lower it further. Or if you are below -1000 points, function should not raise points more than -1000.
Same for other factions too.

Idea behind this is to create failsafe checks, if you have been too bad to some faction, you can improve relation with them by avoid contact for some amount of time. Also if you have done some good deeds towards faction, you should keep doing similar, to keep your relation good enogh for that faction to alow you to buy good equipment, give you some discount at traders and so on.

Also, based on those info portions, military can call for heli only if you are in realy bad reputation with them - killed way too many military members, for example. How some moder will use that info portions or it will not be used at all is their will, should be easy configured in config files, but it will be much easier to have something like that.

I know that there is already some functions in "xr_conditions.script" and game_relations.xml, like "actor_goodwill_ge" that deals with that in similar way, also there is already reputations that is like this:

Code: Select all

terrible, very_bad, bad, neutral, good, very_good, excellent

But i don't know if that can be used at all for S_T and/or trader configs.

To summarize this post, I need some info how to fullfil such idea.

Beside info portions in file "info_portions.xml", is it enough to add that new function for info portion calculation in "xr_conditions.script" or there is also need to make some adjustment to game engine, so game engine can recognize those properly ?

What is best place(script) for function and timer that will be executed each ingame 24h and how it need to look like. I just need proper syntax to declare such function and start working on it, not whole function.

User avatar
Posts: 1368
Joined: 26 May 2012, 22:26

Re: Info portions and timer based event

Postby Alundaio » 20 Oct 2015, 00:48

game_relations.script has a bunch of functions you may find useful. You can get the exact community goodwill (faction relation) between two factions, or between a faction and a NPC (or the actor). So you won't need infoportions you can just check the value directly.

Call of Chernobyl uses them for discounts:

Code: Select all

discounts                                = {=actor_goodwill_ge(bandit:1200)} discount_3, {=actor_goodwill_ge(bandit:1000)} discount_2, discount_1

reputation is still used in engine, but not really handled by anything. In game_releation.ltx these are zeroed out and no scripts bother with it either. But I imagine you can re-utilize it.

As I described in that other thread info_portions.xml is not actually used at all. The engine code to read this is completely commented out. It was used in Shadows of Chernobyl and looks like they tore it out in 1.6. Not sure why. This explains why we had trouble Sidorovich's animations working when we first started working on the mod.

As for your timer, you want to use logic on space restrictors. They have a scheme for this already, it's called sr_idle. Can be thrown on any space restrictor. If you want it to be a timer that persists on all levels then you should just do it in script. But have a look at how nimble is handled in esc_2_12_order_process.ltx. This is a timer that keeps track when the order is ready.

If that is not feasible for what you want to do, then in script you can just make a timer with game.get_game_time(). The persistent storage system in CoC is able to encode game time. So it's just as easy as doing this in an update someplace:

Code: Select all

   local m_data = alife_storage_manager.get_state()
   -- create the timer
   if not (m_data.some_unique_timer_name) then
      m_data.some_unique_timer_name = game.get_game_time()
   if (game.get_game_time():diffSec(m_data.some_unique_timer_name) > 86400) then
      m_data.some_unique_timer_name = game.get_game_time() -- reset timer
      -- do something every 24 hours

Anything you put into the m_data table can persist through saves. Just make sure it's only bool, number, game_time, function or table datatypes. userdata needs to be setup properly to persist and only game_time is set up properly in _G.script. It's very nifty, GSC should have did this. Packet storage is hard as hell to debug.
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests