ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod downloads
"xr_companions" scheme reanimation - companions mod for SHoC

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  09:30:09  19 November 2010
profilee-mailreply Message URLTo the Top
On forum: 03/11/2009

Message edited by:
11/20/2010 21:12:34
Messages: 85
"xr_companions" scheme reanimation - companions mod for SHoC

This is the fully english-translated release of my "Компаньоны" mod. It's created in the process of my work on OGSE mod, on base of disabled xr_companions behavior scheme - i almost totally rewrite it and now it's available for clear game as a stand-alone mod.

Latest Version: 1.9
Game version required: any original SHoC release ver. 1.0004-1.0006
Size: 3.41 Mb
Download links:

Adaptation for XiaNi Freeplay Start 1.21 fixed 2 (still needs testing):

Mod discussion thread:

Mod readme:

- 2010 © Alexey "KamikaZze", reconstruction of behavior scheme "Companions"
- Please send feedback via e-mail:
- Many thanks to kolinkoff YouTube user for supplying me
- the english version of original game and for the testing -
- this made my release possible. Thanks again to kolinkoff!

Anticipating some questions I have to say the following:

This is not a clone of "Partners" mod and not its conversion; this scheme has been written almost from scratch, but in this scheme I used one of "Partners" algorithms (jumping of NPC between locations) by Dmitry Roshchin aka Red75 and for that my acknowledgements to him. The idea proved to be convenient and very viable. In fact I've just adjusted the implementation of his method so that its use does not interfere with the normal operation of conventional NPCs in smart terrains. This scheme is based on a small scheme xr_companion from original and the builds by Sergei Vinnichenko. This scheme worked in a build 2205 but in release it was disabled. As useless apparently - it haven't been finished.

So that's the companions. This behavior scheme allows you to invite NPC as a companion and together explore the Zone. Idea of reconstructing this scheme was born when I saw it initially in build 2205 and decided to revive for our global mod - OGSE (Old Good Stalker Evolution). In this case I tried to give scheme maximum flexibility and functionality as much as been possible, while also tried to avoid potential problems - so that the player didn't required to nurse his mate, pulling him out of any trouble.

WARNING! During the operation of the scheme it had been discovered that some (fairly rare) NPCs behave strangely when hiring - do not go after the Player, staring dully into space, do not pass through the levels. It is a conflict between the behavior scheme and built-in logic, it happens mostly with guards of scripting camps. If you hired such NPC - leave it alone and hire another.

Also in this package included custom gamegraph of original game corrected by me especially for this behavior scheme. The length of all transitions between locations had been reduced to a minimum and eventually your partner overcomes transitions between locations almost immediately - within 10-20 game minutes (1-2 real time minutes).


So in OGSE, OGSM and AMK too, if I remember correctly, you can use custom gamegraph completely painless, as they wasn't changed it. If, however, you install it on the mod which already contains edited gamegraph (ANY mod with new locations) game will behave unpredictably, or new locations became unreachable, so don't even try.

The main features of the scheme:

1. Mate follows you wisely - no chasing stray dogs and wild boars, no trying to chase them through the entire location, so don't panic.
2. If you decide to escape combat - a partner will escape with you, not reacting to the enemy. This allows us to get out of the fire without the risk of once again taking the fight against superior enemy forces.
3. With a partner you can direct exchange goods for no price - via trade menu. Exchange is free which is convenient.
4. All settings are stored in a special scheme repository inside the companion's packet - for this I used utility functions from a library of utilities for working with net packets - m_net_utils (SIMBION: SHOC mod), author Artos. The library is included.
5. Mate can disguise armor when used in conjunction with the scheme xrs_armor, author xStream. Modified for this purpose scheme xrs_armor attached. Notice that it's not acivated just from box and needs to be edited before use.
6. To use mods in which player can join the factions the scheme supports the following factions companions: a loner, duty, freedom, gangster, zombie (the latter experimental, working but not very good). Moreover, each faction in the scheme have their own style of dialogs. For the integration scheme in such mods you should check IDs of factions in function community_by_actor (actor_comm) and, if needed, rewrite. Companions can be hired only from the faction to which player now belongs. In addition to the binder of scheme immediately entered evaluators of behavior schemes xrs_grenade, xrs_medic, rx_bandage, rx_facer, rx_reload, and anomaly_evader, so that it can be used together with xr_companions with minimal adjustments together with anomalies evade packs of logic and the arms manager (from AI Pack).
7. Following restrictions apply to the hiring of teammates:

1) You cannot hire quest NPCs (for obvious reasons)
2) Player has bad reputation in faction
3) This is some of the prisoners
4) Player experience is lower than NPC
5) Player much more experienced than NPC (beginners are afraid to go with the experienced stalkers, fearing that they use them as a "jemmy"
6) The Player already have a partner (with a little edits this scheme could support more than one partner, but for me it was not appropriate as heavily disbalancing the game, so I did not do it - and please don't ask - if you are skilled enough you can add this yourself)
7) Player from other faction (can be turned off if necessary: edit in the header of xr_companions.script parameter other_factions_switch)
8) Too many companions were died with Player

8. Yes, the scheme is counting and recording "death toll". If you had lost in action more than 4 NPCs they will refuse to go with you. To correct the situation you may treat wounded stalkers. For each saved life you will write off one victim.
9. The scheme has the following behavior types:

1) Follow me
2) Wait here
3) Sneak after me
4) Hide here

Moreover, for each of these scheme has three modes of aggression:

1) Normal
2) Reduced aggression (allows companion to come closer to the enemy)
3) Low (companion hides his weapons and not engages in battle until he or Player obtains some damage)

This set of functions allows the use of team-mate in the cases when it is necessary to make ambush or covertly change position. In addition, it can hide in safety so that it didn't attract enemy attention.
10. Especially for a partner I've prescribed additional state types on the basis of a panic run that he didn't get lost from Player when Player runs in haste.
11. You can use the radio to instruct your mate what to do. Radio works within a radius of a-life (about 150 meters). Also be aware if you left your partner behind and go beyond a-life radius (about 150 meters) he will most likely go to the camp.

Future development plans:

1. Add a weapons selector so you can instruct companion what type of guns to use (long range, close combat, etc).
2. Make a "follow-me-step-in-step" mode.


Description of the changes marks
* fixed bug
- feature disabled
+ feature added
= rebalanced
~ minor change

Version 1.9 (first english public version also)
+ included a more secure versions of smart_terrain and xr_gulag scripts with revisions excluding a-life hangs at postmortem re-init of characters logic
+ custom gamegraph with a reduced distances between locations is included in the package
+ in the package for original game it has been added portable radio for communications with a partner
+ You can easily disable the restriction on faction by changing "other_factions_switch" parameter inside title of xr_companions.script

Version 1.8
* Processing partner's death is made faster and more stable because it's cleaned of unnecessary actions
* Fixed constant yelping of companion caused by firing around of monsters roar, now he has to cry only when it receives a serious blow
* Hire Dialogue turned off for Yurick - his game logic is not compatible with the scheme and caused serious problems

Version 1.7 (first public version)
+ release!

Version 1.6
* Refined the combat scheme for companion so it's not cause animations conflicts

Version 1.5
+ returned to the 'disturbing hits' on companion, now without annoying sounds
* Refined combat scheme

Version 1.4A
+ partner is no longer able to lock you in a narrow passage. Come closer to him and within seconds he will realize that the way is blocked and change the position.

Version 1.4
* Fixed crash when NPC refuses to hire because of different faction

Version 1.3
~ Small code optimization

Version 1.2
* Fixed a rare crash that occurs at the loss of storage of companion schemes
* Removed 'alarming hits' on mate - response to threats found to be satisfactory without them

Version 1.1
* Fixed waiting for a companion at location

Version 1.0
* Fixed a crash when companion dies on a hacked game with NoDVD

Version 0.9
+ Now teammates from different factions have different dialogs with actor
= Now if the actor lost more than 4 companions he gets a bad rep. Stalkers do not go with him
* Finally response of companion at the enemy had been corrected: if you are together with companion escaping from the enemy he will not get nervous and try to go back to finish them
* Fixed cleanup of map mark when companion insulted at you for assault
= Attack of companion after which he becomes your enemy is regarded as his death
* Fixed inability of companion to pass on the Rostok - the name of the location werenot respecting letter cases
+ taken the opportunity to atone for the death of companion - every time you save a wounded NPC, providing first-aid kit to him, counter of dead companions on your conscience is decreased by 1. Counter cfn not be below 0.
* Hire dialog dosn't appears if NPC is wounded
= Inability to hire NPC before completing the quest on ATP bandits (disabled, enable if necessary)
* Fixed a minor crash in the companion scheme
* Fixed a bug where a dead teammate did not check out and that make impossible to hire new one
+ partner no longer runs through half of location from actor - distance restrictions applied
+ configuration of companion including his native faction, attitude to actor, and patterns of behavior are stored inside the companion and is automatically loaded from the data saves when loading the game
+ companion trained to run faster - if the actor more than 20 meters away he goes to a panic run and no longer breaks away from actor

Version 0.7G1
+ You can hire Wolf when he was on military warehouses (needs tuning)

Version 0.7G
+ set priorities for action - a partner can normally recharge weapons, heal, bandaging, react to the unexpected throw grenades, etc. if such schemes are present in game
+ companion can wear new armor if such scheme is present in game

Version 0.7F
* Completed combat mode
+ remade companion's map mark

Version 0.7E
* Added new mode - limited aggressiveness; it should be be a better choice for ambushes and hidden operations than the mode "did not attack the enemies first"
+ redone menu control - behavior modes regrouped

Version 0.7D
* Refined response to the attack
~ Optimized code

Version 0.7C
* Fixed some glitches in NPC behavior including not entirely appropriate reaction to the discovery, as well as not responding to some threats

Version 0.7B
* Created a new, more simple and rapid method for determining the NPC as companion; it replaced old one, which would cause the freezes
* Fixed clean-up of map marks after companion dies
+ Game displays a warning message in the moment of companion's death

Version 0.7A
+ path of the companion is not calculated as a straight line - now it's the curve - should be more natural
+ Now in the pattern of behavior "don't attacks enemies first" attack on actor is regarded as an attack on NPC himself

Version 0.7
+ operational and ready to use models of behavior:
1) Sneak after me.
2) Sneak after me and don't attack enemies first.
3) Hide here.
4) Hide here and don't attack enemies first.
Now the companion can be used in attacks on the enemy base - behaves well, does not rise noise to the last moment, and due to its low visibility you can sneak very close to the enemy. In addition modes "Hide here" and "Hide here and don't attack enemies first" help to set up ambush for the enemy.

Version 0.6B
* Made a selector of answers - NPCs now clearly explain why they don't want to go with the actor, if so

Version 0.6A
* Configured and make more intuitive the appearance of a dialog

Version 0.6
+ implemented patterns of behavior: "Follow me and do not attack the enemies first" and "Wait here and do not attack the enemies first" respectively. The scheme was finally made fully functional and suitable for permanent use. In the "no enemy attacks first" NPC are hiding weapons and behaves extremely quiet until it does not suffer damage, or it won't get hit. Then starts to fight. Nevertheless, these modes should be used with caution as such NPC as at the post of Kuznetsov still attacks NPC, even if he isn't taking hostile action. Should bear this in mind.

Version 0.5D
* Removed unnecessary script resulting in duplication of the mark on the map
+ mark of a companion on the map was changed - more accurate now, similar to the mark actor but green

Version 0.5C
* Companion's mark on the map is removed when it dies or when he ceases to be a companion

Version 0.5B
* Companion is not frightened of every rustle as usual NPCs

Version 0.5A
* Transition of the companion between locations is made operational
+ Companion draws a mark on the map

Version 0.5
+ attempt to adapt in scheme method of transition between locations from Red75 - from his scheme, "PARTNERS"

Version 0.4
* Fixed a crash in the moment of companion's death
* Corrected inability to speak with a companion after loading saves

Version 0.3
+ exchange of goods between the actor and his companion is now possible free of charge

Version 0.2
+ saving of the scheme is implemented as follows: NPC is appointed to actor faction. After game loads the NPC switches on scheme automatically if its faction will coincide with the actor.
+ NPC becomes a friend to actor after hiring
+ NPC switches to a neutral to actor after retiring
+ NPC returnes to his original faction based on its visual after retiring
= Cannot hire more than one partner
* Companion immediately begins to follow the actor, without unnecessary conversations

Version 0.1
+ General scheme revival: rewritten binder on modern version, scheme switching

Sample videos:
  13:55:13  20 November 2010
profilee-mailreply Message URLTo the Top
On forum: 03/11/2009

Message edited by:
11/20/2010 15:21:19
Messages: 85
Gamegraph editing and adaptation of scheme to mods with new locations:

I'm worked with the graph using a script gg_cdc_x4 by Xiani:
It's simply to use (only thing you need to run is installed ActivePerl) - who was unpacking at least once allspawn by ACDC, will understand how use it without any problems. Method is the same. You decompressing gamegraph, and get a huge pile of configs from it... find there a reference configuration file - it lists all the points of the transitions between location that were found when unpacking a gamegraph. All these points must be found in the main configs of locations - they named as game.graph.edges.<location_id>.ltx, search by parameter "edge_offset". Once found, you need to change "distance" parameter of what vertexes link (the distance between the vertexes in conventional gaming meters) to any small number. I personally put 5. Further, after treating all the transitions in this way, you have to recompress gamegraph back from configs and use it. Now transition times between location are greatly decreased to everyone - both you companion and other NPCs and monsters to, what lead sometimes to very interesting situations, greatly adding fun to gameplay. For example in our OGSE mod after that correction in gamegraph we somtimes get an attacks of Monolith fanatics in DarkValley, DarkValley bandits on Escape (quite a coomon thing now), Yantar zombies attacks on Agroprom and once time user even encounters a pseudogiant on Escape! This is because game is sending NPCs and monsters to other gulags then they current one is overpopulated. Original transitions between locations are very long - ranging from hundreds of meters to some kilometers, and then distances are cut to some meters then sometime nearest empty gulag is on other location nearby, so game sends NPCs and monsters there. This side-effect howewer wasn't ruining game balance but make it more fun. It's now real Zone there you never can say what awaits you.

So, adapt the companions scheme for new locations is easy enough. Most important thing - new location must be already registered in gamegraph, and must have registered level-crossings in it (actor level-jumpers unsuitable for the NPCs, they can move between locations only using vertex links in gamegraph). If all this has been done, and the NPC could freely visit the location, you need now only add records in the table named "offline_dest_table" in the main script of companions - "xr_companion.script" - table is almost at the end of the module. Table contains records with smart_terrains IDs, in which companion can be sent by game to move between locations. Entries looks like follows:

l07_military = {
none = "mil_dolg_ambush_walk1"

Ie this table records also is the small tables, which have as key an identification names of locations, and contains inside the names of smart_terrains, as they are defined in allspawn, usually one per location. Suppose we have location Generators named "l13_generators" and smart_terrain called "gen_last_hope_smart4". Then the record will look like this:

l13_generators = {
none = "gen_last_hope_smart4"

smart_terrain must be such type as to accept any faction NPCs. How to spawn it - your choice, the easiest way is to add it directly to allspawn of location. You can use the camp (camp fire) smart_terrain, albeit undesirable - because teammate, trvelled there in offline mode, may be in the vicinity of the already occupied smart_terrain before him bandits for example. And when you go there to reunite with him, he goes online at the same time with them and be killed. So now the scheme commonly using disposable scenario smart_terrains.

That's actually a checklist of what should be done for ensure companion (or indeed any other NPC) could visit the location:

1. It must have properly working AI-net.
2. Vertex grid of location must be correctly registered in gamegraph.
3. The pair of location vertexes in gamegraph must have link to vertexes of other location - they work as transition ways to NPCs.
4. On location must be at least one smart_terrain what able to take any NPC.
5. In xr_companion.script a table "offline_dest_table" must have record of this location with the name of what smart_terrain.

In fact, all items except 5th, do not apply directly to the companions. What is described in sections 1 to 4 should be done initially by mappers when connecting new location to the game, otherwise it is a waste of time, because locations not connected to others would not be able to use by the NPC. But if it's already been done, then you will need only complete 5th action to go.
  14:13:58  20 November 2010
profilee-mailreply Message URLTo the Top
On forum: 03/11/2009

Message edited by:
11/20/2010 14:19:30
Messages: 85
One small addition to manual - note what location IDs and smart_terrrains names in table "offline_dest_table" ARE CASE-SENSITIVE! If you write at least on charaster of them in wrong case it's wasn't work, so be careful. And one more - you don't need to add a new smart if you already have some camps on location - just find a suitable and use it. And one more thing i forget to mention - if you wasn't changed anything except transition distances in gamegrath you don't need a start new game - changes take action immediately.
  21:02:59  8 December 2010
profilee-mailreply Message URLTo the Top
On forum: 03/11/2009

Message edited by:
12/08/2010 21:05:12
Messages: 85
Updated version

New Version: 1.9B
Game version required: any SHoC release from 1.0004-1.0006 (yes, this version is for original game)
Size: 3.41 Mb
Download links:

* Implemented a logics restart when companion scheme begins to work, and also when companion goes panic run. This must solve problems with stuck companion caused by logics conflicts.
Each word should be at least 3 characters long.
Search conditions:    - spaces as AND    - spaces as OR   
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod downloads

All short dates are in Month-Day-Year format.


Copyright © 1995-2022 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.