Author Topic: Tag Based Grenade Script  (Read 589 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #15 on: November 27, 2012, 03:45:45 pm »


                Here is what I ended up doing:

I added a line to spells.2da for a default grenade
867   Grenade_Spell   16777554   is_X1Grenade   T   M   s   ****   0x3e   x2_s3_bomb   ****   ****   ****   ****   ****   ****   3   1500   hand   ****   ****   ****   ****   ****   ****   up   1000   ****   ****   ****   ****   1   it_potion_000   bounce   hand   spr_los   path   ****   0   ****   ****   ****   ****   ****   2   ****   4   ****   0   0   2732   1   ****   ****   ****   1   

I then created a few lines in iprp_spells.2da so that a builder could set the caster level for the spell grenade
548   Grenade_Spell   16777554   3   3   300   867   1   01   1   iss_X1Grenade
549   Grenade_Spell   16777555   5   3   500   867   1   01   1   iss_X1Grenade
550   Grenade_Spell   16777556   7   3   700   867   1   01   1   iss_X1Grenade
551   Grenade_Spell   16777557   9   3   900   867   1   01   1   iss_X1Grenade
552   Grenade_Spell   16777558   11   3   1100   867   1   01   1   iss_X1Grenade   

Then I edited x2_s3_bomb to first read the spellid that ran the script, and if it is my "Grenade_Spell" Spell I check the item tag and respond accordingly.
               
               

               


                     Modifié par henesua, 27 novembre 2012 - 03:46 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #16 on: November 27, 2012, 04:17:17 pm »


               isnt adding additional lines into iprp_spell needless? you can increase the cost via various item cost increase properties (CEP, HR, CP...) and you can set CL into integer variable on the grenade item in question. Grenades are not intented to penetrate spell resistence or anything that would be tied with CL so that shouldnt be problem.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #17 on: November 27, 2012, 04:43:39 pm »


               local variables get lost on stacked items.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #18 on: November 27, 2012, 04:52:14 pm »


               

henesua wrote...

local variables get lost on stacked items.

thats true but you dont want to stack different types of grenades together right?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #19 on: November 27, 2012, 05:01:37 pm »


               I just didn't want to run into that pitfall later. Including those item properties made it safer.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #20 on: November 27, 2012, 05:17:32 pm »


               

henesua wrote...

I just didn't want to run into that pitfall later. Including those item properties made it safer.

hmm not really actually, stacking by default ignores differences between itemproperties: read this if you havent
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #21 on: November 27, 2012, 05:25:23 pm »


               Ah... interesting.

Solution then is to insert caster level as a suffix on the tag. That should do the trick.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #22 on: November 27, 2012, 10:02:53 pm »


               

henesua wrote...

Ah... interesting.

Solution then is to insert caster level as a suffix on the tag. That should do the trick.


While you're at it you can script the tag to consider an unlimited number of variations.

E.g.
#include "x0_i0_spells"
void main()
{
    int nVFX1, nVFX2, nDamType, nDamage;
    effect eAOE;
    object oGrenade = GetSpellCastItem();
    if(!GetIsObjectValid(oGrenade)) return;
    string sTag = GetTag(GetSpellCastItem());
    nDamage = StringToInt(GetStringRight(sTag, 2));
    sTag = GetStringLeft(sTag, GetStringLength(sTag) -2);
    if(sTag == "bombfire")
      {
      nVFX1 = VFX_IMP_FLAME_M;
      nVFX2 = VFX_FNF_FIREBALL;
      nDamType = DAMAGE_TYPE_FIRE;
      eAOE = EffectAreaOfEffect(AOE_PER_FOGFIRE);
      }
    else if(sTag == "bombacid")
     {
     nVFX1 = VFX_IMP_ACID_L;
     nVFX2 = VFX_FNF_LOS_NORMAL_30;
     nDamType = DAMAGE_TYPE_ACID;
     eAOE= EffectAreaOfEffect(AOE_PER_FOGACID);
     }
    else if(sTag == "bombsonic")
     {
     //Define other values here
     }
    DoGrenade(d6(nDamage), nDamage, nVFX1, nVFX2, nDamType, RADIUS_SIZE_HUGE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAOE, GetSpellTargetLocation(), RoundsToSeconds(5));
    }
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Tag Based Grenade Script
« Reply #23 on: November 27, 2012, 10:10:55 pm »


               definitely. already done.