ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Disabling a specific anomaly

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  22:37:30  29 March 2014
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
 

Message edited by:
ddraig
03/29/2014 22:37:53
Messages: 158
Disabling a specific anomaly

I've come across a rather unique problem. I'm a rather terrible scripter, but I've been trying to switch a specific anomaly on and off based on whether or not an info portion is active.

I want the anomaly to appear in a specific place, but only if a certain info portion is set. Right now I currently have a non-functioning update function that I want to switch the anomaly on/off based on the info portion, but can't because I am a terrible scripter.


function disable_barrier()
	local obj = level.object_by_id("zone_psychic_death")
	if obj and not has_alife_info("deathbarrier_enable") then
		obj:disable_anomaly()
	else
		obj:enable_anomaly()
	end
end



The anomaly exists in the all.spawn, so hasn't been created by script. I'm thinking it may be better to create a logic script to disable/enable it based on an info portion rather than just using this script.

I'm obviously missing something incredibly obvious. Can anyone shed some insight?
  22:59:36  29 March 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
Messages: 454
level.object_by_id takes a number, not a string. You may find it useful to give the anomaly a unique story_id value in the all.spawn. Then you can call alife():story_object( [that number] ) to get the server object reference for the specific anomaly you're interested in.
  00:44:26  30 March 2014
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
Messages: 158

---QUOTATION---
level.object_by_id takes a number, not a string. You may find it useful to give the anomaly a unique story_id value in the all.spawn. Then you can call alife():story_object( [that number] ) to get the server object reference for the specific anomaly you're interested in.
---END QUOTATION---



Thanks for the pointers! Got it working.

Here's the code I used:


function disable_barrier()
	local obj = get_story_object("zone_deathbarrier")
	if obj and not has_alife_info("deathbarrier_enable") then
		obj:disable_anomaly()
	else
		obj:enable_anomaly()
	end
end



This was actually for Call of Pripyat so I could assign a story_id in the config file (not sure you can do this for SoC?). Assigned it the story id, used that and it now works perfectly!
  21:01:14  30 March 2014
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
level.object_by_id takes a number, not a string. You may find it useful to give the anomaly a unique story_id value in the all.spawn. Then you can call alife():story_object( [that number] ) to get the server object reference for the specific anomaly you're interested in.

Thanks for the pointers! Got it working.

Here's the code I used:


function disable_barrier()
	local obj = get_story_object("zone_deathbarrier")
	if obj and not has_alife_info("deathbarrier_enable") then
		obj:disable_anomaly()
	else
		obj:enable_anomaly()
	end
end



This was actually for Call of Pripyat so I could assign a story_id in the config file (not sure you can do this for SoC?). Assigned it the story id, used that and it now works perfectly!
---END QUOTATION---


I was looking at doing something like this myself. I'm really excited to try this out - thanks for sharing.

Where did you place the functions?
  21:58:09  30 March 2014
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
Messages: 158

---QUOTATION---
level.object_by_id takes a number, not a string. You may find it useful to give the anomaly a unique story_id value in the all.spawn. Then you can call alife():story_object( [that number] ) to get the server object reference for the specific anomaly you're interested in.

Thanks for the pointers! Got it working.

Here's the code I used:


function disable_barrier()
	local obj = get_story_object("zone_deathbarrier")
	if obj and not has_alife_info("deathbarrier_enable") then
		obj:disable_anomaly()
	else
		obj:enable_anomaly()
	end
end



This was actually for Call of Pripyat so I could assign a story_id in the config file (not sure you can do this for SoC?). Assigned it the story id, used that and it now works perfectly!
I was looking at doing something like this myself. I'm really excited to try this out - thanks for sharing.

Where did you place the functions?
---END QUOTATION---



Depends, really. I'm using a timer system, so every now and then a timer is checked, and it does a random action, and one of those actions is switching certain anomalies on/off via info portion, so it was just an update function. Calling it from anywhere will work fine, though (I tested it by using the execute function in Alundaio's debug tools for CoP).

Here's one I'm using at the moment:


function disable_moon()
	local obj = get_story_object("zat_anom_doublemoon")
	if obj then
		if not has_alife_info("secondmoon_enable") then
			obj:disable_anomaly()
		else
			obj:enable_anomaly()
		end
	end
end



This is an update callback, so it checks to see if the secondmoon_enable info portion is set. If it is, the anomaly is enabled, if it isn't then it's switched off. I modified it slightly to test to see if the object actually exists and then do the functions, as otherwise it would crash if the anomaly didn't actually exist for some reason.

It also works if you were to call it in dialog or whatever.
 
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-2022 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.