therfiles Posted December 31, 2014 Posted December 31, 2014 Hey everyone! Hope you can shed some light on this tricky question. So I've been tinkering around with adding some new features via ICARUS, but I've ran into a big roadblock. I've scoured the ICARUS manual and forums and can't figure out the answer. How can I define/manipulate a variable (or PARM) that is global? For instance, at the moment, I can define a variable named test_var as a string with value of therfiles. However, that value and variable will only be set for the entity it is ran on (most likely, the player). So, if we ran a check on another entity, let's say an NPC, it would have no value for test_var What I'm looking to do is define a global variable. For instance, the variable test_var would be set as a string. Then, a script ran on the player sets that variable to therfiles. Then, if another entity runs an IF statement check on it (again, let's say an NPC named Bob), the NPC would also have the value of test_var to be therfiles. If that doesn't make sense, let me explain it another way. I want to make a variable that every entity knows exists, and how it is defined. I then want any entity to be able to modify it, and that would it's global definition. Then, any entity could run checks on that variable, and receive that the value is the input that the other entity used. For example: Global variable var1 is hello.NPC_1 sets var1 to goodbye.NPC_2 runs an if statement check on var1, and the value is goodbye, not hello. One thing that has alluded me is how to set global commands. It seems like any scripts ran via console or even in a map are executed on the player locally. How can I achieve such an effect globally? Is that even possible? This will really help make scripts that are generic and can be set to any NPC to do what I want. Thanks guys!
mrwonko Posted December 31, 2014 Posted December 31, 2014 You just use global variables://(BHVD) declare ( /*@DECLARE_TYPE*/ STRING, "g_greeting" ); set ( "g_greeting", "hello" ); affect ( "NPC1", /*@AFFECT_TYPE*/ FLUSH ) { set ( "g_greeting", "goodbye" ); signal ( "greetingChanged" ); } waitsignal ( "greetingChanged" ); if ( $get( STRING, "g_greeting")$, $=$, "goodbye" ) { set ( /*@SET_TYPES*/ "SET_HEALTH", 0 ); } free ( "g_greeting" ); Don't forget freeing it once it's no longer required as there's a fairly low limit, it may have been 16. therfiles likes this
therfiles Posted December 31, 2014 Author Posted December 31, 2014 Thanks @@mrwonko for your insight! I ran your provided script and it worked perfectly! Thanks! But I don't think I can adapt it for what I am trying to do. Let me provide some more specifics... So, I'm basically creating new force powers, by repurposing the Mind Trick ability. The mind trick force power is versatile because an NPC can have it's own mindtrick script. So, instead of having the player confuse the targeted NPC, I can run a script on it (like chopping of it's head.) This works and has been tested, but the problem is that this method needs to utilize multiple force powers. In the past, I've been able to setup a simple script that checks the value of the specific variable (PARM1, I think) and then determines which set of commands to run on the NPC. I'll post this script below: (force power commands removed to make the script shorter) //Generated by BehavEd affect ( "player", /*@AFFECT_TYPE*/ INSERT ) { if ( $get( FLOAT, "SET_PARM1")$, $=$, $1$ ) { affect ( "bob", /*@AFFECT_TYPE*/ INSERT ) { rem ( "Commands" ); } } else ( ) { if ( $get( FLOAT, "SET_PARM1")$, $=$, $2$ ) { affect ( "bob", /*@AFFECT_TYPE*/ INSERT ) { rem ( "Commands" ); } } else ( ) { if ( $get( FLOAT, "SET_PARM1")$, $=$, $3$ ) { rem ( "Commands" ); } else ( ) { rem ( "Error" ); } } } } This works. The problem here is that the targetname has to be Bob. In order for this method to work, each NPC would need it's own script, with it's own unique targetname. I'm not a big fan of this and have been trying to create a generic script to fix this. The script that you provided works, except that the commands in the script would not be executed in the same script, and the waitsignal wouldn't work, since multiple NPCs would execute the waitsignal erroneously. For instance, when the player selects the desired force power, a script will be run that sets a variable, g_forcepower to power1.Then, the mindtrick script will be applied via spawnscript or entity keys in Radient to the NPC.Then, when mindtrick is used on the NPC, it needs to check the value (hopefully global) of g_forcepower to see what power to run. If power1 is the value, it will run the specified commands. I was rather surprised that your method worked, however. Through all my experiments, I would have guessed that the value change of g_greeting would be stored only in the NPC, but that is not the case. Thanks for your help and I hope you can sort all this out!
mrwonko Posted December 31, 2014 Posted December 31, 2014 I don't quite understand the problem, can you strip it down to a simple example map that I can play around with?
therfiles Posted December 31, 2014 Author Posted December 31, 2014 Sure! It may take a couple days...I'm leaving today for a trip so I'll get that to you via PM as soon as I can. Thanks again for your help!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now