clu Posted May 3, 2003 Share Posted May 3, 2003 Here's (hopefully) an easy one. I have three NPCs, and I want to trigger a script after they are *all* dead (individual deathscripts seem to be out since I don't know which will die last). Any ideas? -clu Link to comment Share on other sites More sharing options...
War Master Posted May 3, 2003 Share Posted May 3, 2003 Put a target_counter inside your map. In it's entity window, give it key:count value:3. Next, enter key:usescript value:nameofscript. Give your target_counter a targetname. For each NPC, in their entity windows, enter key:closetarget value:targetnameoftarget_counter. Link to comment Share on other sites More sharing options...
clu Posted May 4, 2003 Author Share Posted May 4, 2003 Cool, I'll give that a try. Thanks much War master. -clu Link to comment Share on other sites More sharing options...
lassev Posted May 4, 2003 Share Posted May 4, 2003 Now that it came into my mind, I can also give you an idea how to make it via scripting, if you insist. Of course it's total waste of time compared to the way War Master explained. (Of course I have used myself the counter method, but anyway. One can always build nice theories). First, perhaps in the player spawnscript, your declare a float variable. Then, in each deathscript of these three unfortunate victims, you add one to the variable (+1). But in addition to that, you also check the current status of the variable. If it has reached some certain value (like 2 in this case, if you start with a zero), you use a scriptrunner to launch the appropriate script, that should be lauched after all the dudes are down. For each NPC, in their entity windows, enter key:closetarget value:targetnameoftarget_counter. I used NPC_target key, but I guess it makes little difference. Link to comment Share on other sites More sharing options...
clu Posted May 4, 2003 Author Share Posted May 4, 2003 The counter worked sweet (thanks again War Master), but lassev your post is useful and somehow reminded me of another question related to global variables (which I'm going to post in another thread!) Thanks again. -clu Link to comment Share on other sites More sharing options...
clu Posted May 4, 2003 Author Share Posted May 4, 2003 Ahh screw it, I'll post it here. I'm definitely new to scripting, so apologies if this is very basic. OK, two questions: 1) Are you saying if I define a variable in a script (like my spawnscript), it will persist throughout the whole level? And I can change it's value in other scripts? 2) Can I then have dynamic triggers? (have them launch different sections of a Usescript depending on the value of the variable)? -clu Link to comment Share on other sites More sharing options...
War Master Posted May 4, 2003 Share Posted May 4, 2003 The target_counter is the best way to go because scripting it can lead to a problem. One objective in my sp map is to destroy 12 imperial mainframes. I originally scripted the counting. After each mainframe is destroyed it would target the target_scriptrunner. I discovered a problem though, if the player destroys more than one at the same time the target_scriptrunner is only run once. On the other hand with a target_counter, you can use a detonator and destroy as many as you want at the same time and it'll keep count. For variables, you have to declare and set them like this. //Generated by BehavEd declare ( /*@DECLARE_TYPE*/ FLOAT, "variablename" ); set ( "variablename", "0" ); To increment them: set ( "variablename", "+1" ); Link to comment Share on other sites More sharing options...
clu Posted May 5, 2003 Author Share Posted May 5, 2003 War Master, I'm using your counter and it works like a charm. Just wanted to know about persistent variables and I think you guys answered that too. Thanks for all the help. -clu Link to comment Share on other sites More sharing options...
clu Posted May 5, 2003 Author Share Posted May 5, 2003 Hey sorry to keep beating this thread to death, but I have a question related to variable persistence and what you mentioned earlier. In my player spawnscript, I define a variable called "03gamestate" to a value of "0" ------------------------------------------------- declare ( FLOAT, "03gamestate" ); set ( "03gamestate", "0" ); ------------------------------------------------- Then, in a later script, I have an "if" statement that runs different scripts depending on the value of "03gamestate" ------------------------------------------------- if ( get( FLOAT, "03gamestate") = "0" ) { run ( "colo/L03/fight_brothers" ); } else ( ) { if ( get( FLOAT, "03gamestate") = "1" ) { run ( "colo/L03/fight_soldiers" ); } else ( ) { rem ( "do nothing" ); } } ------------------------------------------------- My problem is that it is not recognizing the value as "0" (not running the scripts). Is this a syntax issue (I notice the use of "$$" to define numbers in other scripts. Do I need those? -clu Link to comment Share on other sites More sharing options...
Obsidian-Jovani Posted May 5, 2003 Share Posted May 5, 2003 My problem is that it is not recognizing the value as "0" (not running the scripts). Is this a syntax issue (I notice the use of "$$" to define numbers in other scripts. Do I need those? From looking at the SP scripts I think you do need to use the $. Try this out. if ( $get( FLOAT, "03gamestate") = 0$ ) { run ( "colo/L03/fight_brothers" ); } else ( ) { if ( $get( FLOAT, "03gamestate") = 1$ ) { run ( "colo/L03/fight_soldiers" ); } else ( ) { rem ( "do nothing" ); } } Link to comment Share on other sites More sharing options...
clu Posted May 5, 2003 Author Share Posted May 5, 2003 Cool, thanks. I actually just ended up using a string, but that resolves the whole dollar sign mystery for me, thanks. -clu Link to comment Share on other sites More sharing options...
gweedodung Posted April 17, 2007 Share Posted April 17, 2007 "Give your target_counter a targetname." Does this mean clicking on them and pressing Ctrl+k? I am using NPC_Reborns. Are they the target or targetname? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.