Author Topic: Help with visual effects for group play  (Read 487 times)

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help with visual effects for group play
« on: October 03, 2012, 02:08:43 am »


                Hi!

I'm working on a dissertation study using a group task in NWN, and I'm hoping that I can get some help with how to display customized visual effects. 

Here's a brief background of the study: I'd be asking people to complete a short (and *super* basic task) in NWN, and I'd vary a number of visual elements to see if it impacts performance on the task.

Players won't necessarily be seeing the same visual effects as other people in their party, however, so it would be ideal if the visual effects are client side only so that *only* the player using the PC can see them. 

I'm a scripting beginner, so I might need things explained at really basic levels =) I've received a recommendation from an experienced NWN player to ask for help here though, so I'm hoping I can keep up with explanations!

The first thing I'd be interested in doing is creating a visual effect such that the effect "VFX_FNF_GAS_EXPLOSION_FIRE" from the Lexicon appears on a player when they are dealing melee damage to a creature (however, this might be a different player than the player using the PC -- ex. Player A would see a visual effect when Player B deals melee damage).

If anyone has any suggestions for how to go about doing this, I'd appreciate it!
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Help with visual effects for group play
« Reply #1 on: October 03, 2012, 11:51:45 am »


               Visual effects in NWN are server side. If you apply an effect to an object, every player will see it. There is no possibility to "hide" it from a specific observer.
Better said, their appliance is server side (the server commands, the clients obey). But their visual representation is client side (each client loads in memory its own local copy of an effect).
So...

There might be a workaround.
But it is a nontrivial amount of work. And it is UNTESTED, as this is just an idea off the top of my head as we speak. And if the game makes some kind of CRC check on game resources it might not work.


On the assumption that it could work...

... the idea would be that of making a visual effect resource available only to a specific player, and to none other. The selected player would receive a genuine sample of the visual effect resource, while the others would receive a dummy that could produce no screen output.
Say, for example, that you prepare one such effect, and that you call it MyFireA.
You have, say, 4 players: A, B, C and D. Each player will receive an Hak pak you prepared for play on your server.
These 4 Hak paks will differ, physically. Say that effect MyFireA is only supposed to be visible for player A. The Hak pak given to player A would contain a genuine MyFireA, while the Hak paks given to players B, C and D would contain a dummy version of MyFireA.
When -during play- you wanted to apply a fire effect to be visible only for player A, you would apply MyFireA to player A. Every player (A, B, C and D) would, technically speaking, "see" it, but only player A would truly get something going on his screen. Players B, C an D would not notice a thing because their own local copy of MyFireA, though ongoing, is essentially a void.

Similarly you would prepare 3 more versions of the same fire effect, but these you would call MyFireB, MyFireC and MyFireD. And like you did for MyFireA, you would place a genuine copy of each such effect in 1 Hak pak only, while the other 3 Haks would receive a dummy effect.

And that is how your scripts could apply an effect that is only visible for a specific player (or players).
To put it all together, say that you wanted -at some point in the game- to apply a fire effect on Player D. But this fire has to be seen only by players A, B and C. Player D must see nothing.
You would apply MyFireA to player D. Only player A would see it.
Also, you would apply MyFireB to player D. Only player B would see it.
Also, you would apply MyFireC to player D. Only player C would see it.

The end result would be that player D would have 3 fire effects active on him (as far as the game is concerned), but he could see none of them. Player A would be seeing MyFireA on his screen, player B would see MyFireB, player C would see MyFireC. And since all these fire effects are the same in appearance, the trick of an effect that is only visible to specific player(s) is achieved.

You can choose whether to go for effects that are "visible to one player only" (as described above) or effects that are "visible to all players but one". Suit yourself, the amount of visual effects to prepare in the Hak paks is the same.
But the former method allows you to choose which players are _not_ meant to see a given effect. The latter method, instead, only allows you to apply fewer effects during play. I would pick the former, for finer control over the mechanism.

Hm. My english is long winded. I hope you were not lost in my explanations.
Hopefully someone else can understand this and come up with a more concise version.


-fox


[edited to improve explanation -fox]
               
               

               


                     Modifié par the.gray.fox, 03 octobre 2012 - 12:38 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Help with visual effects for group play
« Reply #2 on: October 03, 2012, 01:55:46 pm »


               NWNX allows for a visual effect to be applied only for a specific player (under windows and Linux versions).  It works for any fnf of imp type visual effects, and would be the easiest method of doing what you want to.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Help with visual effects for group play
« Reply #3 on: October 03, 2012, 02:13:07 pm »


               nwnx funcs - specifically.
I use the single player visual effect function to achieve telepathic-esq effects.

Eg - When speaking on whisper channel, only people of specific telepathic races will see the visual effect cue over their heads when they hear it. etc
               
               

               
            

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help with visual effects for group play
« Reply #4 on: October 03, 2012, 02:22:31 pm »


               Hi all!

Thanks for the replies! Fox, I appreciate the detailed and thoughtful reply, but I am sure I am far too much of a newbie to be able to pull off the description you described =) I think it will be a long, long time before I'm up for that!

failed.bard and baaleos, thanks for the tip about nwnx. baaleos -- I think you mentioned this before in a post I made earlier on a similar topic, and I sent you a followup pm that I think got lost in the ether! I'd like to explore using nwnx_funcs to pull this off, since it seems like it most easily allows for this. However, I've never used nwnx before. Would you be willing to describe in a bit more detail how it works (ex. where is a secure place I can download nwnx, what should I be looking for once I've downloaded it, and if there's a tutorial about how to use it somewhere?)

Thank you so much!
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Help with visual effects for group play
« Reply #5 on: October 03, 2012, 03:02:10 pm »


               

the.gray.fox wrote...

Hm. My english is long winded. I hope you were not lost in my explanations.
Hopefully someone else can understand this and come up with a more concise version.


-fox


Failed.Bard wrote...

NWNX allows for a visual effect to be applied only for a specific player (under windows and Linux versions).  It works for any fnf of imp type visual effects, and would be the easiest method of doing what you want to.

That was certainly concise.
And a more appropriate suggestion overall.
+1


LindsayReynolds wrote...

Hi all!

Thanks for the
replies! Fox, I appreciate the detailed and thoughtful reply, but I am
sure I am far too much of a newbie to be able to pull off the
description you described =) I think it will be a long, long time before
I'm up for that!

No problem. Pick what is best for you, and never look back.


-fox
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Help with visual effects for group play
« Reply #6 on: October 03, 2012, 03:10:05 pm »


               in my specific example its a player based loop.



object oPlayer = GetFirstPC();
while(oPlayer != OBJECT_INVALID)
{
   if(MyCondition)
      {
             NWNXFuncs_ApplyVisualEffectForPC(oViewingPC, 13, GetPosition(oPlayer));
      }
   oPlayer = GetNextPC();
}


oViewingPC = The player that is to view the visual effect
13 = The premonition visuals
GetPosition(oPlayer) = get the vector/position of the target player.


This example loops through all players on the server, and plays the visual on them, but only oViewingPC Can see it.

Notes about this function:
If you apply a visual effect at Player A's Position, and Player B is the player to view it, but Player B is in another area, they might see the visual effect appearing at the same vector/position in their own area.
It is up to you, the scriptor to determine the logic behind who should and should not see the visual.
If you apply the visual effect at vPos  ( 10.5 , 4.5 , 1.0 )
and use this on all players.
They would all see the visual effect just appearing randomly at that vector, in their currently occupied area.
Its up to you to do the 'if condition' step to prevent this.
               
               

               
            

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help with visual effects for group play
« Reply #7 on: October 03, 2012, 06:38:13 pm »


               Thanks for the example -- that should be really helpful for trying to orient myself around what's going on. I haven't yet downloaded nwnx, so I'm taking a look at that now to try to get my head around that!

One other question -- can this then only be used for the person who's running the multiplayer server? What if I wanted the person running the server and one other person to see the visual effects, but not a third person?

Thanks!
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Help with visual effects for group play
« Reply #8 on: October 04, 2012, 01:16:51 am »


               NWNXFuncs_ApplyVisualEffectForPC(oViewingPC, 13, GetPosition(oPlayer));

This line when called creates a single instance of the visual effect for oViewingPC.

To have 2 players viewing it, you would call it twice, but change the oViewingPC
They wouldnt be seeing the same visual effect, technically, but they would be seeing one that appears at the same location, and they would only see the one that was spawned for them specifically.

eg

NWNXFuncs_ApplyVisualEffectForPC(oPC1, 13, GetPosition(oPlayer));
NWNXFuncs_ApplyVisualEffectForPC(oPC2, 13, GetPosition(oPlayer));

oPC1 and oPC2 will see sparkly eyes above/around oPlayer, but oPlayer himself wont see anything.
               
               

               
            

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help with visual effects for group play
« Reply #9 on: October 04, 2012, 01:20:03 pm »


               Great, thanks! I'll try that and report back about how it goes!
               
               

               
            

Legacy_LindsayReynolds

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help with visual effects for group play
« Reply #10 on: October 04, 2012, 09:58:01 pm »


               I'm having a problem implementing the sample script you provided above -- basically, I'm having trouble getting the NWNXFuncs_ApplyVisualEffectForPC function to compile. It's just not recognizing it at all. I had planned to use "GetCurrentAction" to determine if a PC is performing a melee attack, and if so I want to display an easily distinguishable animation to some but not all of the other characters. It's tough to determine if I'm on the right track without knowing why the ApplyVisualEffect function doesn't want to import properly, but am I at least on the right track? Thanks for your help!
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Help with visual effects for group play
« Reply #11 on: October 05, 2012, 09:54:18 am »


               Some installation is required for the nwnx funcs to work.

https://sourceforge....wnxstuff/files/

Download the latest from there.

Make sure you have nwnx installed as well (it is a separate package that you need in order to use funcs.)

nwnx2 can be got from nwnx.org


When you have got both packages, put all files from each package into the nwn server directory.
Configure the nwnx ini file : with the information you need - eg - ports to use, and module to load.

Then start nwnx.exe and it should start your server for you.

The function I listed, will only be useable if you have included the funcs include file.
http://nwn.virusman..../package files/

anything that is listed as an nss in this folder/site - should probably be replicated in your module.

Then, when you wana use the vfx functions, you just need to make sure you have
#include "nwnx_funcs'  at the top