Author Topic: Fixing AOE Spells  (Read 325 times)

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Fixing AOE Spells
« on: June 15, 2012, 01:23:12 am »


               Hi,

I know that the subject has been discussed quite often, but unfortunately most of the threads I found in the omnibus provided dead links pointing to the old forums, so thanks for your indulgence...

So, I know that caching the needed data on the AOE(at creation) is the preferred method, but I'm not too sure how to retrieve the AOE object after creation, in the impact script, mostly if, for instance, a player casts several AOE spells at the same location, so, would you wise guys accept to share a few tips? Thanks in advance!

Kato

   
               
               

               


                     Modifié par Kato_Yang, 15 juin 2012 - 12:38 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Fixing AOE Spells
« Reply #1 on: June 15, 2012, 01:40:25 am »


               *sigh* what you want to fix specifically? Except stacking (which isnt bug per see) everything AOE related was fixed in certain unofficial patch already.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Fixing AOE Spells
« Reply #2 on: June 15, 2012, 01:40:32 am »


               Their tags are given by vfx_persistent.2da A lot of people limit them to one Aoe of a type at a time to reduce load.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Fixing AOE Spells
« Reply #3 on: June 15, 2012, 01:54:25 am »


               @ShaDoOoW: Thanks for the info, if the fixes already exist I'll most likely use them, of course(I'm currently using the spell fix package you posted on the vault, thank you for this BTW!).

@ShadowM: Thanks for the info, I'll most likely limit the number too, indeed.


Kato
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Fixing AOE Spells
« Reply #4 on: June 15, 2012, 02:13:12 am »


               

Kato_Yang wrote...

@ShaDoOoW: Thanks for the info, if the fixes already exist I'll most likely use them, of course(I'm currently using the spell fix package you posted on the vault, thank you for this BTW!).

@ShadowM: Thanks for the info, I'll most likely limit the number too, indeed.


Kato

what I have fixed:
- AOE ResistSpell function bug - by re-scripting the function using default functions
- AOE heartbeat not firing on large modules - module switch to use delay based heartbeat
- mobile circle AOEs - the spell package from ILKAY and me contains an imperfect solution that still has bugs
- mobile circle AOEs stacking with itself - yes two casts of battletide will take away 10levels from enemy spellmantle
- creature aura AOEs were dispellable

this is done by using special struct engine, rewrite of all spells etc. all needed spell informations are stored on AOE object as I did provided a function to retrieve newly created AOE object in spellscript. To limit number of certain AOEs you should use spellhook.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Fixing AOE Spells
« Reply #5 on: June 15, 2012, 02:47:27 am »


               Very nice indeed, thanks again ShaDoOoW, I'm studying all this...

Kato
               
               

               


                     Modifié par Kato_Yang, 15 juin 2012 - 09:20 .
                     
                  


            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Fixing AOE Spells
« Reply #6 on: June 15, 2012, 10:20:16 pm »


               Well, after a closer look I must say for anyone interested that the spell fixes + the new spell engine in the patch are amazing, amazing!! (did I say amazing?)


Kato
               
               

               


                     Modifié par Kato_Yang, 15 juin 2012 - 09:26 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Fixing AOE Spells
« Reply #7 on: June 15, 2012, 10:35:25 pm »


               Oh one more note if you are implementing current release (1.71b5). The current system has a customized x2_inc_spellhook library which rely on the script 70_spellhook in which is implemented default content of the function X2_PreSpellCastCode. This is in order to allow modify this code (internal spellhook) without need to recompile all spellscripts (very usefull for example if you want NPCs to trigger spellhook as well).

However the 70_spellhook script is not packaged with other spellscripts in builder's resources (oversight), thus spells won't trigger spellhook neither they will allow crafting without this script.

(NOTE: for regular user that install the patch this is not an issue)

You can get the file by installing the patch and openening it in toolset or this is the source code:

//::///////////////////////////////////////////////
//:: Community Patch 1.71: Improve Spell Hook Include File
//:: 70_spellhook
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

   This file acts as a hub for all code that
   is hooked into the nwn spellscripts'

   If you want to implement material components
   into spells or add restrictions to certain
   spells, this is the place to do it.

*/
//:://////////////////////////////////////////////
//:: Created By: Shadooow
//:: Created On: 2012-01-17
//:://////////////////////////////////////////////

#include "x2_inc_spellhook"

//------------------------------------------------------------------------------
// if X2_EXECUTE_SCRIPT_END is set by this script, the original spell will not be cast
// the order in which the functions are called here DOES MATTER, changing it
// WILL break the crafting subsystems
//------------------------------------------------------------------------------
void main()
{
  object oTarget = GetSpellTargetObject();
  object oItem = GetSpellCastItem();

  if(oItem != OBJECT_INVALID)
  {
      int spellOverride = GetLocalInt(oItem,"ITEM_SPELL_OVERRIDE");
      if(spellOverride != 0 && !GetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED"))
      {
          SetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED",TRUE);
          ExecuteScript(Get2DAString("spells","ImpactScript",spellOverride < 0 ? 0 : spellOverride),OBJECT_SELF);
          SetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED",FALSE);
          SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
          return;
      }
  }

  //---------------------------------------------------------------------------
  // This small addition will check to see if the target is mounted and the
  // spell is therefor one that should not be permitted.
  //---------------------------------------------------------------------------
  if(!GetLocalInt(GetModule(),"X3_NO_SHAPESHIFT_SPELL_CHECK"))
  { // do check for abort due to being mounted check
      switch(GetPhenoType(oTarget))
      {// shape shifting not allowed while mounted
      case 3:
      case 5:
      case 6:
      case 8:
       if(X3ShapeShiftSpell(oTarget))
       {
          if(GetIsPC(oTarget))
          {
          FloatingTextStrRefOnCreature(111982,oTarget,FALSE);
          }
       SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
       return;
       }// shape shifting not allowed while mounted
      break;
      }
  } // do check for abort due to being mounted check


  //---------------------------------------------------------------------------
  // This stuff is only interesting for player characters we assume that use
  // magic device always works and NPCs don't use the crafting feats or
  // sequencers anyway. Thus, any NON PC spellcaster always exits this script
  // with TRUE (unless they are DM possessed or in the Wild Magic Area in
  // Chapter 2 of Hordes of the Underdark.
  //---------------------------------------------------------------------------
  if (!GetIsPC(OBJECT_SELF))
  {
      if( !GetIsDMPossessed(OBJECT_SELF) && !GetLocalInt(GetArea(OBJECT_SELF), "X2_L_WILD_MAGIC"))
      {
           return;
      }
  }

  //---------------------------------------------------------------------------
  // Break any spell require maintaining concentration (only black blade of
  // disaster)
  // /*REM*/ X2BreakConcentrationSpells();
  //---------------------------------------------------------------------------

  //---------------------------------------------------------------------------
  // Run use magic device skill check
  //---------------------------------------------------------------------------
  int nContinue = X2UseMagicDeviceCheck();

  if (nContinue)
  {
      //-----------------------------------------------------------------------
      // run any user defined spellscript here
      //-----------------------------------------------------------------------
      nContinue = X2RunUserDefinedSpellScript();
  }

  //---------------------------------------------------------------------------
  // The following code is only of interest if an item was targeted
  //---------------------------------------------------------------------------
  if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_ITEM)
  {
      //-----------------------------------------------------------------------
      // Check if spell was used to trigger item creation feat
      //-----------------------------------------------------------------------
      if (nContinue)
      {
          nContinue = !ExecuteScriptAndReturnInt("x2_pc_craft",OBJECT_SELF);
      }

      //-----------------------------------------------------------------------
      // Check if spell was used for on a sequencer item
      //-----------------------------------------------------------------------
      if (nContinue)
      {
          nContinue = !X2GetSpellCastOnSequencerItem(oTarget);
      }

      //-----------------------------------------------------------------------
      // * Execute item OnSpellCast At routing script if activated
      //-----------------------------------------------------------------------
      if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS))
      {
          SetUserDefinedItemEventNumber(X2_ITEM_EVENT_SPELLCAST_AT);
          int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oTarget),OBJECT_SELF);
          if (nRet == X2_EXECUTE_SCRIPT_END)
          {
              SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
              return;
          }
      }

      //-----------------------------------------------------------------------
      // Prevent any spell that has no special coding to handle targetting of items
      // from being cast on items. We do this because we can not predict how
      // all the hundreds spells in NWN will react when cast on items
      //-----------------------------------------------------------------------
      if (nContinue)
      {
          nContinue = X2CastOnItemWasAllowed(oTarget);
      }
  }

  SetExecutedScriptReturnValue(!nContinue);
}


               
               

               


                     Modifié par ShaDoOoW, 15 juin 2012 - 09:38 .
                     
                  


            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Fixing AOE Spells
« Reply #8 on: June 15, 2012, 10:49:29 pm »


               Excellent, tyvm ShaDoOoW! '<img'>

Kato