ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Reducing health/stamina with script

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  17:39:40  12 August 2013
profilee-mailreply Message URLTo the Top
exostalker
Novice fashion designer since 2008
(Resident)

 

 
On forum: 08/10/2009
Messages: 1267
Reducing health/stamina with script

Is there any way to reduce max health or stamina through the script? So that when the function is called, player either can't have his full health or has a lot less stamina?

I've tried db.actor:max_health and tried searching for other similar functions, but couldn't find anything.
  21:23:15  12 August 2013
profilee-mailreply Message URLTo the Top
Jketiynu
Swartz
(Resident)

 

 
On forum: 04/05/2007
Messages: 867

---QUOTATION---
Reducing health/stamina with script

Is there any way to reduce max health or stamina through the script? So that when the function is called, player either can't have his full health or has a lot less stamina?

I've tried db.actor:max_health and tried searching for other similar functions, but couldn't find anything.
---END QUOTATION---




local act=db.actor
act.power = -0.9
act.health = -0.9



Set it to negative whatever fraction of health you want.
  23:50:11  12 August 2013
profilee-mailreply Message URLTo the Top
exostalker
Novice fashion designer since 2008
(Resident)

 

 
On forum: 08/10/2009
Messages: 1267
Thanks!

Maybe someone has any idea what could be wrong with this:

if act.power>0.3 and act.health>0.3 and nemiga == 3 then
act.power = -0.01
act.health = -0.01
end

It only performs act.health section, ignoring act.power. I tried splitting them into two different if's, still, got the same result.

These work:

if act.power>0.5 and nemiga == 2 then
act.power = -0.01
end

if nemiga == 4 then
act.health = -0.01
end
  02:18:40  14 August 2013
profilee-mailreply Message URLTo the Top
exostalker
Novice fashion designer since 2008
(Resident)

 

 
On forum: 08/10/2009
Messages: 1267
Oh, and maybe someone knows if there is a function to put item into slot?
  02:43:17  14 August 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Oh, and maybe someone knows if there is a function to put item into slot?
---END QUOTATION---


There's almost certainly a more elegant solution, but you could exploit the fact that items automatically fill empty slots when the actor picks them up. Check the slot you want, if there's an item there drop it, drop the item you want to equip, transfer it BACK into the actor, then grab the item that was originally in the slot, if any.
I would be surprised if there wasn't a better way to do this, although I didn't notice anything relevant in game_object's member functions.
  16:16:47  14 August 2013
profilee-mailreply Message URLTo the Top
exostalker
Novice fashion designer since 2008
(Resident)

 

 
On forum: 08/10/2009
 

Message edited by:
exostalker
08/14/2013 16:17:02
Messages: 1267
Thanks.

I know I've been asking a lot, but I'm quite new to scripting and don't really know much about ingame functions...

Is there a way to count how many of the specific items actor has in inventory?
  17:04:09  14 August 2013
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454

---QUOTATION---
Is there a way to count how many of the specific items actor has in inventory?
---END QUOTATION---


game_object has a handy function called inventory_for_each which takes a function as its argument. It steps through every item in the actor's inventory and passes each object to the function you specify. Here is a fairly simple implementation:

function countItems( section )
	local howMany = 0
	db.actor:inventory_for_each(
		function ( object )
			if object:section() == section then
				howMany = howMany + 1
			end
		end
	)
	return howMany
end

  13:30:03  16 August 2013
profilee-mailreply Message URLTo the Top
exostalker
Novice fashion designer since 2008
(Resident)

 

 
On forum: 08/10/2009
Messages: 1267
That worked perfectly, thanks!
 
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.