Author Topic: "Reduce speed HASTE" Scripting  (Read 1597 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« on: January 23, 2014, 12:53:29 am »


               Haste is really too fast to our .mod, it's necessary reduce your speed. We are thinking to make it slow using NWNX or scripting maybe using a penalty speed on haste.

if anyone can help i'll be grateful. 
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #1 on: January 23, 2014, 03:04:48 pm »


               Is it just haste or movement speed in general that is too fast?

If it is movement speed in general, you can decrease the values in creaturespeed.2da.

If the problem is haste, and you aren't using perma-haste gear you can add on a movement speed penalty to the abilities that produce it.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #2 on: January 24, 2014, 12:35:52 am »


               In the general, haste itens is too fast. I want to reduce especially the itens speed.




I found it:

--------------------------------------------------------------------------------------
Message by Squatting Monk -

You can reduce the movement speed with EffectMovementSpeedDecrease().

Add this right under line 59 of nw_s0_haste:
Code:
   // Slow it down a bit
   eHaste = EffectLinkEffects(EffectMovementSpeedDecrease(30), eHaste);


Replace 30 with a smaller value if that slows it down too much.

Note: this will not help with hasted items, only the spell.
----------------------------------------------------------------------------------------------
               
               

               


                     Modifié par sandronejm, 26 janvier 2014 - 01:54 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #3 on: January 24, 2014, 12:45:51 am »


               A non-NWNX way to fix haste speed on items would be to modify your OnPlayer(Un)EquipItem scripts to look for haste properties on any equipped items and apply/remove a movement penalty there.
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #4 on: January 24, 2014, 12:47:09 am »


               We need do it for all itens hasted?
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #5 on: January 24, 2014, 01:23:35 am »


               You don't need a script for each individual item. Rather, you need something like the following in your OnPlayerEquipItem script (disclaimer: I'm doing this in a text editor since I'm at work and cannot guarantee it will compile):

   object oItem = GetPCItemLastEquipped();

    // If the equipped item has the Haste property...
    if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_HASTE))
    {
        object oPC = GetPCItemLastEquippedBy();
        int nItems = GetLocalInt(oPC, "HastedItems");
   
        // Slow him if he hasn't been slowed by another hasted item.
        if (!nItems)
        {
            effect eSlow = EffectMovementSpeedDecrease(30);
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSlow, oPC);
        }
   
        // Increment a counter for hasted items in case the PC has more than one
        SetLocalInt(oPC, "HastedItems", nItems + 1);
    }

...and something like this in your OnPlayerUnEquipItem script:

    object oItem = GetPCItemLastUnequipped();

    // If the unequipped item has the Haste property...
    if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_HASTE))
    {
        object oPC = GetPCItemLastUnequippedBy();
        int nItems = GetLocalInt(oPC, "HastedItems");
   
        // Remove the slow effect if he has no more hasted items.
        if (nItems == 1)
        {
            object oCreator = GetModule();
            effect eEffect = GetFirstEffect(oPC);
      
            while (GetIsEffectValid(eEffect))
            {
                if (GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE &&
                    GetEffectCreator(eEffect) == oCreator) // Don't remove slow effects from other sources
                    RemoveEffect(oPC, eEffect);
         
                eEffect = GetNextEffect(oPC);
            }
        }
   
        // Decrement a counter for hasted items in case the PC has more than one
        SetLocalInt(oPC, "HastedItems", nItems - 1);
    }

Note: I'm not sure if equipped items that are destroyed with DestroyObject() are still valid when the OnPlayerUnequipItem event is fired. If not, you'd need to loop through all currently equipped items to see if a now-invalid item had the Haste property.
               
               

               


                     Modifié par Squatting Monk, 24 janvier 2014 - 02:54 .
                     
                  


            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #6 on: January 24, 2014, 02:24:10 am »


               I'll test. Thanks

The ON_PLAYER_EQUIP has compiled with sucess but the

on_player_UNEQUIP don't compile (looks 8 line wrong)
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #7 on: January 24, 2014, 02:54:49 am »


               Ah. Yeah, the line that reads:

object oPC = GetPCItemLastUnquippedBy();

...should read:

object oPC = GetPCItemLastUnequippedBy();

               
               

               


                     Modifié par Squatting Monk, 24 janvier 2014 - 02:55 .
                     
                  


            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #8 on: January 24, 2014, 03:06:58 am »


               It's works. Thanks
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #9 on: January 24, 2014, 04:23:14 am »


               For OnEquip replace

effect eSlow = EffectMovementSpeedDecrease(30);

with

effect eSlow = EffectMovmentSpeedIncrease(-30);

and for OnUnEquip replace

if (GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE && GetEffectCreator(eEffect) == oCreator)

with

if (GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_INCREASE && GetEffectCreator(eEffect) == oCreator)


Can't have those with freedom getting an unnecessary advantage can we?
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #10 on: January 24, 2014, 05:19:09 am »


               Congratulations, WhiZard. You think for us. haha.

I spent some time testing the system and it's work fine. It's only works on equip. When player login with item already equiped the penalty speed isn't as we programmed ):
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #11 on: January 24, 2014, 04:35:35 pm »


               WhiZard,
The code effect eSlow = EffectMovmentSpeedIncrease(-30); won't compile. You need replace Movment to Movement.

1. Rogues hide/unhide cancel the speed decrease.
2. Login in the game cancell the speed decrease.
3. I'm not sure but rest cancel the speed decrease.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #12 on: January 24, 2014, 05:10:59 pm »


               You'll need to make the effect Supernatural to avoid it being removed by resting.  Or you can simply reapply it when someone cancels or finished a rest.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #13 on: January 24, 2014, 06:28:23 pm »


               1.  Hiding should not cancel the decrease.  The icon may disappear (because removing an effect triggers the removal of associated icons from the display) but the effect is there and the character sheet should show it.

2.  Login may have the same issue as 1).  Check to see if you are just missing the icon or the effect itself.

3. As MM described an effect needs to be supernatural to not be removed on rest.

Additionally there may be issues with dying and resurrection (so that a character, if resurrected with the haste item already equipped, will not incur a penalty).  The number of scripts needed to get the behavior for the haste item property to work is significant, which may be a reason to stay away from perma-haste items.
               
               

               


                     Modifié par WhiZard, 24 janvier 2014 - 06:42 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
"Reduce speed HASTE" Scripting
« Reply #14 on: January 24, 2014, 07:09:35 pm »


               If you just fire a similar segment of code for the OnRespawn, Raise Dead, and Resurrection scripts that should fix the death issues removing the buffs.