logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Beta plugin: nwnx_funcs
Goto page Previous  1, 2, 3 ... , 9, 10, 11  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
arvikk



Joined: 29 Sep 2012
Posts: 1

PostPosted: Sat Sep 29, 2012 12:27    Post subject: Reply with quote

you have to change feats separatly.


Code:
void ChangeDomain(object oTarget, int nOldDomain, int nNewDomain)
{
    int nFindFeat = StringToInt(Get2DAString("domains", "GrantedFeat", nOldDomain));
    int nNewFeat = StringToInt(Get2DAString("domains", "GrantedFeat", nNewDomain));

    if(nFindFeat != 0 && nNewFeat != 0) {
        int nIndex = 1;
        if(GetClericDomain(oTarget, nIndex) != nOldDomain) {
            nIndex = 2;
            if(GetClericDomain(oTarget, nIndex) != nOldDomain) {
                nIndex = 0;
            }
        }
        if(nIndex != 0) {
            SetClericDomain(oTarget, nIndex, nNewDomain);

            int nFeatIdx = 0,
                nFeats = GetTotalKnownFeats(oTarget);

            while(nFeatIdx < nFeats) {
                if(GetKnownFeat(oTarget, nFeatIdx) == nFindFeat) {
                    SetKnownFeat(oTarget, nFeatIdx, nNewFeat);
                    break;
                }
                ++nFeatIdx;
            }

            int nHD = GetHitDice(oTarget);
            int nLevel = 1;

            while(nLevel <= nHD) {
                if(GetClassByLevel(oTarget, nLevel) == CLASS_TYPE_CLERIC) {
                    break;
                }
                ++nLevel;
            }

            nFeatIdx = 0;
            nFeats = GetTotalKnownFeatsByLevel(oTarget, nLevel);

            while(nFeatIdx < nFeats) {
                if(GetKnownFeatByLevel(oTarget, nLevel, nFeatIdx) == nFindFeat) {
                    SetKnownFeatByLevel(oTarget, nLevel, nFeatIdx, nNewFeat);
                    break;
                }
                ++nFeatIdx;
            }
        }
    }
}
Back to top
View user's profile Send private message
Monti



Joined: 06 May 2011
Posts: 5

PostPosted: Sun Sep 30, 2012 22:02    Post subject: Reply with quote

Thanks arvikk for the quick answer! I'll test you code Very Happy
Back to top
View user's profile Send private message
DM_Vecna



Joined: 10 Feb 2010
Posts: 37

PostPosted: Mon Jul 07, 2014 6:13    Post subject: Reply with quote

I am trying to use DumpLocalVariables but after debugging it appears that GetLocalVariableByPosition is returning all variable types as 0 for me. Has anyone got this working or is this a known issue? My end goal is to output all the variables on a creature.

Thanks!
Back to top
View user's profile Send private message Send e-mail
Ravine



Joined: 26 Jul 2006
Posts: 105

PostPosted: Tue Jul 08, 2014 10:57    Post subject: Reply with quote

DumpLocalVariables works for me, except it crashes the server when i use it on an area object (at least it was a problem a year ago).
Back to top
View user's profile Send private message
DM_Vecna



Joined: 10 Feb 2010
Posts: 37

PostPosted: Thu Jul 10, 2014 21:33    Post subject: Reply with quote

Thanks Ravine for te help I was able to find the issue which was in the script that I downloaded for this.
Back to top
View user's profile Send private message Send e-mail
farhorizon



Joined: 07 Dec 2012
Posts: 12

PostPosted: Sun Sep 28, 2014 8:09    Post subject: Reply with quote

Is there any hook for 'on player leaving' for the linux version of this plugin? I don't see it documented, but maybe I just missed it, or it is in some other plugin?
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Sep 28, 2014 10:15    Post subject: Reply with quote

farhorizon wrote:
Is there any hook for 'on player leaving' for the linux version of this plugin? I don't see it documented, but maybe I just missed it, or it is in some other plugin?


Don't think so. Just Client Disconnect, at which point the CNWSPlayer object is already disassociated (I think).

Anything in particular you'd want to do with it?
Back to top
View user's profile Send private message
farhorizon



Joined: 07 Dec 2012
Posts: 12

PostPosted: Sun Sep 28, 2014 17:21    Post subject: Reply with quote

I could do a few things with it, but I think they can all be worked around with more scripting.

- track online time by looking at a player logintime (recorded in on client enter) vs their leave time and logging/writing to a db.
- get the area associated with the player leaving & if they were the last player in that area, set a delay command to clean it up if no one enters it in N seconds.
- cleanup custom resources associated with the player


I suppose I can do the first in the standard leave script, I would just need to record some extra information as locals (player account name, ip, etc that is not accesible in the leave script).

For the second, I suppose I could set a local string on the player each time they enter an area, which is the tag of the area & then just load the area via tag when they logout. This doesn't really seem that bad, compared to stray DelayCommands running to see if there is anyone left in an area.

The last could likely be handled by area cleanup scripts, given a decent implementation of the above. Or it could be done via locals in on client leave, if it was cross area stuff.

So, I guess I can work around it without that much trouble after all.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Mon Sep 29, 2014 10:23    Post subject: Reply with quote

Not sure about this (has been a looong time since I fiddled with that), but wouldn't the Area Exit event work for this too? The player object should still be valid then.
Back to top
View user's profile Send private message
farhorizon



Joined: 07 Dec 2012
Posts: 12

PostPosted: Mon Sep 29, 2014 14:57    Post subject: Reply with quote

Based on the lexicon, area exit event won't work for dead players. On client leave also says that you cannot use GetIsPC() and that it happens before area exit, so GetIsPC() probably won't work there either, which is required for our cleanup scripts.

I tested the local var with area tag + client leave and that works fine for area cleanup.

http://www.nwnlexicon.com/index.php?title=OnExit
http://www.nwnlexicon.com/index.php?title=OnClientLeave
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Mon Sep 29, 2014 17:13    Post subject: Reply with quote

Alright, as long as it works. I'm sure one could hook a similar event on linux too, but it seems kind of low-priority. :)
Back to top
View user's profile Send private message
kucik



Joined: 11 Feb 2009
Posts: 19
Location: Czech Republic

PostPosted: Thu Feb 05, 2015 15:12    Post subject: Reply with quote

Hey. I've tried to dump all variables on modul simply by:

Code:
void __dumpModuleVariables() {
  object oItem = GetModule();

  WriteTimestampedLogEntry("************ Dump Module variables ************");
  int cnt = GetLocalVariableCount(oItem);
  int i;
  struct LocalVariable lv;

  WriteTimestampedLogEntry("************ Total "+IntToString(cnt)+" variables************");
  for(i=0;i<cnt;i++) {
    lv = GetLocalVariableByPosition(oItem,i);
    WriteTimestampedLogEntry("* "+lv.name+" ("+IntToString(lv.type)+")");
  }

  WriteTimestampedLogEntry("************ Dump Module variables end *********");

}


But i get 250872632 from GetLocalVariableCount() which i dont believe is correct and then server crashes in atempt to read them one by one.
Im using last nwnx changeset (03874980cd045f766bcda06e29219c75d0a96d15) from github.
_________________
Les jambes en l'air, comme une femme lubrique,
Brûlante et suant les poisons,
Ouvrait d'une façon nonchalante et cynique
Son ventre plein d'exhalaisons.
Back to top
View user's profile Send private message Visit poster's website
Ravine



Joined: 26 Jul 2006
Posts: 105

PostPosted: Thu Feb 05, 2015 16:59    Post subject: Reply with quote

Yeah, afaik i had the same problem, maybe it's happens with area objects also.
Back to top
View user's profile Send private message
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Sun Mar 29, 2015 20:48    Post subject: Reply with quote

Is there a reason only spells can be used for SetRawQuickbarSlot ? I'd like to remove this check: type != QUICKBAR_TYPE_SPELL

Can this be removed from this file? I've attempted to do it myself, but the build process doesn't seem to work for me.

https://github.com/NWNX/nwnx2-linux/blob/master/plugins/funcs/funcs/quickbar/f_SetQuickBarSlot.c
Back to top
View user's profile Send private message
orth



Joined: 10 Apr 2005
Posts: 12

PostPosted: Mon Mar 30, 2015 4:09    Post subject: Reply with quote

Zunath wrote:
Is there a reason only spells can be used for SetRawQuickbarSlot ? I'd like to remove this check: type != QUICKBAR_TYPE_SPELL

Can this be removed from this file? I've attempted to do it myself, but the build process doesn't seem to work for me.

https://github.com/NWNX/nwnx2-linux/blob/master/plugins/funcs/funcs/quickbar/f_SetQuickBarSlot.c


The code as it was did not support anything other than spells, feats, skills and some other random slot types like emotes, modes (Power Attack, Expertise etc). I'm not sure why it was limited to spells only though.

Items, custom macros and DM creator commands would never have worked.

I just so happened to rework this entirely to handle all quick bar types. I'm not a very advanced C programmer though so if anyone wants to take a look at my changes and let me know if there are better/easier ways to do things they're available here: https://github.com/plenarius/nwnx2-linux/commit/5c6738ad6c9cb7a768db52810505a412be1c70b6

The functions return a string of 4 fields separated by pipes (|) when you Func_GetQuickBarSlot and expects 7 fields separated by the not sign (¬) when you Func_SetQuickBarSlot. The pipe is necessary because there are spaces used in custom macro and dm creator label/commands. If a user includes a pipe in one of these two strings for some reason, they get an error.

Items in quickslots were a challenge to Get and Set in some persistent sense. You have to use StringToObject and store a var on the object for later retrieval.

Anyway, I made a generic lib available (not very well commented! sorry) if it might save you some time. You'll need a function that returns your player's unique identifier if you're building for a persistent world and edit the GetPlayerID function.

You can set the command either by voice chat or conversation, on our site we use "=c qb save default" for example then can be later restored with "=c qb restore default" The on player chat sets the LocalString "last_qb_command" and then executes the script from there.

NSS: https://github.com/plenarius/nwnx2-linux/blob/full_quickbars/plugins/funcs/nwnx_qb.nss
SQL: https://github.com/plenarius/nwnx2-linux/blob/full_quickbars/plugins/funcs/nwnx_qb.sql

This all might be moot if you're having trouble building though! That might be something you wish to work out first, heh.

Cheers
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3 ... , 9, 10, 11  Next
Page 10 of 11

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group