Scripts / NPC Gun Range and damage

Author
Message
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 7th Nov 2021 12:34 Edited at: 7th Nov 2021 12:55
I just want to know the gun spec of a gun especially this part

does this only apply to the player or are is it supposed to apply to the NPC that is also using that gun.

If i do a simple test with

PlayerDist = GetPlayerDistance(e)
Prompt(PlayerDist )
to display the players distant from the Ai and to see at what range the Ai will start to fire . So far it looks like they all starts to fire at the same distance at less than 1500

I am busy with a cene in the game were i what to place AI with pistols and shot guns at deferent places , obviously the pistols must have a longer range, the ai can not shoot the player with a shotgun at the same distance.
how can i achieve this
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Nov 2021 18:42
yes the gun settings do effect the AI weapons but there is a hardcoded "vision" check which max's out at 1500 which is why they can't fire beyond that range
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 8th Nov 2021 01:35
@pcs
Sounds like some 'per-the-usual' red-neck fakery via script might fill in?
That is if you are interested. 3500 units maximus.
** Remove the 'remarks' at the sound slot when you have actual sound files set to play.**
As usual just place an always active barrel, set player health to about 1000 and move nearer and further to see what's happening round here.

This script I wrote for you randomizes the shot
A> damage,
B> chance of a hit (more or less according to distance)
C> sound played
D> can include ricochet sounds for misses...

As of this time, these functions are not included; any obstacles between you, nor if the NPC is facing you and 'alarmed', nor if the NPC has already been a casualty... more scripting would have to play into that.
This crude example sorta simulates an unseen bot sniping at you in an open field or from a hill...

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 8th Nov 2021 06:23
Hey GubbyBlips, thanks man. i will test it out as soon as i come back from hospital. i need to get my stitches out.
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 8th Nov 2021 15:22
I'm going to add at least one more feature (or two)
An entity tracker so this script will follow an actual NPC, and maybe figure out how I can determine if the NPC is not dead? Health n stuff... so the script stops at that point.

BTW, I think determining bullet obstacles wouldn't be that hard either, just a matter of time to incorporate those features.
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 9th Nov 2021 01:47 Edited at: 9th Nov 2021 02:46
Added obstacles and you can tie this script to an NPC's location.
Also @smallg function; /detect if object facing player/ before taking action.
But it seems like stock AI is locked away under a few levels of functions and there's no documentation so it's hard to trace where to find
AI death to turn script off.

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 9th Nov 2021 02:34
GubbyBlips, i looked at the script and it work fine just need to get sound going.

i will look into the ai script and see if i can help with the death and hurt detection
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 9th Nov 2021 02:54 Edited at: 9th Nov 2021 04:17
There's a new one above (had to edit post)...
Sound is working if you remove comments. Modify as you wish (shot speed or damage for example.)
Also you can assign the script to an Entity on line 69. In that way the script is associated with the location and distance the NPC is, (like when it moves). Did we once have someone show how to detect AI death?

Now say what ............. I was looking through all this stuff for dead AI characters like
/ / / -- if ai_bot_state[e] == ai_state_preexit then ---
or
/ / / -- if tFrame >= tDyingAnimFinish-2 then ---
but come to find out it's silly simple the same as other entities...
/ / / -- if g_Entity[e]['health'] < 1 then ---
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 9th Nov 2021 08:32 Edited at: 9th Nov 2021 09:05
i have found the place were to detect if Ai get hurt a while back.
https://forum.game-guru.com/thread/221723#msg2628990
andd to detect if NPC is dead just add a check in the exit of the ai.soldier script.
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
Duchenkuke
GameGuru VBOTB Developer
7
Years of Service
Recently Online
Joined: 7th Jun 2016
Location: Germany
Posted: 10th Nov 2021 18:11
Quote: "which max's out at 1500 which is why they can't fire beyond that range"


can it be changed ? Or did anyone change it ?
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 10th Nov 2021 20:34
Quote: "can it be changed ? Or did anyone change it ?"


im not sure
Windows 10 Pro 64-bit
Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz
RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Nov 2021 21:13
No, and no.

Basically it is hard coded in the engine.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-23 09:07:17
Your offset time is: 2024-04-23 09:07:17