Scripts / Player has weapon

Author
Message
ffrtzgy!
4
Years of Service
User Offline
Joined: 7th Mar 2020
Location:
Posted: 7th Mar 2020 10:21
A question for the community:-
How can I detect whether the player, (or another entity) has a weapon? I want to be able to change npc behaviour based on it.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Mar 2020 13:00
--detect if player is holding a weapon
if g_PlayerGunID > 0 then

--detect if gun is fired
if g_PlayerGunFired > 0 then

don't think it's really possible to do with an NPC so easily but you can do it if you keep track of the animations or states
i.e. if you see FireWeapon(e) in the AI script it should be firing (not always true as this has some internal checks)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
ffrtzgy!
4
Years of Service
User Offline
Joined: 7th Mar 2020
Location:
Posted: 7th Mar 2020 16:39
Thank you smallg, that's very helpful.
Shame about the npc detect as I was aiming for a generic script I could apply across games without having to hard-code entity id's or mod other stock scripts.
I shall experiment.
PM
MouthNine
4
Years of Service
User Offline
Joined: 17th Dec 2019
Location:
Posted: 9th Mar 2020 16:50
Hello, I have a similar question, but this is a question about bows and arrows. (Third-person perspective) When the character does not hold the bow and arrow, pressing the left mouse button will produce a strike action, while holding the bow and arrow will not have a combat action. Question: When holding a bow and arrow, how can I set it to have a strike action?

My thoughts: the third person perspective, when the player holds the bow and arrow, attack, appear: the action of pulling the bow, archery (this action is already in the bone and placed in the CSI).

Solution: Set the bow and arrow to melee mode so that you do not hold the same action as the weapon (you can set this action to pull the bow and drop the arrow).
The questions are: 1. How to detect the possession of bow and arrow weapons? 2. How to set this situation to melee?

thank you very much!
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 9th Mar 2020 17:35 Edited at: 9th Mar 2020 17:36
In third person there's not much you can do about it, most of it is hard coded, third person was never completed properly and anything to do with weapons and weapon switching etc. is a major point of contention.

If the character is using the wrong attack animation then you would need to find out the start and finish frame number for the correct animation, and then edit the .fpe file and change the animation range for attack in there.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Primary Laptop:
i5, NV1050 4GB, 8GB memory, 1x 1TB HDD, Win10.

Secondary Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
MouthNine
4
Years of Service
User Offline
Joined: 17th Dec 2019
Location:
Posted: 9th Mar 2020 18:39
Thank you!
PM

Login to post a reply

Server time is: 2024-03-28 10:07:30
Your offset time is: 2024-03-28 10:07:30