Aller au contenu

Photo

Need help with applying a visual effect.


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Mistraven

Mistraven
  • Members
  • 14 messages

Hello everyone I picked up my old NWN2 game discs a few days ago and figured I would give it a try since I almost never played it since I got it a few years ago (my computer just didn't cope with it). I have always been more of a builder in NWN 1 so I wanted to try and see what I could make with the new toolset, so far I got my module up and running, I got a few basic systems done for death and rest and such but I have run into a problem in one of my scripts where the visual effect I want to apply just never fires and I have half beaten myself to death today trying to figure it out.

 

Description of what I want the script to do...

When a player dies he/she respawns in a shadow realm where they are guided to a portal, by a wisp spirit,that will bring them back to the world of the living. I have setup a bunch of numbered waypoints in the area that the spirit will walk along towards the portal, I have also setup a number of triggers that fires an on_enter script that moves the wisp on to the next waypoint. But there is supposed to be unstable magic in the area and with some randomness there will be a visual effect, like an explosion or similar that knocks down the player for a few seconds and then the player can continue. 

 

What the script is actually doing...

I got pretty much everything working, the wisp walks along fine, a local int on the player keeps track of where the wisp-spirit is, each trigger stops triggering after they have been fired once, when the explosion effect takes place the player is knocked down so that part is working, it is just the visual effect that won't fire.

 

And here is my code...

//Wisp Trigger
void main()
{
    object oPC = GetEnteringObject();
    int nExplosion = d100();
    //show this message when the explosion happens
    string sMsg  = "<b><color=Red>The unstable weave of magic around you explodes.</color></b>";

    //if already triggered, there is still chance of an explosion but the wisp won't move
    if (GetLocalInt(OBJECT_SELF, "Triggered") != 0) {
	if (GetIsPC(oPC) && nExplosion <= 35) { 
	    SendMessageToPC(oPC, sMsg);

        //this effect doesn't fire
	    effect eVisual = EffectNWN2SpecialEffectFile("VFX_SPELL_SHADES_DELAYED_FIREBALL", oPC, GetPosition(oPC));
	    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPC, 5.0);

	    //these effects fire as planned so there is nothing wrong with the if statement
	    AssignCommand(oPC, ClearAllActions());
	    AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_PRONE, 1.0, 8.0));
	    effect eImmobilize = SupernaturalEffect(EffectCutsceneImmobilize());
	    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eImmobilize, oPC, 8.0f);	
	    effect eFreeze = SupernaturalEffect(EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION));
	    DelayCommand(1.0f, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFreeze, oPC, 7.0f));
        }
        return;
    }

    //if not triggered, move the spirit and then check for explosion
    if (GetIsPC(oPC) || GetIsPossessedFamiliar(oPC)){
	    object oWisp = GetNearestObjectByTag("guiding_spirit");

        //setup the waypoint variable, the wisp spawns at waypoint number 1
        //if the variable does not already exist as a local int on the player
        //then increase it to 2 to get next waypoint.
        int nNumber = GetLocalInt(oPC, "WispWaypoint") + 1;
	    if (nNumber == 1){
            nNumber++;
    	}
	    string sWaypoint = "Z_WP_WISP_" + IntToString(nNumber);
	    AssignCommand(oWisp, ActionMoveToObject(GetWaypointByTag(sWaypoint), TRUE));

        //set the triggered and current waypoint as local int
	    SetLocalInt(oPC, "WispWaypoint", nNumber++);
	    SetLocalInt(OBJECT_SELF, "Triggered", 1);
	
        //now check for a random explosion again		
        if (GetIsPC(oPC) && nExplosion <= 30) { 
	        SendMessageToPC(oPC, sMsg);

            //and ofcourse this effect won't fire either since it is the same as above
 	        effect eVisual = EffectNWN2SpecialEffectFile("VFX_SPELL_SHADES_DELAYED_FIREBALL", oPC, GetPosition(oPC));
   	        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVisual, GetLocation(oPC), 5.0);

            //these effects fire as planned so there is nothing wrong with the if statement
	        AssignCommand(oPC, ClearAllActions());
	        AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_PRONE, 1.0, 8.0));
	        effect eImmobilize = SupernaturalEffect(EffectCutsceneImmobilize());
	        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eImmobilize, oPC, 8.0f);	
	        effect eFreeze = SupernaturalEffect(EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION));
	        DelayCommand(1.0f, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFreeze, oPC, 7.0f));
	    }
    }
}

If anyone has any idea of what is going on I would really appreciate your help, the script compiles fine and I have tried substituting EffectNWN2SpecialEffectFile with EffectVisualEffect and substituting the VFX with other effects and nothing seems to work.

 

Thanks in advance! =)



#2
rjshae

rjshae
  • Members
  • 4 478 messages
effect eVisual = EffectNWN2SpecialEffectFile("VFX_SPELL_SHADES_DELAYED_FIREBALL", oPC, GetPosition(oPC));

 

Hi Mistraven,

 

The "VFX_SPELL_SHADES_DELAYED_FIREBALL" is not the name of a file; it's a global constant. (Upper case names are generally always constants in the base scripts.) You need to find out what file that constant is referencing. In the script authoring tool, have a look at the value of that constant, then look up the matching row in the visual effects 2da file. There should be one or more visual effect file names on that row.


  • GCoyote aime ceci

#3
Mistraven

Mistraven
  • Members
  • 14 messages

Thanks for trying to help, is the script authoring tool a separate program to the script editor in the toolset? Also, where do I find the 2da file? I remember that in NWN 1 I had to unpack some file archive in order to read and modify 2da files but i'm not sure how to do it in nwn 2?

 

EDIT: I checked the constants in the toolset and it says this in the notes 

int VFX_SPELL_SHADES_DELAYED_FIREBALL                  = 737;

I suspect I need to check line 737 in the visual effects 2da then? is this what you meant?



#4
rjshae

rjshae
  • Members
  • 4 478 messages

Yes, the script editor is what I meant.

 

If you select '2DA' File from under the 'View' menu, then type 'v' to go down to the V section, it should down be there.



#5
Dann-J

Dann-J
  • Members
  • 3 161 messages

Another way to find the name of an SEF file would be to put an effect placeable in a test area, look at its properties window, open the drop-down list where the SEF name currently is, and enter a likely keyword. In this case I'd filter on the word 'fire', which would reveal a list of all the SEFs with 'fire' in their file names. For location-based effects you'll actually see them happen in the toolset as you try each one.

 

You can browse every SEF in the game by not entering a keyword at all (if you've got plenty of time to spare!). I've discovered all sorts of interesting VFX that way.



#6
Mistraven

Mistraven
  • Members
  • 14 messages

Thanks your comments and help, I will try this soon once I get time to continue building!