Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Script Parameter Crashes?

Page: 1 of 1
 Exile007
01-10-2009, 9:07 PM
#1
Recently I've been trying to write most of my scripts using TSL's useful script parameter system to keep them more organized. I've had a weird occurence in that whenever I use a script parameter greater than 0, my game will crash on the entry spoken where the parameter is 1,2, etc.

Below is the actual script I am using.

void main() {

int nParam1=GetScriptParameter(1);
switch (nParam1) {
case 0:

effect efVisual=EffectVisualEffect(3016);
effect efVisual2=EffectVisualEffect(3010);

vector vKun=Vector(-0.22,301.64,11.20386);
location lKun=Location(vKun, 270.77);
CreateObject(OBJECT_TYPE_CREATURE, "exarkun", lKun);

ApplyEffectAtLocation(0, efVisual, lKun, 0.0);
ApplyEffectAtLocation(0, efVisual2, lKun, 0.0);

break;
case 1:

object oKun=GetObjectByTag("exarkun");
CreatureFlourishWeapon(oKun);
DelayCommand(1.5, ChangeToStandardFaction(oKun, 1));

break;
}
}


And a screenshot of my dialog file.

Clicky (http://i292.photobucket.com/albums/mm29/Exile007_album/crash.jpg)

I'm not really sure what's going on, so any advice given is grateful. :)
 Star Admiral
01-10-2009, 11:32 PM
#2
Not sure if this might be a cause, but you should enclose the statements for each case within braces. Regarding the crash issue, it might be because the exarkun NPC does not exist yet. Try putting a GetIsObjectValid check on the NPC.

void main() {
int nParam1 = GetScriptParameter( 1 );
switch ( nParam1 ) {
case 0: {
effect efVisual = EffectVisualEffect( 3016 );
effect efVisual2 = EffectVisualEffect( 3010 );
vector vKun = Vector( -0.22, 301.64, 11.204 );
location lKun = Location( vKun, 270.77 );
CreateObject( OBJECT_TYPE_CREATURE, "exarkun", lKun );
ApplyEffectAtLocation( 0, efVisual, lKun, 0.0 );
ApplyEffectAtLocation( 0, efVisual2, lKun, 0.0 );
break;
}
case 1: {
object oKun = GetObjectByTag( "exarkun" );
if( GetIsObjectValid( oKun ) ) {
CreatureFlourishWeapon( oKun );
DelayCommand( 1.5, ChangeToStandardFaction( oKun, 1 ) );
}
break;
}
}
}

- Star Admiral
 tk102
01-11-2009, 1:20 AM
#3
Lack of braces shouldn't be a problem because case statements are sort of like labels to provide a location to for the script to jump to (switch to).

My guess is that the crash is caused by the CreatureFlourishWeapon function and that Exar Kun doesn't have a flourish animation. You might try commenting out that line and see how it goes.
 Exile007
01-14-2009, 11:53 PM
#4
Lack of braces shouldn't be a problem because case statements are sort of like labels to provide a location to for the script to jump to (switch to).

My guess is that the crash is caused by the CreatureFlourishWeapon function and that Exar Kun doesn't have a flourish animation. You might try commenting out that line and see how it goes.

The script actually was crashing because of the ChangeToStandardFaction part, I'm not sure why, but it works now. :)
Page: 1 of 1