ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Tutorial: Better Recoil, now AI-Friendly

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  02:53:49  7 August 2013
profilee-mailreply Message URLTo the Top
Hammru
(Novice)
 
On forum: 07/13/2010
Messages: 10
Tutorial: Better Recoil, now AI-Friendly

Hello all. It is I, David. First, an introduction.

I did some casual modding in SOC a long time ago and this forum was a great help to me. I don't think I ever posted because I never made anything worth discussing. Now I have rediscovered my love of this game and will be making a nice mod. I am even using this as my excuse to buy a nice gaming computer, which is something I've thought about doing for a couple years now. Because I will be asking for more help from this community I figured I should first "pay it forward" and teach what I've learned on my own.

For this purpose I present to you this tutorial which will teach you how to add more realistic recoil to weapons in your mod without breaking the AI. I can't possibly be the only person who has figured this out, but I don't remember ever seeing anyone else describe the process.



STEP #1: A brief description of our goal. The default settings cause the first shot of a burst to recoil strongly and every shot after it to recoil very little. This is the exact opposite of reality. In real life single shots have very little recoil and bursts are difficult to control (when talking about an intermediate-caliber service rifle). Heavy machineguns and pistol-caliber machineguns can be fired more accurately on full auto because their mass dampens the energy of the recoil. This is a big part of why it's the guy with the machinegun who gets hit with artillery and airstrikes and tanks in real life.



STEP #2: We adjust the weapons so that they work well for the player. More-realistic recoil is achieved by using a [u]negative[/u] value for cam_dispersion. This allows the first shot to be mild, after which the positive value in cam_dispersion_inc kicks in and climbs your muzzle. I recommend resisting the temptation to set cam_max_angle way high, unless we're talking about a micro uzi in which case go nuts. For a 5.45 LMG I recommend something like -0.05, 0.1 and for a rifle I recommend experimenting in the ballpark of -x, 1 to 2. I like something like 1.1 for the sig 550 and I would use 1.6 for an ak-47. Your tastes may vary; this tutorial is about "more realistic" and not about "precisely realistic". Unfortunately this kludgy fix creates an opportunity for cheating: if you put a fast-click macro on a mouse button you can fire "semi-auto" at full auto speeds with minimal recoil.




STEP #3: Now we teach the AI to be smart. How do soldiers use their rifles in real life? Single shots, unless hordes of north Koreans with pointy sticks are flooding their position. How do we make our stalkers not shoot straight up at the sky? Single shots, unless we specifically tell them otherwise. Better realism and better gameplay; that's what I like.

In gamedata/config/creatures/m.stalker.ltx look for the fire queue parameters. This is where we force our angry little stalkers to stop blasting away at the clouds and stay cool. By setting weapon_min&max_queue_size to 1 at all distances our stalkers will only fire single shots. They will stay level-headed and level-barreled just like we want. Set the inteval times to fit your personal tastes. A very small interval is functionally equivilant to full auto, but if you chose to do this you will not see the stalker separate his fire into discrete bursts. This is functionally equivilant to the mouse-macro cheat. A few enemies in game are scripted to blast away anyways; I don't know how to fix this other than by giving them low-recoil weapons. You'll see it at agroprom and at the freedom baricade.




STEP #4: Now we add variety. We actually do want some enemies to fire full auto. We don't want every person in the game to be equally proficient with their firearms. We can also make some kinds of enemies more or less alert to enhance stealthy gameplay. We can specify all of these things by creating sub-types of "stalker". This is easy to do. First, open up creatures/stalkers.ltx and add a new line which reads: #include "m_stalker_custom.ltx", or whatever name you prefer instead. Then create a blank file named m_stalker_custom.ltx, or whatever you prefered instead. In this file add a section like this for each kind of person you want in your mod:

[stalker_yourname]:stalker
$spawn = "stalkers\stalker_yourname"

under this copypasta and edit attributes from stalker.ltx so that this sub-stalker behaves the way you want. It is easy to play with the visibility, fire dispersion, and fire queue parameters. Here are a few possible stalker types for your inspiration:

Machinegunner: huge eye_range, unleashes long bursts at all distances (give a low-recoil weapon)
Submachinegunner: single shots far, small bursts medium, mag dumps up close (also low-recoil only)
Novice: Low alertness, fires slowly, terrible accuracy. This way you can sneak up on early bandits at night without nerfing the monolith elites.
Sniper: very slow rate of fire, huge eye_range, extreme accuracy with which to kill you

Don't forget to customize the accuracy and fire rates of zombies and monolithies.




STEP #5: Get it in the game! Now you gotta play with all.spawn. It's time to go through the alife files. For each human actor there is a line which looks like "section_name = stalker" or stalker_zombied or stalker_monolith. Change 'stalker' to the name of your customized sub-stalker. Now it may look like "section_name = stalker_machinegunner".A good way to save time is to find the person you want in the gameplay/character_desc files, copy the "class" string, and then find that in the spawn file. This is better than blindly scrolling through smart terrains and space restrictors andd such looking for the person.




STEP #6: Start a new game if you changed all.spawn. Simply changing the basic stalker behavior to use semi-auto fire does not require starting a new game.



That's about it, unless you've modded the game so that stalkers go around picking up weapons from the ground and a submachinegunner gets his hands on a rifle. That's my personal way of putting high-recoil firearms in the game without breaking the AI. Because the game is now mostly semi-auto vs semi-auto firefights (which I find to be better gameplay) you'll want to tweak the accuracies and damages of all the weapons for better balance.


Good luck and happy experimenting
  19:26:00  7 August 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
08/07/2013 19:28:05
Messages: 567
This is great, thanks!

About the AI stuff - I have a function that allows the game to tell whether it is the actor or NPC using the weapon, and can switch config settings (if you want to give the actor and NPCs different recoil values).

I'd be happy to share it.
  20:03:07  7 August 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
 

Message edited by:
Jketiynu
08/07/2013 20:05:50
Messages: 867

---QUOTATION---
This is great, thanks!

About the AI stuff - I have a function that allows the game to tell whether it is the actor or NPC using the weapon, and can switch config settings (if you want to give the actor and NPCs different recoil values).

I'd be happy to share it.
---END QUOTATION---



Would you mind sharing that with me too? That sounds really interesting.

Also, thanks OP, that's a really good idea. I'm going to experiment with that myself.
  21:38:19  7 August 2013
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
+1
I have an inbalance with semi auto weapons in my mod. This should level things out quite nicely.
Class implementation is going to be tricky though, but would give incredibly fine control. Taking what I currently have a step further (have faction specific settings for npcs rather than class specific)
  00:01:13  8 August 2013
profilee-mailreply Message URLTo the Top
Hammru
(Novice)
 
On forum: 07/13/2010
Messages: 10

---QUOTATION---
I have a function that allows the game to tell whether it is the actor or NPC using the weapon, and can switch config settings (if you want to give the actor and NPCs different recoil values).

I'd be happy to share it.
---END QUOTATION---



That sounds very interesting to me. I had no idea that kind of thing was possible. I already know what I want to try to do with it.

The ammo actually used by npcs (at least until they reload) is the first ammo type specified in ammo_class. If I can use this function to make the late game NPCs use AP ammo by giving them a differently-ordered ammo_class this would save me the need to add any redundant cloned weapons. This would be a big time saver.



---QUOTATION---
Class implementation is going to be tricky though
---END QUOTATION---



I agree. A full mod could be (and for me will be) very time consuming to make and test and tweak.
  03:25:30  9 August 2013
profilee-mailreply Message URLTo the Top
Hammru
(Novice)
 
On forum: 07/13/2010
Messages: 10
I might as well use this thread to ask a some quick questions instead of littering the forum with lots of threads.

Has anyone figured out a good way to make some weapons/ammos specialized against either fleshy or armored enemies? I would love to be able to use some kind of armor-piercing mechanic. It is frustrating that changing hit_type in the weapon files does not appear to do anything.

Can weapon damage be randomized at all, or is always exactly predictable? I want to avoid "x hits for y enemy" gameplay.

Is it possible to adjust an enemy's 'reaction time'? I want some enemies to spit fire the instant you poke your head out of cover, and I want some enemies to give you more time to aim or run.

Is it possible to make grenade fragments 'tracer'? In addition to awesome incendiary grenades with a thousand burning fragments we could use this to make fireworks. Imagine how awesome it would be if you finish the game, it kicks you back to freeplay mode, and the first thing you see is a dozen NPCs giving you a celebratory fireworks show by blasting away at invisible invincible birds with grenade launchers.

Has anyone made a mod in which enemies properly use grenades or underslungs? Being able to get out of a bad situation by going nuts and nuking everything is fun, but It feels somewhat unfair to have such disproportionate firepower.
  05:44:32  9 August 2013
profilee-mailreply Message URLTo the Top
Seeker_of_Strelok
Senior Resident
 

 
On forum: 05/02/2011
Messages: 279

---QUOTATION---
Has anyone figured out a good way to make some weapons/ammos specialized against either fleshy or armored enemies? I would love to be able to use some kind of armor-piercing mechanic. It is frustrating that changing hit_type in the weapon files does not appear to do anything.
---END QUOTATION---



I'm not sure how relevant this might be, but you might be able to tinker with the AP or Hydroshock ammo sections in weapons.ltx. See how they're different than the default ammo perhaps in the k_ sections ( k_hit, k_impulse, k_pierce, etc ) to make the ammo cut through armored targets more, have the hydro rounds make the targets stagger back more or something.

I'd be willing to test a file or two out for you for feedback if you'd like.
  10:12:06  9 August 2013
profilee-mailreply Message URLTo the Top
xRatx
Senior Resident
 

 
On forum: 06/18/2008
Messages: 1592

---QUOTATION---

Has anyone made a mod in which enemies properly use grenades or underslungs? Being able to get out of a bad situation by going nuts and nuking everything is fun, but It feels somewhat unfair to have such disproportionate firepower.
---END QUOTATION---



Regarding this question, yes, someone already made a mod that allow's NPC's to use grenade launchers and other stuff.

Check this AMK forum thread for download links: http://www.amk-team.ru/forum/index.php?showtopic=4653&page=1
  18:35:48  9 August 2013
profilee-mailreply Message URLTo the Top
ERForman
Senior Resident
 

 
On forum: 04/12/2007
Messages: 224
xStream Grenadier and Rulix AI are now included with latest ZRP. You have option to allow NPC grenade throwing, attach scopes, attach grenade launchers, eliminate friendly fire accidents, NPCs self heal, rifle butt melee by NPCs will dislodge your weapon from your hands, really a lot of added features if you take the time to understand the Modifier.exe program.
  05:26:26  10 August 2013
profilee-mailreply Message URLTo the Top
Hammru
(Novice)
 
On forum: 07/13/2010
Messages: 10
I thought I had the most recent version of ZRP, turns out I was wrong. This new version has a lot of great options. I'll give it a try tonight.

I'm still gonna download and play AMK when I get my new computer because I just found out it has a flamethrower and that is awesome.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

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


 

Copyright © 1995-2021 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.