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 
 
back-porting some nwnx-win funcs to linux ?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
xorbaxian



Joined: 18 Dec 2007
Posts: 45

PostPosted: Thu Nov 12, 2015 18:46    Post subject: back-porting some nwnx-win funcs to linux ? Reply with quote

does anyone know if there's still any active development going on for nwnx-linux ? i noticed there's been a lot of dev for some of the windows plugins [e.g. nwnx_funcs and nwnx_events] and was wondering if there are plans to back-port some of the development there.

for my own selfish reasons, i'd love to be able to use NWNXFuncs_GetTrapGeometry, as well as handle EVENT_TRAPTRIGGER so traps don't actually get triggered in certain situations.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Nov 15, 2015 0:37    Post subject: Reply with quote

Hi,

there's no ACTIVE porting work going on but I'm willing to have a look. Can you kindly post links to where I can find the corresponding win32 code for the features you want?

Cheers

Edit: PS: We're rather active in developing nwnx2-linux. Check us out on github. ;)
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Scholar Midnight



Joined: 12 Oct 2014
Posts: 3

PostPosted: Sun Nov 15, 2015 1:40    Post subject: Reply with quote

We've actually been working on a more modern, cross-platform API in the last few weeks. You can check the progress here: https://github.com/ScholarMidnight/NWNX-Unified
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Nov 16, 2015 13:38    Post subject: Reply with quote

A unified library would be great.
I would personally move to Linux if I had my nwnx_cool hooks functionality available on linux.


Code:

int (__fastcall *CNWSCreature__DoDamageNext)(CNWSCreature * cre, void*, int a2);
int (__fastcall *CNWSEffectListHandler__OnApplyDamageNext)( void * pThis, void*, CNWSObject * obj, CGameEffect * effect, int iArg );
int (__fastcall *CNWClass__GetSpellsKnownPerLevelNext)( CNWClass * pThis, void*, uint8_t level, int8_t sp_level, int8_t cls_type, uint16_t race, uint8_t cha );
int (__fastcall *CNWClass__GetSpellGainNext)(CNWClass *cls, void *, uint8_t level, int8_t sp_level);
int (__fastcall *CNWSCreature__ValidateCounterSpellDataNext)(CNWSCreature * cre, void*, nwn_objid_t target, unsigned char arg2, unsigned char arg3);
void (__fastcall *CNWSCreature__SummonFamiliarNext)( CNWSCreature * cre, void*);
void (__fastcall *CNWSCreature__SummonAnimalCompanionNext)( CNWSCreature * cre, void*);




Code:


Not sure if this exists on linux yet - but it is a Damage hook, allowing you to mitigate, prevent, or increase damage on damage application.


int __fastcall CNWSEffectListHandler__OnApplyDamage( void * pThis, void*, CNWSObject * obj, CGameEffect * effect, int iArg )
{

   CNWSCreature * cre = obj->AsNWSCreature();
   char * cData = new char[25];
   if(cre)
   {
      int iShouldRun = obj->obj_vartable.GetInt( CExoString( "onDamageHook" ) );
      if(iShouldRun == 1 || cre->cre_is_pc == 1)
      {
         ResetParameters();
         Cool.frames++;
         Cool.Event = 101;
         Cool.oTarget = cre->obj.obj_generic.obj_id;
         Cool.oTarget2 = effect->eff_creator;
         
                  int i;
               for (i=0; i< 12; i++)
               {
                  
                  //string sVar = "damage_%d";
                  sprintf( cData, "damage_%d", i );
                  int iNum = effect->eff_integers[i];
                  obj->obj_vartable.SetInt(CExoString( cData ),iNum,0);
                  
               }

         Cool.ScriptRunning = true;
         (*NWN_VirtualMachine)->Runscript(&CExoString("nwnx_cool"), cre->obj.obj_generic.obj_id );
         Cool.ScriptRunning = false;                   

            if( Cool.ByPass )
            {
               for (i=0; i< 12; i++)
               {
                  sprintf( cData, "damage_%d", i );
                  int nDamAmount = obj->obj_vartable.GetInt( CExoString( cData ) );
                  effect->eff_integers[i] = nDamAmount;
               }
            Cool.ByPass = false;
            //return Cool.nRetn;
            }
            
         
      }

   }
   delete cData;
   return CNWSEffectListHandler__OnApplyDamageNext(pThis,NULL,obj,effect,iArg);
}

int __fastcall CNWSCreature__ValidateCounterSpellData( CNWSCreature * cre, void*, nwn_objid_t target, unsigned char arg2, unsigned char arg3){
   
   //int nMR = CNWSCreatureStats__GetSpellResistanceNext( cre, NULL );
   //if( cre == NULL )
   //   return nMR;
   //
   //int nEx = cre->cs_original->obj.obj_vartable.GetInt( CExoString( "SR" ) );

   ResetParameters( );

   Cool.Event = 102;
   Cool.oTarget = cre->obj.obj_generic.obj_id;   
   Cool.nData = Cool.nLastSpell;
   Cool.nData2 = target;
   Cool.Log( 1, "o ValidateCounterSpell: %08lx %08lx %i %i\n", cre, target, arg2, arg3 );

   Cool.ScriptRunning = true;
   (*NWN_VirtualMachine)->Runscript(&CExoString("nwnx_cool"), cre->obj.obj_generic.obj_id);
   Cool.ScriptRunning = false;   

   if( Cool.ByPass ){
      Cool.ByPass = false;
      //Do not counter
      return 0;
   }

   //Counter
   return CNWSCreature__ValidateCounterSpellDataNext(cre,NULL, target, arg2, arg3);
}

The counterspell one is used to allow control over whether or not spells are consumed on counterspelling. (epic mage battles etc)





I also use a .Net library : nwnxdotnet - but TBH - I could/should probably refactor this to be nwnx_jvm.
Alternatively, a nwnx library that can execute mono/.Net calls - would be awesome.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Mon Nov 16, 2015 15:35    Post subject: Reply with quote

Baaleos wrote:

Code:

int (__fastcall *CNWSCreature__DoDamageNext)(CNWSCreature * cre, void*, int a2);
int (__fastcall *CNWSEffectListHandler__OnApplyDamageNext)( void * pThis, void*, CNWSObject * obj, CGameEffect * effect, int iArg );
int (__fastcall *CNWClass__GetSpellsKnownPerLevelNext)( CNWClass * pThis, void*, uint8_t level, int8_t sp_level, int8_t cls_type, uint16_t race, uint8_t cha );
int (__fastcall *CNWClass__GetSpellGainNext)(CNWClass *cls, void *, uint8_t level, int8_t sp_level);
int (__fastcall *CNWSCreature__ValidateCounterSpellDataNext)(CNWSCreature * cre, void*, nwn_objid_t target, unsigned char arg2, unsigned char arg3);
void (__fastcall *CNWSCreature__SummonFamiliarNext)( CNWSCreature * cre, void*);
void (__fastcall *CNWSCreature__SummonAnimalCompanionNext)( CNWSCreature * cre, void*);



Nothing of that looks particularily complicated and should be ported in a few hours, worst case. Some of it is already possible or redundant (ApplyDamage is hookable with nwnx_effects, but why would you need it if you already have CNWSObject::DoDamage?).


Baaleos wrote:

Not sure if this exists on linux yet - but it is a Damage hook, allowing you to mitigate, prevent, or increase damage on damage application.


I'm working on that - a plugin that replaces the combat round and offers hooks at various places. It's working fine on my PW but needs a cleanup and more hookpoints. It's just not high priority atm.
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Nov 16, 2015 17:17    Post subject: Reply with quote

Yeah the DoDamage one is a little redundant now that I have
CNWSEffectListHandler__OnApplyDamageNext

The CNWSEffectListHandler__OnApplyDamageNext allows the modification of damage effects (including all damage types and power of those damage types)
(I don't use nwnx_effects - so I was unaware it was already do-able.)


Opposed to DoDamage which is basically the damage application 'after' the calculation phase.

DoDamage can however come in handy, as it allows you to apply damage to characters without any source.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Mon Nov 16, 2015 17:28    Post subject: Reply with quote

Baaleos wrote:
The CNWSEffectListHandler__OnApplyDamageNext allows the modification of damage effects (including all damage types and power of those damage types)
(I don't use nwnx_effects - so I was unaware it was already do-able.)


Here is what I'm doing w.r.t. damage calculation. The AttackRoll hook is nearly identical.

https://code.silm.pw/projects/NWNX/repos/silm/browse/partials/Attacks_ResolveDamage.cpp

The basic idea is to hook both AttackRolls and DamageRolls, then just serialize the whole CombatAttackData struct (which contains attack roll values and damage values after rolling them) into nwscript, like so:

https://code.silm.pw/projects/NWNX/repos/silm/browse/partials/Attacks_CNWSCombatAttackData_Serializer.cpp

Edit in nwscript as you see fit and serialize it back.

https://gist.github.com/niv/3852cc2086aeaae3573c

As you can clearly see it's nowhere near ready for public use. I want to refactor it into a independent plugin, add pluginlink hooks, write up some documentation, examples, etc.

The drawback to this approach is that there are two calls to nwscript with each attack, plus de/serializing overhead. It's minimal but could pose problems on servers that have lots of action going on (2 calls per attack -> 5 calls per second for a 15 attacks/round creature).

It's the best way though if you absolutely need control over all aspects and don't want to write your logic in C++ (which I would strongly recommend in this case).

You can also edit/replace special attacks (which is what I am doing). You can actually plug in any feat ID you want; however, this requires clientside patching to add feats into the specialattacks radial menu.

Let me know if you have any questions. :) I know most people don't really care to understand the combat mechanic intrinsics of NWN (or DND for that matter).
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
leo_x



Joined: 25 Aug 2010
Posts: 75

PostPosted: Tue Nov 17, 2015 22:23    Post subject: Reply with quote

Since you are familiar with Lua via Garry's Mod, I'll add one further suggestion: Solstice. Here is my combat engine. The style is quite low level for performance (about 150us on a low tier VPS) but the most important bits are all Lua side.

Like everything it has its tradeoffs tho and there's a whole framework that needs to be learned, but it's worth considering, I think.

Also there are hooks for SummonFamiliar and SummonAnimalCompanion in nwnx_levels which you could use for the basis of your own work. Not sure the plugin would find enough use for it to be in the main repo.
_________________
the awakening (PW Action)
Back to top
View user's profile Send private message
xorbaxian



Joined: 18 Dec 2007
Posts: 45

PostPosted: Wed Nov 18, 2015 19:04    Post subject: Reply with quote

elven wrote:
Hi,

there's no ACTIVE porting work going on but I'm willing to have a look. Can you kindly post links to where I can find the corresponding win32 code for the features you want?

Cheers

Edit: PS: We're rather active in developing nwnx2-linux. Check us out on github. Wink

thank you ! Smile

here is the link i found to the functions in the latest nwnx_funcs for windows :
http://sourceforge.net/projects/mrnwnxstuff/files

i think the forum thread corresponding to this development is this one :
http://www.nwnx.org/phpBB2/viewtopic.php?t=1535

and i believe the link to the nwnx windows tree is here :
https://github.com/NWNX/nwnx2-win32

thanks again ! looking fwd to hearing about what you come up with !
Back to top
View user's profile Send private message
Nob



Joined: 16 Apr 2005
Posts: 21

PostPosted: Fri Dec 04, 2015 22:48    Post subject: Reply with quote

Out of curiosity what does the *CNWClass__GetSpellsKnownPerLevelNext hook do?

Does it actually fix the spells known calculation bug for sorcs/bards?
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Dec 04, 2015 23:01    Post subject: Reply with quote

The moment when that hook shines is when you want to do levelling systems beyond level 40.
Ordinarily levelling beyond level 49 will produce 0 spells.
By adding the hook it lets you provide spells to spell casters
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Fri Dec 04, 2015 23:03    Post subject: Reply with quote

Nob wrote:
Does it actually fix the spells known calculation bug for sorcs/bards?


Never heard of this specific bug (or I forgot) - what's this about?
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Dec 04, 2015 23:11    Post subject: Reply with quote

Ps: I'm drunk.
I meant 40 when i said 49
Back to top
View user's profile Send private message
Nob



Joined: 16 Apr 2005
Posts: 21

PostPosted: Sun Dec 06, 2015 15:49    Post subject: Reply with quote

elven wrote:
Nob wrote:
Does it actually fix the spells known calculation bug for sorcs/bards?


Never heard of this specific bug (or I forgot) - what's this about?


This is the bug where Sorcerors and Bards don't get new spells known despite getting spell progression (half or full) on a PRC - it's because during the level up process it only counts sorc/bard levels to determine what level spells known you should have instead of counting the total caster level for that caster class.

I'd been trying to hook it in a custom plugin but hadn't had a lot of luck getting it working.

It's actually touched on in the Witch of the Wilds dev post at SILM:
https://silm.pw/display/DEV/2015/01/10/Witch+of+the+Wilds
Quote:
The second issue - not for everyone, but just as or even more showstopping: Spells Known. While a PrC can advance your spells per day, it does not, in fact, grant you new spells to fill those slots. For divine casters, this is a non-issue - they know all spells on their lists right from the start. Wizards do not gain their two free spells per level, but could at least learn new ones via means of scrolls. Sorcerers and bards? Nada. You do not learn new spells through prestige classes, ever. As a sorcerer 5 / prc 5, you might have fifth level slots - but you know only second level spells, exactly the same as any other fifth level sorcerer.

In other words: I found that PrCs as-is are not worth it at all for bards and sorcerers, and are only of marginal use to everyone else, at least if you want to play a primary spellcaster.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Dec 06, 2015 16:51    Post subject: Reply with quote

Nob wrote:
This is the bug where Sorcerors and Bards don't get new spells known despite getting spell progression (half or full) on a PRC

It's actually touched on in the Witch of the Wilds dev post at SILM:


Whoops! Yeah, this rings a bell. Please see the PM I sent you. :)
_________________
silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers.
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
Page 1 of 1

 
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