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 
 
CounterSpell hook?

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



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Dec 18, 2014 0:58    Post subject: CounterSpell hook? Reply with quote

Anyone have a working counterSpell hook?

Eg: When a counterspell is being attempted
return the
Countering Mage
Target Mage
and ideally the spells being used
1. The spell being countered
2. The spell being used to counter with


I am currently working on a hook using ValidateCounterSpellData as a starting point.
Getting crashes though
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Dec 18, 2014 1:23    Post subject: Reply with quote

Think I might be making progress:


Code:

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);
}


Target (the nwnobjid) - seems to be the spell that you are countering with.
By modifying my onSpellCast hook to take note of the last cast spell - I am then able to pass that information to the counterspell hook - to pass it to nwnscript.

Testing it now
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Dec 18, 2014 1:44    Post subject: Reply with quote

Yup its working:
Feel free to use the hook anyone who is interested.


Using the hook you can make unlimited spell countering.

Eg: Restore spells that are consumed by countering.
I only needed it for my God Subrace - it seemed odd that they had unlimited spells, but those spells could be drained by countering.
No more though
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows 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