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 ... 5, 6, 7 ... 9, 10, 11  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
Calan



Joined: 23 Mar 2009
Posts: 16

PostPosted: Wed Mar 25, 2009 7:22    Post subject: Reply with quote

Thanks for the reply, Funky!

FunkySwerve wrote:

Acaos is pretty busy right now, as we're migrating our servers to a new host, so I'll answer briefly for him. I occasionally complain to him about this or that documentation being incomplete (he hates doccing), but in most cases you can figure it out. In this case, it'd take you 5 minutes tops to figure out whether it's the new total, which would be my assumption, since anything else would be useless for debug, which is the obvious use of a Set that returns anything. Hardly useless. Actually, I'm nearly positive that's what it does, since I seem to recall using sets with an add of 0 to get base value in some script or another.


Yes, I could guess, or test it, or even dig through code and figure it out. The issue isn't even really that command in particular, just that there are return values in general that aren't explained. A couple extra words in the doc for each function would allow people to use the return value, since it's there.

FunkySwerve wrote:

His autoformatter does that, much to my chagrin (I've also complained about it in our mod's includes). Again, however, all you have to do is reformat them yourself if you want them to pull up in the help window. Frankly, I'd rather you spend that time than he, since he can spend it making other functions, among other things. Would also not take long in a text editor.


Ah, autoformatter.. I see, yeah that stinks there. Smile I personally would strongly suggest that released versions get edited in a text editor before release. Yes, I can find/replace easily, but it would in the end be easier for everyone in the long run if it was done once before releasing. During beta I can understand then, since it's autoformatted. This isn't a request for myself (as I can find/replace) but just a suggestion for the released version.

FunkySwerve wrote:

Actually, it tells you EVERYTHING about what it's doing. Those fields aren't used in the engine (by PCs). You would only set them if you were using them to store other data, as we do. Ditto tag, though some people write scripts with the assumption that pc tag will be blank, which is otherwise is.


Well thing is, NWNX n00bs *raises hand* don't know that, and a simple "This value does nothing to the PC, but can be used to store a number in the PC's bic file" would explain it.

I would also like to point out that a small bit of documentation can save not only the users tons of time trying to figure things out, but also the developers. In the end, n00bs like me just come running to the forums to ask questions and take up time, for things that could have been stated once in the documentation. It's also just a shame to see great code go to waste because it's not explained how to use it.

What -is- the string format for RestoreReadySpells() anyway? Razz

Once again, thanks for the reply.
Back to top
View user's profile Send private message Visit poster's website
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Wed Mar 25, 2009 16:34    Post subject: Reply with quote

Calan wrote:
Thanks for the reply, Funky!


Well thing is, NWNX n00bs *raises hand* don't know that, and a simple "This value does nothing to the PC, but can be used to store a number in the PC's bic file" would explain it.

That's the root of your problem right there. This is a beta, and is not intended for newbies. I imagine the final version will be a bit more polished.

Quote:

What -is- the string format for RestoreReadySpells() anyway? Razz


RestoreReadySpells(oTarget, "%0");

to wipe all spells, %50 to wipe half (other percentages, including over 100%, are also possible, though I don't know what they do).

Funky
Back to top
View user's profile Send private message
Calan



Joined: 23 Mar 2009
Posts: 16

PostPosted: Wed Mar 25, 2009 22:14    Post subject: Reply with quote

FunkySwerve wrote:
That's the root of your problem right there. This is a beta, and is not intended for newbies. I imagine the final version will be a bit more polished.


Fair enough. I have a tendency to dive right in, I'll be writing my own custom plugins by the end of next month. Smile

That said, my comments were intended for the final version, just that the documentation in it's state isn't adequate for final release as eventually newbies -will- be trying to use it, so beta testing by a noob isn't all that invalid. Given some of the constraints you've explained, and the fact it's in beta, I can understand and live with the current state. I thought I would mention it though, as beta is generally the phase you're in when you are trying to polish for a final release, and asking for beta-testers' issues that they've found, so I was doing just that.

And thank you much for the explanation of the string format!

-Calan
Back to top
View user's profile Send private message Visit poster's website
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Thu Mar 26, 2009 21:03    Post subject: Reply with quote

Calan wrote:
As with almost every other function, this returns a value even though it's a "Set" function, which is fine, but it is not documented what is returned. This doesn't make the function useless, obviously, but the return value is useless because no one knows what it means.

It returns the new value of the ability score (in general, all the Exalt sets do this).

Quote:
These functions involve strings, but the format of the strings are never explained. A simple explanation in the documentation for each function would do wonders for the usability of the functions.

Actually, the strings are intended to be opaque cookies. I'll add a note mentioning that.

Acaos
Back to top
View user's profile Send private message
Ravine



Joined: 26 Jul 2006
Posts: 105

PostPosted: Sat Apr 04, 2009 13:37    Post subject: Reply with quote

Hello!

I'm just playing with these functions, adding feats to players and stuff.
However, i can add feats by level, but can't do remove feats from level Shocked This makes the PC unusable, ELC kicks him.
I found the RemoveKnownFeatByLevel function in the sources, but it's empty... ( "TODO" ).
I jusst wanna ask: is it ready, or will be ready sometime Question

thx
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Mon Apr 06, 2009 0:41    Post subject: Reply with quote

You need to turn off ELC if you're editing characters, and use scripted ELC instead. Most changes will violate its strictures - I'm amazed you haven't had trouble with adding.

Funky
Back to top
View user's profile Send private message
Ravine



Joined: 26 Jul 2006
Posts: 105

PostPosted: Mon Apr 06, 2009 8:27    Post subject: Reply with quote

FunkySwerve wrote:
You need to turn off ELC if you're editing characters, and use scripted ELC instead. Most changes will violate its strictures - I'm amazed you haven't had trouble with adding.

Funky


I had troubles, but if i make the changes to the 2da's, it won't break anything.
However, i'm currently only using the feat-stuff for changing domains and domain-feats for the player (fix domains for fix gods). With this plugin i can change the domains, can remove and add the feats from featlist, but can't remove feats from the LvlStatList (and i don't wanna use letoscript again).
However, i made a kludge with the available SetKnownFeatByLevel, which works like a replace (with the GetTotalKnownFeatsByLevel), so far so good. But the RemoveKnownFeatByLevel would be better Confused
Back to top
View user's profile Send private message
SartriX



Joined: 13 Jul 2008
Posts: 16

PostPosted: Mon Apr 13, 2009 11:51    Post subject: Reply with quote

An addition for nwnx_funcs I made quite some months ago is ModifySkillRankByLevel(). The reason I needed it is because I built a custom skill levelling system in my module. The regular ModifySkillRank would only make changes to level 1, which caused various inconsistencies like not removing the skillpoints when levelling down, nor being detected by GetSkillIncreaseByLevel().

Ergo: To set the skillpoints gained on a specific level I've written this:

Code:
#include "NWNXFuncs.h"


void Func_ModifySkillRankByLevel (CGameObject *ob, char *value) {
    int level, skill, val;
    CNWSCreature *cre;
    CNWSStats_Level *ls;

    if (ob == NULL                                              ||
        (cre = ob->vtable->AsNWSCreature(ob)) == NULL           ||
        cre->cre_stats == NULL                                  ||
        sscanf(value, "%d %d %d", &level, &skill, &val) != 3    ||
        skill < 0 || skill > SKILL_LAST                         ||
        (ls = nwn_GetLevelStats(cre->cre_stats, level)) == NULL) {

        snprintf(value, strlen(value), "-1");
        return;
    }

    ls->ls_skilllist[skill] += val;

    val = cre->cre_stats->cs_skills[skill] + val;
    if (val < 0) val = 0;
    if (val > 127) val = 127;
    cre->cre_stats->cs_skills[skill] = val;

    snprintf(value, strlen(value), "%d", val);
}

Which has been working and running on my server since october now.

With it, I've been able to rename and change skills, without needing any 2da overrides or haks, as well as adding skill-trained languages and knowledge skills with synergies.
Back to top
View user's profile Send private message
Paul R



Joined: 17 Apr 2009
Posts: 42

PostPosted: Mon May 11, 2009 13:39    Post subject: SetCreatureSize() usage Reply with quote

Hi (first time poster, long time lurker so firstly thank you all for the hard work done in opening up the game and engine Very Happy).

I have a few of the different nwnx_ overrides in place and working great including nwnx_funcs but I was wondering if there were certain conditions of using the SetCreatureSize() function?

Code:
int SetCreatureSize (object oCreature, int nSize);


The function seems to be called correctly, it's a valid creature object and using one of the CREATURE_SIZE_* constants for nSize, the following is logged in the nwnx_funcs.txt file when I try and use it but nothing visually alters (assuming it is supposed to and not just a way to get the engine to handle combat differently Confused):

Code:
StrReq: "SETCREATURESIZE"
Params: "4          "
Return: "4          "


Is there anything else required or will it only work under certain conditions? Only with certain models for instance, need to log out of the area and back in before it is visible or am I missing a step somewhere?

Other info:
    the function is called by a targeted DM Tool feat, standard GetCreatureSize() call works correctly.
    compiled from svn trunk and recently updated to revision 240 (but using 2.7.1-dev).
    other functions in nwnx_funcs such as SetQuickBarSlot() work fine.


Thank you for your time.

Cheers,

Paul
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon May 11, 2009 21:08    Post subject: Reply with quote

It only affects internal engine information. There will be no visual change.

Acaos
Back to top
View user's profile Send private message
Paul R



Joined: 17 Apr 2009
Posts: 42

PostPosted: Mon May 11, 2009 22:02    Post subject: Reply with quote

Ah, did wonder. Thank you
Back to top
View user's profile Send private message
garrison



Joined: 16 Feb 2009
Posts: 4

PostPosted: Mon Jun 29, 2009 2:21    Post subject: RemoveKnownSpell() Reply with quote

I'm trying to write an OnPlayerLevelUp script to require that certain spells be learned only from scrolls:
Code:
void main(){
    object oPC=GetPCLevellingUp();
    string s0="You may only learn ";
    string s1=" from a scroll.";
    effect eOops = EffectVisualEffect(VFX_IMP_MAGIC_RESISTANCE_USE);
    struct SpellHandle sp = GetSpellHandle(570);
    if(GetKnowsSpell(sp.id, oPC, sp.class)){
        if(!GetPCPref(oPC,sp.name)) {
            RemoveKnownSpell (oPC, sp.class, sp.id);
            FloatingTextStringOnCreature(s0+sp.name+s1,oPC);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eOops, oPC);
        }
    }
}


In testing I get the Floating Text and VFX but the spell remains, is it not possible to remove known spells from a PC? I'm currently at NWNX2 r239

(570 is a custom spell, but I get the same result with e.g. Improved Invisibility)
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Jun 29, 2009 8:14    Post subject: Reply with quote

It looks like there's actually a bug in the RemoveKnownSpell prototype. I'll fix this.

You need to provide class, spell level, -and- spell ID.

Thanks,
Acaos
Back to top
View user's profile Send private message
SpiderX



Joined: 14 Aug 2007
Posts: 12

PostPosted: Mon Jun 29, 2009 13:17    Post subject: Reply with quote

http://nwn.virusman.ru/trac/nwnx2-linux/changeset/251

Quote:
int nFlags = (mss.ready != 0) | ((mss.domain != 0) << 1);


http://nwn.virusman.ru/trac/nwnx2-linux/browser/trunk/plugins/funcs/nwnx_funcs.nss

Quote:
struct MemorizedSpellSlot {
int id;
int ready, meta;
};


", domain" missed.
Back to top
View user's profile Send private message
garrison



Joined: 16 Feb 2009
Posts: 4

PostPosted: Mon Jun 29, 2009 16:40    Post subject: Thanks. Reply with quote

Sweet, thanks. Works like a charm now.

Now if I can just figure out how to pick up use of the Learn property for scrolls I'll be all set (it doesn't seem to fire EVENT_TYPE_USE_ITEM).
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 ... 5, 6, 7 ... 9, 10, 11  Next
Page 6 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