Author Topic: Removing all affects on area enter.  (Read 337 times)

Legacy_Rio420

  • Full Member
  • ***
  • Posts: 112
  • Karma: +0/-0
Removing all affects on area enter.
« on: September 08, 2013, 04:09:07 pm »


               So I've been digging into our module code the last few days, for some odd reason, when you first enter our module you get hit with a movement affect that causes the players to move a little more slowly than I'd prefer them to.  Upon resting, those affects disappear and all is well.  My question is, what function call is it that removes those affects to begin with, I looked at how our rest system works, and I'm just not sure at this point.  Is there a global function that simply heals and removes all the affects or does this have to be singled out to remove the affect?
 
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Removing all affects on area enter.
« Reply #1 on: September 08, 2013, 06:08:56 pm »


               Magical effects (default for most effects) are removed by resting and dispelling
Extraordinary effects are removed by resting
Supernatural effects are not removed by resting

You can set the effect subtype by the functions
MagicalEffect() ExtraordinaryEffect() and SupernaturalEffect()
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Removing all affects on area enter.
« Reply #2 on: September 08, 2013, 07:13:42 pm »


               I'd be wary of changing things until you understand why they are the way they are to begin with - generally speaking. For all I know it's some esoteric HC rules thing. '<img'> You might want to run a search of the mod scripts for that effect type, to see if it's checked anywhere.

Funky
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Removing all affects on area enter.
« Reply #3 on: September 10, 2013, 02:06:10 am »


               AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_GREATER_RESTORATION, oPC, METAMAGIC_ANY, TRUE, 10, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
Where oCaster is the Module and oPC is the module enterer.  
Anyway you may want to think about it as FS indicated...It could be a fail safe mechanism to prevent people from logging in and out to avoid something. If that does not work you can follow the structure of while loop to remove that specific movement speed decrease effect.

 effect eBad = GetFirstEffect(oTarget);
   //Search for negative effects
   while(GetIsEffectValid(eBad))
   {
       if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
           GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
           GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
           GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
           GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
           {
               //Remove effect if it is negative.
               if(!GetIsSupernaturalCurse(eBad))
                   RemoveEffect(oTarget, eBad);
           }
       eBad = GetNextEffect(oTarget);
   }
So the above is part standard restoration spell you could write your own to remove any specific effect(s). To further illustrate the point.  Some boots of speed:

//boots of speed by ffbj
#include "x2_inc_switches"
void main()
{
 object oPC = GetPCItemLastEquippedBy();
 int nEvent = GetUserDefinedItemEventNumber();
 object oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
 int nItem = GetBaseItemType(oItem);
 if (nEvent == X2_ITEM_EVENT_EQUIP)
     {

   effect eEffect = EffectMovementSpeedIncrease(112 + d4(2));
   effect eEffect1 = EffectMovementSpeedIncrease(105 + d4(1));
     //change number to change speed
   effect eSpeed = SupernaturalEffect(eEffect);
   effect eSpeed1 = SupernaturalEffect(eEffect);
   if  ((nItem == BASE_ITEM_ARMOR) && (GetWeight(oItem) > 20))
     ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSpeed1, oPC);
    else
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSpeed, oPC);
     return;
      }

  else if (nEvent == X2_ITEM_EVENT_UNEQUIP)
     {
     object oPC = GetPCItemLastUnequippedBy();
     effect eSpeed = GetFirstEffect(oPC);
           // check fo this effect
            while (GetIsEffectValid(eSpeed))
              {
              if (GetEffectType(eSpeed) == EFFECT_TYPE_MOVEMENT_SPEED_INCREASE)
              RemoveEffect(oPC, eSpeed);
              eSpeed = GetNextEffect(oPC);
              }

      }


}
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Removing all affects on area enter.
« Reply #4 on: September 10, 2013, 07:45:27 pm »


               

ffbj wrote...

effect eEffect = EffectMovementSpeedIncrease(112 + d4(2));
   effect eEffect1 = EffectMovementSpeedIncrease(105 + d4(1));
     //change number to change speed
   effect eSpeed = SupernaturalEffect(eEffect);
   effect eSpeed1 = SupernaturalEffect(eEffect);


The EffectMovementSpeedIncrease() command is not a continuous function. Up to 99 it acts as a percentage for increasing the speed.  100 and above it acts as setting the speed to a percentage of the prior value.  That is 12 is the same improvement as 112 each adding 12% additional speed or multiplying your current speed by 112%.
               
               

               


                     Modifié par WhiZard, 10 septembre 2013 - 06:45 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Removing all affects on area enter.
« Reply #5 on: September 10, 2013, 10:14:11 pm »


               Ah, so essentially no effect writing it as I did since the 100% is already there.