Exile007 Posted January 11, 2009 Share Posted January 11, 2009 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 I'm not really sure what's going on, so any advice given is grateful. Link to comment Share on other sites More sharing options...
Star Admiral Posted January 11, 2009 Share Posted January 11, 2009 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 Link to comment Share on other sites More sharing options...
tk102 Posted January 11, 2009 Share Posted January 11, 2009 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. Link to comment Share on other sites More sharing options...
Exile007 Posted January 15, 2009 Author Share Posted January 15, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.