LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   JO Mapping (http://www.lucasforums.com/forumdisplay.php?f=359)
-   -   Scripting riddle (http://www.lucasforums.com/showthread.php?t=98726)

clu 05-03-2003 06:03 PM

Scripting riddle
 
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

War Master 05-03-2003 08:02 PM

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.

clu 05-03-2003 09:45 PM

Cool, I'll give that a try. Thanks much War master.

-clu

lassev 05-04-2003 08:08 AM

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.

Quote:

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.

clu 05-04-2003 09:32 AM

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

clu 05-04-2003 09:42 AM

dynamic triggers and global variables
 
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

War Master 05-04-2003 08:41 PM

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" );

clu 05-04-2003 10:25 PM

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

clu 05-05-2003 12:06 AM

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

Obsidian-Jovani 05-05-2003 12:30 AM

Quote:

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" );
}
}

clu 05-05-2003 12:46 AM

Cool, thanks. I actually just ended up using a string, but that resolves the whole dollar sign mystery for me, thanks.

-clu

gweedodung 04-17-2007 12:11 AM

"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?


All times are GMT -4. The time now is 09:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.