Aller au contenu

Photo

Applying a visual effect


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

#1
Artevere

Artevere
  • Members
  • 36 messages
 effect vDrunk = EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, vDrunk, oPC);

This is supposed to fire a visual effect centered on the player, correct? Nothing happens when these functions are passed, though other functions in the same script work fine:

	case 2 :			effect vDrunk = EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);			effect eDrunk = EffectPolymorph(POLYMORPH_TYPE_CHICKEN, FALSE, FALSE);				ApplyEffectToObject(DURATION_TYPE_INSTANT, vDrunk, oPC); //vfx not firing properly			ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrunk, oPC);

The player does indeed turn into a chicken. I've tried running the vfx by itself, I've tried about 10 different effects (fnf, imp, and regular vfx)

Nothing seems to work :?

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
Not all VFX work properly applied to an object. Some will only look right at a location. I don't know if that's the case with this VFX or not, but you can try that.

Looking at visualeffects.2da, I see that a bunch of the summon VFX (celestial, summon monster 1, 2, 3, etc.) are all based on the same Special Effects definition file: sp_summon_creature_1.sef. What you can try is to use:

//RWT-OEI 05/31/05
//This function creates a Special Effects File effect that can
//then be applied to an object or a location
//For effects that just need a single location (or source object),
//such as particle emitters, the source loc or object comes from
//using ApplyEffectToObject and ApplyEffectToLocation
//For Point-to-Point effects, like beams and lightning, oTarget
//is the target object for the other end of the effect. If oTarget
//is OBJECT_INVALID, then the position located in vTargetPosition
//is used instead.
effect EffectNWN2SpecialEffectFile( string sFileName, object oTarget=OBJECT_INVALID, vector vTargetPosition=[0.0,0.0,0.0]  );

I'm pretty sure that you should use the filename of the SEF in question without the .sef extension. Read more about this on the wiki page.

#3
Artevere

Artevere
  • Members
  • 36 messages
Still doesn't want to work. I've tried:



	case 2 :
			effect vDrunk = EffectNWN2SpecialEffectFile("sp_call_lightening");
			effect eDrunk = EffectPolymorph(POLYMORPH_TYPE_CHICKEN, FALSE, FALSE);	
			ApplyEffectToObject(DURATION_TYPE_INSTANT, vDrunk, oPC); //vfx not firing properly
			ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrunk, oPC);



Still turn into a chicken, but nothing else happens :(

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages

Artevere wrote...

Still doesn't want to work. I've tried:

	case 2 :
			effect vDrunk = EffectNWN2SpecialEffectFile("sp_call_light[u][i][b]e[/b][/i][/u][i][/i]ning")

Still turn into a chicken, but nothing else happens :(


I don't know whether it will fix it, but you've got an extra 'e' in lightning. The file name is "sp_call_lightning".

By the way, the SEFs are stored in your installation directory: Atari/NWN2/Data/NWN2_VFX, NWN2_VFX_X1, and NWN2_VFX_X2).

#5
Artevere

Artevere
  • Members
  • 36 messages
yup, noticed. That was a typo from changing it back. I've tried a couple different versions (like EffectNWN2ParticleEffectFile())



It was correct when I was testing it though.

#6
kevL

kevL
  • Members
  • 4 052 messages
just tried the original script:

effect vDrunk = EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);
effect eDrunk = EffectPolymorph(POLYMORPH_TYPE_CHICKEN, FALSE, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, vDrunk, oPC); //vfx not firing properly
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrunk, oPC);

and it worked fine .. got the rumble, got the flashy VFX, got the chicken.

(celestial chickens, sheesh)

I know that's not what you want to hear, so here's what I wrote before checkin' ..
--
If MasterChanger's idea of applying effect at Location:

ApplyEffectAtLocation(DURATION_TYPE_INSTANT, vDrunk, GetLocation(oPC))

doesn't work, perhaps try wrapping either (SpecialEffect/VisualEffect) in a  
DelayCommand();

of  
0.1f
.. just a thought.
--
but i tell ya, it worked! maybe check your Override for conflicts? custom VFX package, i donno

#7
Artevere

Artevere
  • Members
  • 36 messages
Hmm... I never use overrides, but I've had this problem before. The toolset does not like to actually save the module. I've deleted gobs of code, compiled all scripts, saved, and tested the module... only to have the scripts I just deleted firing.

That aside, I guess I'll have to keep trying. If my original coding actually works, that is heartening. I didn't think I was that poor of a programmer :P

Oh, and it's just a test script. I don't actually intend to implement celestial chickens.

Modifié par Artevere, 13 décembre 2010 - 09:02 .


#8
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Artevere wrote...

Hmm... I never use overrides, but I've had this problem before. The toolset does not like to actually save the module. I've deleted gobs of code, compiled all scripts, saved, and tested the module... only to have the scripts I just deleted firing.


Do you happen to have multiple copies of the same module saved? Perhaps one saved in Directory format while the other is in .mod format? If so, the game will choose to run the .mod format one.

#9
Artevere

Artevere
  • Members
  • 36 messages
nope, just one copy. I use generic test modules to write script, then import. Currently I don't actually run a module, I'm just helping out a PW.

#10
rjshae

rjshae
  • Members
  • 4 478 messages
Sometimes when I'm applying a couple of graphical effects to a PC, I find that one of them doesn't go into effect unless I introduce a delay. Try putting in a 0.3f second delay for the second effect.

Modifié par rjshae, 13 décembre 2010 - 11:34 .


#11
kevL

kevL
  • Members
  • 4 052 messages

Artevere wrote...

Oh, and it's just a test script. I don't actually intend to implement celestial chickens.


( mind if i use it? i have an idea for cursed armor .. )   Posted ImagePosted ImagePosted Image

#12
Artevere

Artevere
  • Members
  • 36 messages
Be my guest. When I get everything working right, I'll be posting it to the vault anywho.



Still no go on the VFX. I've tried everything. o.0

#13
kevL

kevL
  • Members
  • 4 052 messages
you're being methodical? close everything down (reboot computer), start toolset, open directory, change script, save & compile, save module ... load module fresh



eliminate RL variables

#14
Artevere

Artevere
  • Members
  • 36 messages
Here is the full sample script, if you're interested in using the pieces:

/********************************************************************************************************
Custom Potion Script
Created by Artevere
121210

To use this script as is, import all potions and this file to your module. If you wish to add more potions:
1) Create a potion base type.
2) Name the tag pot_unique.
3) Go to item properties > spell > unique on use: self.
4) Go to local variables > int 0 > set to the next number in the case.
5) Add the new case to the list.

To remove a potion
1) Remove all instances of the potion from your areas (vendors, loot drops, etc).
2) Double check.
********************************************************************************************************/

void main()
{

    object oPC      = GetItemActivator();
    object oItem    = GetItemActivated();
    object oTarget  = GetItemActivatedTarget();
	int iPotion = GetVariableValueInt(oItem, 0);
	int iRaceType = GetRacialType(oPC);
	int iSubRaceType = GetSubRace(oPC);

	switch(iPotion)
	{
	case 1 : 
 		//Spider Wine - non-drow make fortitude save or lose 4 intelligence.
		if(iSubRaceType != RACIAL_SUBTYPE_DROW)
			if(FortitudeSave(oTarget, 20)==0)
				{
				effect eDrunk = EffectAbilityDecrease(ABILITY_INTELLIGENCE, 4);	
				ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrunk, oPC);
				SendMessageToPC(oPC, "You have lost intelligence!");  
				}
		break;
		//Fowel Potion - turns drinker into a chicken. Watch out for the Colonel.
	case 2 :
			effect vDrunk = EffectVisualEffect(VFX_FNF_SUMMON_CELESTIAL);
			effect eDrunk = EffectPolymorph(POLYMORPH_TYPE_CHICKEN, FALSE, FALSE);	
			ApplyEffectToObject(DURATION_TYPE_INSTANT, vDrunk, oPC); //vfx not firing properly
			ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrunk, oPC);
		break;		
	}

}

I'll be more methodical later on. I know there must be something stupid I'm over looking... just need to figure out what!

The idea is to create a single script named i_pot_unique_ac with all the abilities in the switch case. The local int variable (index 0) of the unique potion is set to the case number of the script it is supposed to fire when drunk.

Makes things much more tidy.

Modifié par Artevere, 14 décembre 2010 - 07:10 .


#15
kevL

kevL
  • Members
  • 4 052 messages
nice script, I could learn a lot from that .. *copy.


So this goes into OnActivateItem ..**

hm, I just pulled this into the toolset and it compiled fine, but those two lines look suspicious to me:

if (iSubRaceType != RACIAL_SUBTYPE_DROW)
if (FortitudeSave(oTarget, 20)==0)

is this acceptable syntax or do you really mean:

if (iSubRaceType != RACIAL_SUBTYPE_DROW) && (FortitudeSave(oTarget, 20)==0)

although it shouldn't affect  
case 2:
 ..

anywho!


[edit] **gets automatically fired from OnActivateItem .. w/ TBS

Modifié par kevL, 14 décembre 2010 - 10:26 .


#16
MasterChanger

MasterChanger
  • Members
  • 686 messages
I'd pepper your code with some SendMessageToPC calls to verify that the portion of the code that you think is firing is indeed firing. For example:

case 2: SendMessageToPC(GetFirstPC(), "I'm in case 2!");
// Do other stuff
break;

That way, if some effect is being created elsewhere and is giving the impression that something's being called when it isn't.

This is the primary way I de-bug, after I've just done a visual scan to make sure nothing obvious jumps out as being the culprit.

#17
rjshae

rjshae
  • Members
  • 4 478 messages
For test purposes, try a different FNF effect; one that you know will work as an instant effect.

#18
Artevere

Artevere
  • Members
  • 36 messages
kevL - No do not put this in OnActivated. Just make a script file named i_pot_unique_ac and copy the script in. Then you can make the items (don't forget to set their local int variables).



Also, the constitution check is only invoked if the drinker is not a drow. So is char drow? (yes - drink away!) no (fort save or bad stuff)



MasterChanger - I did try setting only the vfx (just in case the chicken poofing locked out the vfx) but I couldn't get any results from that either. I'm not certain where to apply a debug script (everything but the vfx works, so it's already narrowed down pretty well).



rjshae - I've tried a half dozen FNF's, and all are the results are the same.

#19
kevL

kevL
  • Members
  • 4 052 messages
ah, more new grammar for NWN2 .. myself I'd have nested the FortSave since I'm so used to NWN-scripting, no biggie (even if present in NWN1).

The indices on variables are new to me too, but it looks simple enough : when assigning LocalVariables to an object, the first one defaults to #0 .. give it a value that corresponds to the case statement. Tks, Art

#20
Artevere

Artevere
  • Members
  • 36 messages
That's correct. It's like an array (or spreadsheet). so:



#0: Value 1, Value 2, Value 3, etc

#1: Value 1, Value 2, Value 3, etc

etc: etc

#21
rjshae

rjshae
  • Members
  • 4 478 messages
The following worked when I tested it:

void make_chicken( object oTarget )
{
    effect eVisual = EffectVisualEffect( VFX_FNF_SUMMON_CELESTIAL );
    effect eMorph = EffectPolymorph( POLYMORPH_TYPE_CHICKEN );
    location locTarget = GetLocation( oTarget );
    ApplyEffectAtLocation( DURATION_TYPE_TEMPORARY, eVisual, locTarget );
    ApplyEffectToObject( DURATION_TYPE_PERMANENT, eMorph, oTarget );
}

#22
Artevere

Artevere
  • Members
  • 36 messages
Using a location works... I suppose that's enough for my needs. Why ApplyEffectToObject doesn't function is a bit of a mystery... maybe NWN 2 doesn't support it and it's just a legacy function?

#23
rjshae

rjshae
  • Members
  • 4 478 messages
Yes I've had mixed results with many visual effects that have constants; some prefer being applied to the object while others like the location. There's probably some way to weed out that information from the effect file itself. A problem with using location is that some of the effects are rendered too close to the ground and the image gets truncated. I end up having to bump up the elevation a tad. Shrug.

Modifié par rjshae, 20 décembre 2010 - 11:15 .


#24
Artevere

Artevere
  • Members
  • 36 messages
It's also an issue if the target is moving. The effect is tagged to their location when the script is fired, so it could land behind them instead of on them.

#25
rjshae

rjshae
  • Members
  • 4 478 messages

Artevere wrote...

It's also an issue if the target is moving. The effect is tagged to their location when the script is fired, so it could land behind them instead of on them.


Since you are transforming it into a chicken anyway, why not clear the target's action queue just prior to determining the location?