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.

Spawning effects?

Page: 1 of 1
 harark1
05-01-2011, 8:41 PM
#1
I think effects is the proper term.
Ok in a mod I am working on I have a droid self destruct, I am assuming i need to creat a script for this but how do I have it spawn a explosion (specificlly the frag grenade explosion.)?

As you can probally tell from my signature scripting really confuses me.
 JoFlashStudios
05-01-2011, 10:59 PM
#2
Given that you have already created the variable "droid" containing the droid object that is being destroyed, it would be something like this:


ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_GRENADE_FRAGMENTATION), GetLocation(droid));

This would be have to be called BEFORE:

DestroyObject(droid, 0F, TRUE, 0F);
 harark1
05-02-2011, 4:23 PM
#3
Trying to compile and it finds a problem at the DestroyObject in script.
 JoFlashStudios
05-02-2011, 6:37 PM
#4
Can you give me the error text?
 Qui-Gon Glenn
05-02-2011, 7:44 PM
#5
// * qg_droidpercp.nss
// * May 02 2011
void main()
{
int nEvent = GetUserDefinedEventNumber(); // OnPerception
effect eFragger = EffectVisualEffect(VFX_FNF_GRENADE_FRAGMENTATION);
object oDroid = OBJECT_SELF;

if (nEvent == 1002)
{
ApplyEffectToObject(0, eFragger, oDroid);
DelayCommand(0.5, DestroyObject(oDroid)); //this delay may not be necessary
} //or an ActionWait may function better
}


Try this as a custom OnPerception script. The droid will explode when you are just about to enter melee range. You will need to also make a custom OnSpawn for your droid, which will involve simply removing two "//" that comment out the UserDefinedEvent for OnPerception. It looks like this (without the orange coloring on the //): //GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_PERCEPTION ); //OPTIONAL BEHAVIOR - Fire User Defined Event 1002In kotor1 the default OnSpawn script is called k_def_spawn01.nss. This is only a line from the big script of course :)

You can extract an OnSpawn from any generic player, but really you should just get it from your Kotor 1 ---> BIFs --->scripts.bif. Extract that, delete the two "//" and save as some name you like, like droidspawn.nss. Compile, and place in override. Done :)
 harark1
05-02-2011, 8:02 PM
#6
On perception scripts will not work for this because it is from a dialouge option.( At least I think)

Here is my script:

void main (

DestroyObject(n_jimmy, 0F, TRUE, 0F);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_GRENADE_FRAGMENTATION), GetLocation(n_jimmy));

)

3: Error syntax error at "DestroyObject".
 Dak Drexl
05-02-2011, 8:14 PM
#7
On perception scripts will not work for this because it is from a dialouge option.( At least I think)

Here is my script:

void main (

DestroyObject(n_jimmy, 0F, TRUE, 0F);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_GRENADE_FRAGMENTATION), GetLocation(n_jimmy));

)

3: Error syntax error at "DestroyObject".

I know next to nothing about most of scripting, but I can tell you your script is structured all wrong. You need to have a "()" after void main. This is followed by the first curly bracket that signifies the start of your script. Finally you end the script with another curly bracket. Like this:


void main ()

{

DestroyObject(n_jimmy, 0F, TRUE, 0F);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_GRENADE_FRAGMENTATION), GetLocation(n_jimmy));

}



Unfortunately I can't tell you if there's anything wrong with your actual script, but there's my beginner's level help ;) Scripting is a pain for most people, you just have to keep at it and it will eventually click. That and try to stick to the source code and coding that people post here :D

Edit: And listen to everything Qui-Gon tells you!
 Qui-Gon Glenn
05-02-2011, 8:16 PM
#8
void main ()
{

object oJimmy = GetObjectByTag(n_jimmy);
effect eFragger = EffectVisualEffect(3003);
// 3003 == VFX_FNF_GRENADE_FRAGMENTATION in nwscript.nss

ApplyEffectToObject(0, eFragger, oJimmy);
ActionWait(0.5);
ApplyEffectToObject(0, eFragger, oJimmy);
DestroyObject(oJimmy, 0.0f, TRUE, 0.0f);

}
Ok, thanks for the dialog tip... this ought to work ok though. The ApplyEffectAtLocation is unnecessary I think. I added a second VFX, easy to cut if you no likey.
Also, pretty sure you can just destroy jimmy without all that other stuff.... "DestroyObject(oJimmy);" is probably sufficient, although I could be wrong on that.

EDIT: Hahhah, Dak, I am no master! You took care of his first problem, the whole brackets n parens thing, just felt like working it out a little further for Harark1 :D
 harark1
05-02-2011, 8:54 PM
#9
Uh thanks( Really yelling "D*** it why did I forget the paratheses!?")

Edit: You guys are probally thinking "Why is that droid named Jimmy?!"

Well it was xxrevanxx's idea. (He is very strange and insane.) We are kinda co-creating a mod.(If you are thinking Return of the Exile that is not right.)
 JoFlashStudios
05-02-2011, 10:25 PM
#10
Those extra parameters on DestroyObject() will ensure that the droid disappears immediately. Otherwise, you can get an annoying situation where there is an explosion, and then the driod stands there for half a moment after the explosion fades before it randomly vanishes.

I'm assuming that there won't be more than one droid object with Jimmy's tag? If there is, you will have to loop and check for GetIsInConversation() on each object with that tag.
Page: 1 of 1