ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Constant anti-rad effect?

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  22:08:09  21 January 2013
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
 

Message edited by:
ddraig
01/21/2013 22:08:38
Messages: 158
Constant anti-rad effect?

I'm looking to make an item, when it's present in the inventory, gives a constant anti-rad effect (it's not an artifact, just an "invisible" item that reduces radiation per second

I've been looking through various scripts (mainly dmx_medicines.script from DMX) and found a likely looking function but I'm unsure how to make it reduce radiation by the amount I'd like:


	local last_rad_health = 1
		if db.actor:object("remove_radr") then
         local sub = db.actor.radiation - last_rad_health
        if sub>0 then db.actor.radiation = -sub*0.95 end
    end
    last_rad_health = db.actor.radiation
end



This is pretty much a snippet of what I have at the moment, using the update callback so it should be constantly working, but it doesn't seem to be reducing radiation at all.

Anyone have any ideas?
  00:42:39  9 February 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
You've made last_rad_health a local. The indentation implies it is part of a function. It is initialized to 1. No matter what db.actor.radiation (max = 1) is, the math says sub will never be > 0 so db.actor.radiation is never changed.

And even if it were changed, the saved value would be lost when stored back in the local variable, as it would be re-initialized to 1 when the function is executed again.
 
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.