ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Calling Script Functions on Actor Firing Weapon

« Previous 10 events | 1 2 3 4 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  22:51:28  28 July 2013
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735
Not exactly the same. But I wrote a script that includes a check for if a weapon has been fired. It doesn't appear to be too demanding; though I haven't really tested in detail.

It serves a specific purpose that is more complicated than what you need. It checks for change in weapon condition as a proxy for weapon being fired. I'm not completely sure I could extract the part you need but the concept isn't complicated.

Check for active weapon. Save condition. Retest condition on actor update and compare. Return "True" if condition decreases.
  00:31:51  29 July 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
Do you think that method would work well for audio? ie, playing a specific stereo audio file alongside each shot? Or is the weapon status check best used for things that aren't so sensitive to timing?
  03:32:22  29 July 2013
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---
Do you think that method would work well for audio? ie, playing a specific stereo audio file alongside each shot? Or is the weapon status check best used for things that aren't so sensitive to timing?
---END QUOTATION---



It seems very sensitive. An onscreen debug display shows each shot instantly decrements condition I'd guess only limited by the speed of actor update cycle. Whether it would work for your situation I can't say - you'd just have to try.

But I don't know why it would be any less laggy than the check above as it relies on a xrs_utils.get_weapon_data(s_obj) every update cycle. I just haven't noticed any lag when I use it.
  04:27:41  29 July 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
Would you mind posting your code you use to accomplish this task? Is it essentially the same? Do you use bind_stalker's update function, as well?
  04:52:35  29 July 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
Thanks for suggesting this solution, Nuor! I was able to get it working with relative ease; bonus points: doesn't have any non-vanilla dependencies. Here's my script:
http://pastebin.com/x2Sfmf8i
I've tested as many weird cases as I can think of and it seems to be stable. No noticeable performance loss, either. Of course, just call firing_function.update() (whatever yours is called) from bind_stalker's update().
  04:53:55  29 July 2013
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735

---QUOTATION---
Would you mind posting your code you use to accomplish this task? Is it essentially the same? Do you use bind_stalker's update function, as well?
---END QUOTATION---



What I have wouldn't help much - it monitors and updates weapon condition to simulate weapon overheating. What you need is simpler. But I'll see if there is any part that can be simply extracted.
  13:50:06  30 July 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
Just covering some possible loose ends:

Meltac, Jketiynu is right about burdening the update() event loop. It's fast but a lot of processing on each pass will kill the framerate. Hoisting optimization helps; see my note to Daemonion below for an example.

¯¯¯¯¯¯¯¯¯¯
Hi, gannebamm! With myVar = myFunc() and myOtherVar, if myFunc() returns false, myVar is set false without looking at myOtherVar. In the case of

wpn = packet_utils.item_is_fa(wpn) and wpn

if wpn is a weapon (fa == firearm?) then return wpn otherwise return false.

So the code that follows should be testing for wpn before using it.

The code construct is confusing and probably not any more efficient that a direct if item_is_weapon(wpn) then handle_weapon() end because you still need to test for wpn after the assignment.

¯¯¯¯¯¯¯¯¯¯
Daemonion, some of the lag might be from the constant overhead of obtaining the sound objects in the called function each pass. I'd move the rain_fps_l and rain_fps_r assignments either out of the function (where they will be set once when the script is parsed) or inside the if (data.weapon_state == 5) then test just before they are used.

But that isn't enough, because you really only want to fire the sounds once, not sixty times a second or so. A check for playing would help.
  00:11:34  15 October 2013
profilee-mailreply Message URLTo the Top
gannebamm
has abondened XRay and uses Unity3D now
(Resident)

 

 
On forum: 05/02/2007
Messages: 1077

---QUOTATION---
Just covering some possible loose ends:
---END QUOTATION---


love you for doing this! srsly


---QUOTATION---

Hi, gannebamm! With myVar = myFunc() and myOtherVar, if myFunc() returns false, myVar is set false without looking at myOtherVar. In the case of

...snip...

The code construct is confusing and probably not any more efficient that a direct if item_is_weapon(wpn) then handle_weapon() end because you still need to test for wpn after the assignment.
---END QUOTATION---


Thank you for the insight. I totally agree that those "neat" coding styles make code harder to read and even though I could learn that stuff I just don`t see it making it more efficient - if you think about code readability against execution speed. But whatever this is nitpicky and off topic.

Daemonion: Have you tested the approach? I am quite shure you wont get a noticable delay. As said I have used this method to keep track of bullet consumption in the mod project "the gritty zone" for call of pripjat - the code if free to use.
  23:39:25  23 October 2013
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
Messages: 158
This is the "Weapon exploding" script from DMX that was adapted from OGSE, I believe.

http://pastebin.com/WuMLtadv

I've modified it slightly for my own ends (the "rigged" part, for sabotaged weapons) but the basic concept is there.

Rather than checking the weapon condition, it checks the total amount of ammo a given weapon has. If it decreases, it assumes that gun has "fired" and does actions accordingly.

This is put in an update callback, obviously.

It's rather similar to the weapon condition method, but each approach probably has different advantages/drawbacks.
  00:57:33  24 October 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Rather than checking the weapon condition, it checks the total amount of ammo a given weapon has.
---END QUOTATION---


Wouldn't that make it trigger on manually unloading the weapon?
 
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.