Author Topic: Trigger Finger  (Read 545 times)

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« on: September 09, 2011, 04:23:14 am »


               Searches have yielded limited options when it comes to trigger geometry, and I'm just seeing if anyone has had any ideas/luck with this more recently.

Basically, what I need is a way to spawn a waypoint inside a certain trigger - as long as it's within the bounds of the destination trigger. It sounds simple, but GetLocation() on a trigger yields only one of its corners and I haven't found anything on the Omnibus that presents a solution to this (just many folks that had the same conundrum).

I might have to review my system if this isn't possible, but I thought it was worth a shot asking. Thanks in advance.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Trigger Finger
« Reply #1 on: September 09, 2011, 04:30:58 am »


               windows nwnx_funcs have a function that gets trigger geometry data, its not documented and I have used it only as a variable for respawning traps but its certainly possible now
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #2 on: September 09, 2011, 04:39:30 am »


               oOo

I'll check that out, thanks.
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #3 on: September 09, 2011, 05:27:03 am »


               Oh my. I think I'm set, but still...

It took me this long to track down this link on a pretty old post on the nwnx.org forums: nwvault.ign.com/View.php.

I'm just curious if there is a complete list of plugins somewhere that is up-to-date. The one on nwnx.org contains several of the outdated ones instead of, for example, the one listed above.

P.S.: A search for "nwnx" on the vault did not turn this up, otherwise I wouldn't ask.
               
               

               


                     Modifié par Hardcore UFO, 09 septembre 2011 - 04:30 .
                     
                  


            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #4 on: September 09, 2011, 06:23:51 am »


               Just to see if I got this correctly:

1) I have NWNX2 in my NWN folder, but I don't need to run this to do any scripting with NWN, right?

2) I have added lines to NWNX2. ini as indicated by the readme of the nwnx_funcs.

3) I have copy-pasted the contents of nwnx_funcs and company into scripts that have been saved under the same names.

Is that it? Should I be able to use all the functions contained in nwnx_funcs freely now? I tried a test but I keep getting mismatched types when I compile. I'm going to try again when my brain is a bit sharper, but I'm wondering if the basic outline of what I did sounds right (the talk of NWNX being external modules confuses me).
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #5 on: September 09, 2011, 06:47:59 am »


               Eh... As soon as I stopped, I wanted to try again. Sludgy brain be damned. So here is what I am trying, just to see what sort of output I'm dealing with as well as if I've incorporated the scripts correctly.

Using this function:

string NWNXFuncs_GetTrapGeometry(object oTrap) {
   string sSpacer = "--------------------------------------------------------------------------------------------------------------------------------";
   sSpacer += sSpacer + sSpacer + sSpacer;
   SetLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY", sSpacer);
   string sRet = GetLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY");
   DeleteLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY");
   return sRet;
}

What I get when I test this in a trigger's OnEnter using the script below is just what the function suggests it would put out: i.e. "------------------------------------------------" times three. What I'm using is this:

#include "nwnx_funcs"

void main()
{
   string sStuff = NWNXFuncs_GetTrapGeometry(OBJECT_SELF);
   object oPC = GetEnteringObject();

   SendMessageToPC(oPC, sStuff);
}

I'm not seeing how the function deals with coordinates in any way. Do I have to modify it somehow? If so, in turn the same original problem recurs: what function does that? There are examples with the nwnx_funcs download that show how to lay down traps with custom coordinates that can then be called, but that's not helping me evaluate the coordinates of an existing non-trap trigger (which cannot be created, as far as I have found by the occurences of "trigger" in these scripts).
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Trigger Finger
« Reply #6 on: September 09, 2011, 11:24:44 am »


               You also have to add a new section into NWNX.ini

[FUNCS]
Number_of_Skills=28
HOOK_CustomTrapGeometry=1
HOOK_OnPlayerLeaving=1
OnPlayerLeavingScript=ev_scr_exit
; DebugLevel=[0|1|2|3]; defaults to 0
debugLevel=3

MaxRock explained it as the geometry functions are a bit expnsive on CPU so you have to enable them
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #7 on: September 09, 2011, 11:43:24 am »


               I did that. Well, mostly what you have posted here. There are some differences though.

[FUNCS]
;Number_of_Skills, the amount of skills from skills.2da (last row+1)
Number_of_Skills=28

;debugLevel: 1 should only show basic information, 2 should include errors and 3 should log pretty much everything
debugLevel=0

;Set this to 1 to use the CustomTrapGeometry functions
HOOK_CustomTrapGeometry=1

;Hook for a new OnPlayerLeave event which runs before OnClientLeave
;Makes it possible to retrieve information about the player object as usual (GetName, GetArea, etc)
;In the onplayerleaving script, OBJECT_SELF is the player object about to leave
HOOK_OnPlayerLeaving=1
OnPlayerLeavingScript=onplayerleaving

I just copy-pasted what was in the readme. The OnPlayerLeaving script is different, but I don't know that I have one called ev_scr_exit. Either way, I don't understand how a script that goes...

string NWNXFuncs_GetTrapGeometry(object oTrap) {
string sSpacer = "--------------------------------------------------------------------------------------------------------------------------------";
sSpacer += sSpacer + sSpacer + sSpacer;
SetLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY", sSpacer);
string sRet = GetLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY");
DeleteLocalString(OBJECT_SELF, "NWNX!FUNCS!GETTRIGGERGEOMETRY");
return sRet;
}

Is supposed to divine the coordinates of anything. It only fetches strings. That's what has me baffled at this point.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Trigger Finger
« Reply #8 on: September 09, 2011, 11:53:48 am »


               I wasnt aware that this function worked with triggers, just traps.

Anyhow.
Basically, the functionality of the nwnx_funcs hooks into the function that is in nwn script, for Creating a Trap at a location.

(I dunno if you can specifiy a trigger resref instead of trap - maybe you can?)

In any case.
You need to call the NWNXFuncs_GetTrapGeometry(object oTrap)   targetting a trap with the geometry that you desire.
(paint it down in toolset, then target it, use it as a template)

Then, this gives you a delimitated list of x,y,z coordinates.

There is then a nwnx_funcs function, for setting trap geometry.
You call this function, before using the nwn script function for spawning the trap.
It will then override the default trap spawning function, and give it new geometry.

so

1. Call GetTrapGeometry  (store the coords)
2. Call SetTrapGeometry (use the values from 1)
3. Call CreateTrapAtLocation   (it should have the geometry from the template trap that u targetted in step 1)
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Trigger Finger
« Reply #9 on: September 09, 2011, 02:04:04 pm »


               I think what OP is trying to do is retrieve the xy coordinates from the stored coordinates (GetTrapGeometry) so that he can find a center point for the trigger/trap to spawn a waypoint at. How to do this I have no idea since I've never seen or used any of these functions.
But from what I gather it sounds like it is a delimited string that could be broken up into its various coordinates?
               
               

               


                     Modifié par GhostOfGod, 09 septembre 2011 - 01:11 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Trigger Finger
« Reply #10 on: September 09, 2011, 02:06:28 pm »


               Yes Baaleos it works on trigger. UFO if it still returns ----- are you sure you are running the server correctly? run nwnx.exe which runs nwserver then load module then enter module ?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Trigger Finger
« Reply #11 on: September 09, 2011, 04:28:21 pm »


               

Hardcore UFO wrote...

Is supposed to divine the coordinates of anything. It only fetches strings. That's what has me baffled at this point.


Pretty much every NWNX function works that way - they use those strings to pass commands to NWNX. Take, for example, GetLocalVariableCount:


int GetLocalVariableCount (object oObject) {
    DeleteLocalString(oObject, "NWNX!FUNCS!GETLOCALVARIABLECOUNT");
    DeleteLocalString(oObject, "NWNX!FUNCS!GETLOCALVARIABLEBYPOSITION");

    int nVariables = NWNXFuncsZero(oObject, "NWNX!FUNCS!GETLOCALVARIABLECOUNT");
    DeleteLocalString(oObject, "NWNX!FUNCS!GETLOCALVARIABLECOUNT");

    return nVariables;
}

All it does in nwscript is set and delete variables (NWNXFuncsZero just sets a variable, too). You won't find the meat and potatoes in nwscript - it's handled by NWNX. The Get/Set strings are just 'bridge' functions, used to pass information.

Of course, for all this to work, you need to have started the mod using NWNX. You can't just drop functions into your scripts and expect them to work without NWNX running in the background. The old, dare I say 'normal' way of doing this is by means of the NWNX executable that runs the mod as a server, though virusman also made a new version aimed at single player use. Did you launch your mod with NWNX?

Funky
               
               

               


                     Modifié par FunkySwerve, 09 septembre 2011 - 03:29 .
                     
                  


            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #12 on: September 09, 2011, 09:01:21 pm »


               I am not sure of anything at this point, ShaDoOoW.

However, now knowing all that, I have tried (a couple times only, I admit - I'm taking off really soon), to no avail.

This is what I get when I start NWNX:

'Image

"vrenna" is the name of the module I test things in, then export them if they work. I changed the name of the module to run in NWNX.ini to "vrenna" as well. Suffice to say, it's not running and I don't see the option for loading modules that I keep reading about.

Sorry in advance if I missed something blatant in my haste.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Trigger Finger
« Reply #13 on: September 09, 2011, 09:03:54 pm »


               try remove "
               
               

               
            

Legacy_Hardcore UFO

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Trigger Finger
« Reply #14 on: September 10, 2011, 04:22:54 am »


               "vrenna", vrenna, and Vrenna have been tried (in NWNX.ini), to no avail. I still just get "-------------" in my combat log for the test trigger. However I notice that you said "load the module then enter it" - I don't know how to load modules in NWNX as I said, from the interface I posted above it doesn't look like it will let me anywhere. How do I do that?

Thanks for the patience.