Author Topic: Custom feat and GetHasFeatEffect  (Read 714 times)

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« on: June 14, 2011, 10:32:35 am »


               Hi everyone,

Do anyone know if there is a way to apply an effect as a "Feat effect" from a script, in order to find it with GetHasFeatEffect routine instead of finding it by looping on all effects active on the character ?

I want to add the feat "Strong grip" which raise the bonus damage when using a warhammer from 1.0 * Strength modifier to 1.5 * Strength Modifier (one hand) and from 1.5 to 2.0 (two hand).
I use a heartbeat script which add/remove a bonus damage corresponding to 0.5 * Strength modifier to the character. I want to avoid the loop on effects '<img'>

If anyone have any idea to do it another way, I will be glad to hear it '<img'>

Thank you !
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #1 on: June 14, 2011, 12:27:16 pm »


                 I would apply it in the OnEquip script, and just do a GetHasFeat check instead of checking for a feat effect.  The damage bonus would then need to be removed in the OnUnequip, but the check would only need to run once then instead of every heartbeat.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #2 on: June 14, 2011, 12:44:22 pm »


               The info about gethasfeateffect on nwn lexicon neither I know for sure how i works.

So maybe it works for standard feats like knockdown though lately Im dont trust lexicon without testing, but as far as custom feats I think this function returns true only if the feat triggers spell and the spell has correct FeatID setup in the 2da and the spell applies some effects. But it definitely cannot return TRUE for things like custom efffect in OnEquip that is related to feat (like Two-Weapon defense). Thats not possible, cos engine cannot know that the stuff you are doing there is related to your custom feat.

But havent proofed the spell effect part so actually Im not using it, cos if the feat triggers spell then you can simply use GetHasSpellEffect, no need for FeatEffect.

Therefore if you are applying effects like AB,extraattack,speedincrease,see invisibility in OnEquip etc. and then you need to remove them, the only way to safely do this is to use special effect creator, that is unique placeable object in module that you assign to apply the effect. Good practise is to name these objects via effects you are applying like EC_UNARMEDDAMAGE etc.

If you want code sample, just say.
               
               

               
            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #3 on: June 14, 2011, 01:08:23 pm »


               Yep ShaDoOoW, I would rather SpellEffect than FeatEffect too. This idea about item creator is good. I was using GetModule() as creator but I will run in problem soon, when some of my module script will add effect, it could cause some conflicts with my class effect.
And yeah, I can use some samples, thank you !

Failed.Bard, only applying it on OnEquip will not work cause when you cast a spell that increase Strength, the script will not be called, and the bonus damage will not be updated. That's why I'm using a heartbeat script.

Also, I'm glad to see that the NWN1 community is still active '<img'> All of you are great '<img'>
               
               

               


                     Modifié par Aerendil, 14 juin 2011 - 01:59 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #4 on: June 14, 2011, 04:51:05 pm »


               We used the effect creator method for years - it's a solid suggestion, and I'll leave it to Shad to post code, unless he wants me to save him the trouble.

The method we use now uses nwnx and nwnx_structs for linux only. It has a SetEffectID function that allows you to tag an effect with whatever spell ID you like - meaning you can designate custom effect numbers, and check for them. I highly recommend this approach if you're running linux.

Funky
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #5 on: June 14, 2011, 10:19:47 pm »


               sample:

have this snippet in OnEnter/OnLevelUp/OnRespawn and OnLevelDown (special scripted event i created via hooking SetXP calls) (actually all these events run this via ExecuteScript):

void main()
{
object oPC = OBJECT_SELF;
/*string sPlayerId = GetPlayerId(oPC); <- this doesnt interest you
object oSkin = GetPCSkin(oPC);
itemproperty ip = GetFirstItemProperty(oSkin);
  while(GetIsItemPropertyValid(ip))
  {
  RemoveItemProperty(oSkin,ip);
  ip = GetNextItemProperty(oSkin);
  }*/
//this will remove all effects first
effect e = GetFirstEffect(oPC);
string sTag;
 while(GetIsEffectValid(e))
 {
 sTag = GetTag(GetEffectCreator(e)) ;
  if(sTag == "EC_UNARMED_MEPH" || sTag == "EC_AB" || sTag == "EC_NINJA")
  {
  RemoveEffect(oPC,e);
  }
 e = GetNextEffect(oPC);
 }
 //now re-apply them
 if(GetHasFeat(FEAT_NINJA_GHOST_SIGHT,oPC))
 {
 AssignCommand(GetObjectByTag("EC_NINJA"), ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectSeeInvisible()), oPC));
 }
...and so on
}


or this, this is special event-based scripting, its for the Ring of lesser regeneration, the actual regen is +1/3rounds its for lvl 1-4 characters.

#include "_sh_inc_newfce"

void main()
{
object oPC, oItem;
int nEvent = GetRunningEvent();
 if(nEvent == EVENT_MODULE_ON_PLAYER_EQUIP_ITEM)
 {
 oPC = GetPCItemLastEquippedBy();
 AddEventScript(oPC,EVENT_SCRIPTED_ON_PLAYER_RESSURECTED,"sh_uniq_rregen1");
 AssignCommand(GetObjectByTag("EC_sh_uniq_rregen1"), CORE_ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectRegenerate(1, 18.0)), oPC));
 }
 else if(nEvent == EVENT_MODULE_ON_PLAYER_UNEQUIP_ITEM_STARTED)
 {
 oPC = GetPCItemLastUnequippedBy();
 RemoveEventScript(oPC,EVENT_SCRIPTED_ON_PLAYER_RESSURECTED,"sh_uniq_rregen1");
 effect e = GetFirstEffect(oPC);
  while(GetIsEffectValid(e))
  {
   if(GetTag(GetEffectCreator(e)) == "EC_sh_uniq_rregen1")
   {
   RemoveEffect(oPC,e);
   }
  e = GetNextEffect(oPC);
  }
 }
 else if(nEvent == EVENT_SCRIPTED_ON_PLAYER_RESSURECTED)
 {
 object oPC = OBJECT_SELF;
  if(GetModule() == oPC)
  {
  oPC = GetLastRespawnButtonPresser();
  }
  if(GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC)) == "sh_uniq_rregen1" ||
  GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC)) == "sh_uniq_rregen1"
  )
  {
  AssignCommand(GetObjectByTag("EC_sh_uniq_rregen1"), CORE_ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectRegenerate(1, 18.0)), oPC));
  }
 }
}


               
               

               


                     Modifié par ShaDoOoW, 14 juin 2011 - 09:23 .
                     
                  


            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #6 on: June 14, 2011, 11:14:11 pm »


               Thank you FunkySwerve and Shad, I'll have a look and use this. For NWNX, do I need linux client ? If this is only server-side stuff, I'll check (I think it's only server-side, but never verified nor tried it '<img'> )
Anyway, thank you for your help '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #7 on: June 15, 2011, 03:23:22 am »


               NWNX is completely serverside, and offers a huge number of addidtional script functions, database connectivity, crash prevention, automated resetting, and much much more. Here's the website - don't miss the forums.
Click Me

Funky
               
               

               
            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #8 on: June 15, 2011, 07:51:17 am »


               Thank you FunkySwerve ! I think I'll fetch and build from svn source because I'm quite lost with links and versions '<img'>
Oh, and I have another question for NWNX, if it give access to script functions, how do you compile scripts / mod on Linux without Aurora Toolset ?
               
               

               


                     Modifié par Aerendil, 15 juin 2011 - 06:59 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #9 on: June 15, 2011, 11:44:00 am »


               it possible to run toolset on linux, for example think ubuntu 10 can run it via wine

anyway there is a external command line compiler, default one is in nwn/utils, improved one is here: http://nwvault.ign.c...r.detail&id=708
               
               

               
            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #10 on: June 15, 2011, 12:00:54 pm »


               Ok, so all I have to do is script outside of the toolset, compile it with cli compiler on linux and importing in the module as erf or hak ?
And I will just upload the mod and related files to linux server and start it with nwnx '<img'>

Is this correct ?

Edit: Sorry, I understand now, NWScript functions are available via .nss file and hook on SetLocalString/GetLocalString. I just have to inc .nss file which contains nwnx_funcs / nwnx_functions and compile like that. And of course, this script will only work on my linux server with nwnx installed but it will not prevent my module to compile/start.

Thank you for your help =) I'll try all this amazing things right now !
               
               

               


                     Modifié par Aerendil, 15 juin 2011 - 11:46 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #11 on: June 15, 2011, 03:35:48 pm »


               Your edit is all correct. I still recommend using the PRC compiler, ,which is superior in every way to the bioware compiler. If you want to be able to run a test server using linux on your windows box, NWNIAB (NWN in a box) will allow you to do so:

http://highergroundp...gi?board=nwniab

Funky
               
               

               
            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #12 on: June 17, 2011, 12:21:40 pm »


               I'll just use this thread for two questions : I want to create feat like Stun Fist. So I'm facing two problems :
 - First, how can I force the character to do a melee attack and apply effect of my feat ? I was thinking to use a spell (say spell1) that will add a OnHitSpell (spell2) item property on the weapon and remove the OnHitSpell after a while or after the first melee attack.
But if the character miss I'll have no chance to know it and It will be impossible to remove the item property. Any other idea ?

- Second, many of my feat force the character to have a War Hammer in his right hand to use them. Currently, I'm using two spells one without any visual effect that test the weapon and CastSpellAtObject or Location the second spell with visual effect (projectile) and which apply damage and magic effect.

Thank you for your help '<img'>

PS: If you're interested in, I'm re-creating the Moradin's Hammer class from D&D 3.5. (http://www.gemmaline...audemoradin.htm)
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #13 on: June 17, 2011, 01:20:57 pm »


               Quote from my post in ActionUseFeat... topic

Its not possible to make a new combat feat which will work just the same as default one does. Neither via public nwnx plugins afaik. And all workarounds are ugly for this and I would never recomended them.

So the question is why you are doing fake kd? What do you want to change on default KD? The public nwnx plugins can detect kd attempt and block it so that could be the solution?

and the Stun Fist is the same case.
               
               

               
            

Legacy_Aerendil

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Custom feat and GetHasFeatEffect
« Reply #14 on: June 18, 2011, 02:01:01 pm »


               Ok, so I'll have to do as I said before '<img'> Thank you for this information !