ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Checking to see if actor is crouched

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  20:59:17  10 June 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
Messages: 867
Checking to see if actor is crouched

This is for CoP but is applicable to SoC too and this is the only forum with any active scripters

Anyways, via script I need a way to check if the player is crouched. Is this possible?

I'm also using X-Ray Extensions which does allow you to detect key-presses but I think it's only for key-id numbers, I don't think it can tell what game-key is being used for crouching, etc.

Any help would be appreciated.
  23:42:43  10 June 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
 

Message edited by:
SetaKat
06/10/2013 23:43:34
Messages: 6342
There is some code, bit of a hack, but it checks the actors position against either a previous position, or something else. You can check the difference in height to see if the actor is crouching.
Xray extensions can be configured to check to see if a key has been pressed, but I'm still working on a way to map its key# to the ones defined in Lua_help.script.
I'll post my code later on when I'm at my own computer.

The position check is your best bet if you're working with CoP. I can't remember if the CoP Xray Extensions have the keypress functionality.
  00:05:49  11 June 2013
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
...I'm still working on a way to map its key# to the ones defined in Lua_help.script. I'll post my code later on when I'm at my own computer
---END QUOTATION---



Yes, please!!!
  00:30:18  11 June 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
Messages: 867

---QUOTATION---
There is some code, bit of a hack, but it checks the actors position against either a previous position, or something else. You can check the difference in height to see if the actor is crouching.
Xray extensions can be configured to check to see if a key has been pressed, but I'm still working on a way to map its key# to the ones defined in Lua_help.script.
I'll post my code later on when I'm at my own computer.

The position check is your best bet if you're working with CoP. I can't remember if the CoP Xray Extensions have the keypress functionality.
---END QUOTATION---



Yes the CoP one has keypress detection (already using it for other stuff). I'd be very grateful if you post that when you get a chance
  06:00:38  12 June 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
I'd be very interested in having a solution to this, as well. I actually asked this question several months ago
  19:23:41  12 June 2013
profilee-mailreply Message URLTo the Top
Bangalore
Robberbaron
(Resident)

 

 
On forum: 02/17/2008
Messages: 1159
Can't be these values useful from actor.ltx? These are actor's bounding box values in different stances:


ph_box0_center                                             = 0.0,  0.9,  0.0
ph_box0_size                                                 = 0.35, 0.9,  0.35

ph_box1_center                                              = 0.0,  0.75,  0.0
ph_box1_size                                                 = 0.35, 0.75,  0.35

ph_box2_center                                              = 0.0,  0.6,  0.0
ph_box2_size                                                 = 0.35, 0.6,  0.35



0 is standing
1 is crouch
2 is low-crouch

i would guess the values are: width, height, depth

Dunno how can we check this with scripts, and what kind of measure these numbers mean, but if the actual actor can be packed into an 0.35, 0.75, 0.35 sized box, he's crouching for sure.
  22:09:51  18 June 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
Messages: 867
Where'd you go Setakat? Come back! Waaahh!
  22:36:14  18 June 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
 

Message edited by:
SetaKat
06/18/2013 22:36:42
Messages: 6342
Sorry, been busy with work, and been sick for a bit. The keypress code is still a bit buggy, I have an idea on how to fix it, I just need a free weekend to do so
In the mean time, here is some code that replicates the actor state icon, that includes crouch detection. Extract the relevant code out into a function, and return true or false until I can get my other code done.


-- from NLC 6 mod

local last_state = "normal"
local last_pos = vector():set(0,0,0)
local hud = get_hud()
local last_time = 0

function update()
	if db.actor:is_talking() then
		if hud:GetCustomStatic("actor_state") then
			hud:RemoveCustomStatic("actor_state_bkground")
			hud:RemoveCustomStatic("actor_state")
			last_state = "talking"
		end
		last_state = "talking"
	else
		local tg = time_global()
		if last_time < tg then
			last_time = tg + 40
			local apos = db.actor:position()
			local dist_to_cam = device().cam_pos.y - apos.y
			local state = "normal"
			if dist_to_cam > 1.6 then
				local delta_pos = last_pos:distance_to_xz(apos)
				if delta_pos > 0.01 then
					state = (delta_pos > 0.25) and "sprint" or "run"
				end
			elseif dist_to_cam < 1.4 then
				state = dist_to_cam < 1.15 and "creep" or "crouch"
			end
			if last_state~=state then
				last_state = state
				local cs = hud:GetCustomStatic("actor_state")
				if not cs then
					hud:AddCustomStatic("actor_state_bkground")
					hud:AddCustomStatic("actor_state")
					cs = hud:GetCustomStatic("actor_state")
				end
				cs:wnd():InitTexture("ui_hud_soldier_" ..state)
			end
			last_pos = apos
		end
	end
end

  02:03:39  19 June 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
Messages: 867
You're the best. Thank you
  21:18:12  26 July 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
You're the best. Thank you
---END QUOTATION---


Hey Jketiynu, were you able to get a working prototype?
 
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.