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 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
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Wed Aug 13, 2008 4:46    Post subject: Beta plugin: nwnx_funcs Reply with quote

The nwnx_funcs plugin can now be found in the Subversion repository for NWNX Linux. It contains a large number of functions developed for the NWNeXalt system on Higher Ground.

In addition, the functions from nwnx_functions have been cleaned up and ported to nwnx_funcs, making it a replacement for that NWNX plugin.

Code:

void ActionUseItemAtLocation (object oItem, location lTarget, int nProp=0);
void ActionUseItemOnObject (object oItem, object oTarget, int nProp=0);
int AddKnownFeat (object oCreature, int nFeat, int nLevel=-1);
int AddKnownSpell (object oCreature, int nClass, int nSpellLevel, int nSpellId);
int AddSpecialAbility (object oCreature, struct SpecialAbilitySlot sas);
void BootPCWithMessage (object oPC, int nStrRef);
int ClearMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex);
void DumpObject (object oObject);
int GetACNaturalBase (object oCreature);
int GetAbilityIncreaseByLevel (object oCreature, int nLevel);
string GetAllMemorizedSpells (object oCreature);
string GetAllRemainingFeatUses (object oCreature);
int GetBonusSpellSlots (object oCreature, int nClass, int nSpellLevel);
int GetClassByLevel (object oCreature, int nLevel);
int GetClericDomain (object oCreature, int nIndex);
string GetConversation (object oCreature);
string GetCreatureEventHandler (object oCreature, int nEvent);
int GetDamageImmunity (object oCreature, int nDamType);
int GetFactionId (object oObject);
object GetFirstArea ();
struct LocalVariable GetFirstLocalVariable (object oObject);
float GetGroundHeight (object oArea, vector vPos);
float GetGroundHeightFromLocation (location lLoc);
int GetIsVariableValid (struct LocalVariable lv);
int GetIsWalkable (object oArea, vector vPos);
int GetIsWalkableLocation (location lLoc);
object GetItemByPosition (object oCreature, int nPos);
int GetItemCount (object oCreature);
int GetKnownFeat (object oCreature, int nIndex);
int GetKnownFeatByLevel (object oCreature, int nLevel, int nIndex);
int GetKnownSpell (object oCreature, int nClass, int nSpellLevel, int nIndex);
int GetKnowsFeat (int nFeatId, object oCreature);
int GetKnowsSpell (int nSpellId, object oCreature, int nClass=CLASS_TYPE_INVALID);
int GetLocalVariableCount (object oObject);
int GetMaxHitPointsByLevel (object oCreature, int nLevel);
int GetMaxSpellSlots (object oCreature, int nClass, int nSpellLevel);
object GetNextArea ();
struct LocalVariable GetNextLocalVariable (struct LocalVariable lv);
int GetPCBodyBag (object oPC);
int GetPCPort (object oPC);
int GetPCSkillPoints (object oPC);
string GetPortrait (object oCreature);
string GetRawQuickBarSlot (object oPC, int nSlot);
int GetRemainingFeatUses (object oCreature, int nFeat);
int GetRemainingSpellSlots (object oCreature, int nClass, int nSpellLevel);
int GetSavingThrowBonus (object oCreature, int nSave);
int GetSkillIncreaseByLevel (object oCreature, int nLevel, int nSkill);
int GetSoundset (object oCreature);
int GetTotalFeatUses (object oCreature, int nFeat);
int GetTotalKnownFeats (object oCreature);
int GetTotalKnownFeatsByLevel (object oCreature, int nLevel);
int GetTotalKnownSpells (object oCreature, int nClass, int nSpellLevel);
int GetTotalSpecialAbilities (object oCreature);
int GetWizardSpecialization (object oCreature);
object IntToObject (int nObjectId);
void JumpToLimbo (object oCreature);
struct LocalVariable GetLocalVariableByPosition (object oObject, int nPos);
struct MemorizedSpellSlot GetMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex);
int ModifyAbilityScore (object oCreature, int nAbility, int nValue);
int ModifyCurrentHitPoints (object oCreature, int nHP);
int ModifySkillRank (object oCreature, int nSkill, int nValue);
int RemoveKnownFeat (object oCreature, int nFeat);
int RemoveKnownSpell (object oCreature, int nClass, int nSpellId);
int RemoveSpecialAbility (object oCreature, int nIndex);
int ReplaceKnownSpell (object oCreature, int nClass, int nOldSpell, int nNewSpell);
int RestoreReadyFeats (object oCreature, string sFeats);
int RestoreReadySpells (object oCreature, string sSpells);
int SetACNaturalBase (object oCreature, int nAC);
int SetAbilityScore (object oCreature, int nAbility, int nValue);
int SetAlignmentGoodEvil (object oCreature, int nValue);
int SetAlignmentLawChaos (object oCreature, int nValue);
int SetClericDomain (object oCreature, int nIndex, int nDomain);
string SetConversation (object oCreature, string sConv);
string SetCreatureEventHandler (object oCreature, int nEvent, string sScript);
int SetCreatureSize (object oCreature, int nSize);
int SetCurrentHitPoints (object oCreature, int nHP);
int SetFactionId (object oObject, int nFaction);
int SetGoldPieceValue (object oItem, int nValue);
int SetItemWeight (object oItem, int nTenthLbs);
int SetKnownFeat (object oCreature, int nIndex, int nFeat);
int SetKnownFeatByLevel (object oCreature, int nLevel, int nIndex, int nFeat);
int SetKnownSpell (object oCreature, int nClass, int nSpellLevel, int nIndex, int nSpellId);
int SetMaxHitPoints (object oCreature, int nHP);
int SetMaxHitPointsByLevel (object oCreature, int nLevel, int nValue);
int SetMemorizedSpell (object oCreature, int nClass, int nLevel, int nIndex, struct MemorizedSpellSlot mss);
int SetMovementRate (object oCreature, int nRate);
int SetPCBodyBag (object oPC, int nBodyBag);
int SetPCLootable (object oPC, int nLootable);
int SetPCSkillPoints (object oPC, int nSkillPoints);
int SetPortrait (object oCreature, string sPortrait);
int SetRacialType (object oCreature, int nRacialType);
void SetRawQuickBarSlot (object oPC, string sSlot);
int SetRemainingSpellSlots (object oCreature, int nClass, int nSpellLevel, int nSlots);
int SetSavingThrowBonus (object oCreature, int nSave, int nValue);
int SetSkillRank (object oCreature, int nSkill, int nValue);
int SetSoundset (object oCreature, int nSoundset);
int SetSpecialAbility (object oCreature, int nIndex, struct SpecialAbilitySlot sas);
string SetTag (object oObject, string sTag);
int SetTrapCreator (object oTrap, object oCreator);
int SetWizardSpecialization (object oCreature, int nSchool);
struct SpecialAbilitySlot GetSpecialAbility (object oCreature, int nIndex);


This plugin is Linux only at this time, and I do not have plans to port it to Windows, although Virusman may choose to in the future.

Acaos


Last edited by acaos on Wed Aug 13, 2008 17:10; edited 1 time in total
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Wed Aug 13, 2008 16:15    Post subject: Reply with quote

SpiderX wrote:
acaos
I understand that this plugin is beta, but here you`ve posted:
Quote:
Yes, nwnx_funcs is a complete replacement for nwnx_functions.

But I don`t see some functions from nwnx_functions in list you provided.
Quote:
int GetArmorAC(object oObject);
void SetArmorAC(object oObject, int iAC);
int GetDescriptionLength(object oObject);
int GetUndroppableFlag(object oItem);
void SetUndroppableFlag(object oItem, int bUndroppable);
int GetItemWeight(object oObject);
void SetItemWeight(object oObject, int nWeight);
string GetEventHandler(object oObject, int nEventId);
void SetEventHandler(object oObject, int nEventId, string sScript);
void Set2DAString(string s2DA, string sColumn, int nRow, string sValue);
struct scriptvar GetFirstLocalVariable(object oObject);
struct scriptvar GetNextLocalVariable(object oObject);
int GetItemCount(object oTarget);
void RestartServer();
void DebugMe(object oObject);
void ObjectDump(object oObject);

As for GetArmorAC, I assume that it was replaced by int GetACByType (object oCreature, int nACType=AC_DODGE_BONUS) in nwnx_defenses,
but how about others functions?
You just missed this functions in list? You don`t have time to include all functions from nwnx_functions to nwnx_func? Or you are not going to add this functions at all?

P.S. Set2daString doesn`t work.
P.P.S. Great work anyway Smile



  • GetArmorAC() is easily done in the main game scripting (function pasted below).
  • SetArmorAC() didn't really work. If you want to edit a creature's natural base AC however, SetACNaturalBase() is provided.
  • GetDescriptionLength() is easily done with GetStringLength(GetDescription(object)).
  • Bioware provides Get/SetDroppableFlag() now to toggle drop behavior from monsters, and Get/SetItemCursedFlag() to toggle no-drop on items.
  • SetItemWeight() is in the list. GetWeight() is a base Bioware function.
  • Get/SetEventHandler() are now Get/SetCreatureEventHandler().
  • GetItemCount() is in the list.
  • GetFirst/NextLocalVariable() - the plugin now has GetLocalVariableByPosition() as well as GetLocalVariableCount(). I'll add a first/next wrapper.
  • Set2DAString() tended to crash the server badly. It was a really nifty hack, but unfortunately tended to be very fragile.
  • RestartServer() would be part of the nwnx_resetplugin plugin.
  • DebugMe() was only needed for development. ObjectDump() is now DumpObject()


Acaos


Last edited by acaos on Wed Aug 13, 2008 16:24; edited 2 times in total
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Wed Aug 13, 2008 16:19    Post subject: GetItemACBase() Reply with quote

Code:
int GetItemACBase (object oItem) {
    if (!GetIsObjectValid(oItem))
        return 0;

    switch (GetBaseItemType(oItem)) {
        case BASE_ITEM_SMALLSHIELD: return 1;
        case BASE_ITEM_LARGESHIELD: return 2;
        case BASE_ITEM_TOWERSHIELD: return 3;
        case BASE_ITEM_ARMOR: break;
        default: return 0;
    }

    int bID = GetIdentified(oItem);

    SetIdentified(oItem, FALSE);

    int nBaseAC = 0;

    switch (GetGoldPieceValue(oItem)) {
        case 5:    nBaseAC = 1; break;  // Padded
        case 10:   nBaseAC = 2; break;  // Leather
        case 15:   nBaseAC = 3; break;  // Studded Leather / Hide
        case 100:  nBaseAC = 4; break;  // Chain Shirt / Scale Mail
        case 150:  nBaseAC = 5; break;  // Chainmail / Breastplate
        case 200:  nBaseAC = 6; break;  // Splint Mail / Banded Mail
        case 600:  nBaseAC = 7; break;  // Half Plate
        case 1500: nBaseAC = 8; break;  // Full Plate
    }

    SetIdentified(oItem, bID);

    return nBaseAC;
}
Back to top
View user's profile Send private message
SpiderX



Joined: 14 Aug 2007
Posts: 12

PostPosted: Wed Aug 13, 2008 16:44    Post subject: Reply with quote

Everything now is clear. Thank you. Smile
And sorry for posting in wrong topic, I still don`t understand how it`s happened. Embarassed
Back to top
View user's profile Send private message
max196



Joined: 26 Jun 2008
Posts: 30

PostPosted: Thu Aug 14, 2008 4:02    Post subject: Reply with quote

Would be possibile to have more info/documentation for this function?

/* Restore the remaining feat uses for oCreature from the given string. */
int RestoreReadyFeats (object oCreature, string sFeats);

I tried to use string GetAllRemainingFeatUses (object oCreature) to understand it but the format is obscure:)

The aim is to restore the feats with a 1 use a day that are not very useful in game.

thanks,
Max
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Thu Aug 14, 2008 4:15    Post subject: Reply with quote

It's pretty opaque - basically its only purpose is to take the output of GetAllRemainingFeatUses(). We used it on Higher Ground before 1.69 came out to prevent feats from recharging on login.

I'll try to update the documentation some.

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



Joined: 11 Feb 2005
Posts: 76

PostPosted: Sat Aug 16, 2008 23:16    Post subject: Reply with quote

Hi.
Setting EventHandler for PCs by funcs not working, with functions there is no problem.
I'm using OnDeath event because functions like GetLastKiller works fine also for spells victims.

Also i'm intrested in comment /* warning: this leaks memory */.
This mean that asm method in functions does'nt cause memleaks?
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Sun Aug 17, 2008 18:28    Post subject: Reply with quote

Hi I got request for veeer useful thing.

I got idea how to do conversation script more like those in nwn2.

Simply there is Comment field you can wrote some text, such as Tag=sh_gate;GP=500;

So with nwnx_events and new function
string GetCommentFromConversationNode(int nNode)

It would be possible to make very similar system like nwn2!

Shame for me im running windows Smile.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Sun Aug 17, 2008 21:24    Post subject: Reply with quote

I'll look into SetCreatureEventHander in nwnx_funcs. Yes, it leaks memory, but the one in funcs can cause crashes and also (unless I misremember) can't set an event handler name longer than the previously existing one.

As for the conversation request, you'll probably need to ask virusman about that since it would have to tie into the nwnx_events convo stuff and I haven't delved deeply into that.

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



Joined: 11 Feb 2005
Posts: 76

PostPosted: Sun Aug 17, 2008 21:49    Post subject: Reply with quote

Ok, thanks for yor respons Smile
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 18, 2008 6:25    Post subject: Reply with quote

I've just committed a fix to make SetCreatureEventHandler() work.

It still has the memory leak, but the leak is very small (at most 16-20 bytes per invocation). I'm just not comfortable freeing memory allocated by NWN (I think that's what caused our crashes trying to use it before). As long as you're not spam calling it, (I'm guessing you're setting it on PC creation or something) the leak shouldn't be very bad. I'll try to find a better way to do it that won't leak memory as well.

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



Joined: 26 Jun 2008
Posts: 30

PostPosted: Mon Aug 18, 2008 9:03    Post subject: Reply with quote

Would it possibile to know the limits of the spell functions? I mean what is possibile to do without go againts the nwn engine. For example is possibile to add a lvl9 spell for a lvl 10 sorcerer (assuming charism 19)? I noticed that funcs add the spell in the spellbook but the engine make it impossibile to use.
Seems to be impossible also to go over 3 kwown spell at lvl 9 (for sorc).
A
nyway I'm interested in general in knowing what is possibile to do in nwn using funcs plugin without using hak (ok to use server side overrides).
Thsnks,
Max
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 18, 2008 16:18    Post subject: Reply with quote

max196 wrote:
Would it possibile to know the limits of the spell functions? I mean what is possibile to do without go againts the nwn engine. For example is possibile to add a lvl9 spell for a lvl 10 sorcerer (assuming charism 19)? I noticed that funcs add the spell in the spellbook but the engine make it impossibile to use.
Seems to be impossible also to go over 3 kwown spell at lvl 9 (for sorc).
A
nyway I'm interested in general in knowing what is possibile to do in nwn using funcs plugin without using hak (ok to use server side overrides).
Thsnks,
Max


You cannot successfully add a spell that the caster could never cast (that is, not enough character levels, for example). However, you can add additional spells to sorcerers and bards if they could normally cast spells of that level, although they will not save. So you can grant temporary knowledge of additional spells. Although it's not implemented yet, we're planning to use this to add Extra Spell Known feats on Higher Ground.

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



Joined: 28 Nov 2007
Posts: 135

PostPosted: Wed Aug 20, 2008 16:01    Post subject: Reply with quote

where can i find the downloand for the funcs? I looked in the SVn announcement in this forum and i found something named funcs, but it was empty
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Wed Aug 20, 2008 17:44    Post subject: Reply with quote

You need to use a Subversion client to check out the repository. You can't just visit the URL in a browser.

Acaos
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 1, 2, 3 ... 9, 10, 11  Next
Page 1 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