lfnetwork.com mark read register faq members calendar

Thread: Scripting riddle
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 05-03-2003, 05:03 PM   #1
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
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

clu is offline   you may: quote & reply,
Old 05-03-2003, 07:02 PM   #2
War Master
 
Join Date: Jul 2002
Location: On the battle field
Posts: 212
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.
War Master is offline   you may: quote & reply,
Old 05-03-2003, 08:45 PM   #3
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
Cool, I'll give that a try. Thanks much War master.

-clu

clu is offline   you may: quote & reply,
Old 05-04-2003, 07:08 AM   #4
lassev
cryptoscripter
 
lassev's Avatar
 
Join Date: Jun 2002
Location: Finland
Posts: 1,087
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.
lassev is offline   you may: quote & reply,
Old 05-04-2003, 08:32 AM   #5
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
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 is offline   you may: quote & reply,
Old 05-04-2003, 08:42 AM   #6
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
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

clu is offline   you may: quote & reply,
Old 05-04-2003, 07:41 PM   #7
War Master
 
Join Date: Jul 2002
Location: On the battle field
Posts: 212
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" );
War Master is offline   you may: quote & reply,
Old 05-04-2003, 09:25 PM   #8
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
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 is offline   you may: quote & reply,
Old 05-04-2003, 11:06 PM   #9
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
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

clu is offline   you may: quote & reply,
Old 05-04-2003, 11:30 PM   #10
Obsidian-Jovani
 
Obsidian-Jovani's Avatar
 
Join Date: Apr 2003
Location: Onderon
Posts: 223
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" );
}
}


Binary Sunset Studios

WIP: A SP Project entitled "Resurgence"
Obsidian-Jovani is offline   you may: quote & reply,
Old 05-04-2003, 11:46 PM   #11
clu
 
clu's Avatar
 
Join Date: Oct 2002
Posts: 279
Cool, thanks. I actually just ended up using a string, but that resolves the whole dollar sign mystery for me, thanks.

-clu

clu is offline   you may: quote & reply,
Old 04-16-2007, 11:11 PM   #12
gweedodung
Rookie
 
gweedodung's Avatar
 
Join Date: Aug 2004
Posts: 31
Smile

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

gweedodung is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JO Mapping > Scripting riddle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:07 PM.

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