Any ideas for slowing PC speed? (SOLVED)

Hello,

I am trying to slow the PC for more realistic underwater walk, and after testing a lot, i got the feeling that EffectMovementSpeedDecrease() does not work for PCs. This effect works great on monsters/NPC or on polymorphed/possessed but no way to make it work with the standard central character. Does anybody know of something that could do ?

So far, some of my imperfect ideas:

  • put an heavy item on the player’s inventory or reduce strength.
  • fake it by creating a PC clone, hiding the original PC and slowing the clone for the walk.

But, ideally i would like something with no mood-breaking messages or weird status icons.

Thanks

CG

The effect does work. For example, in Dark Energy, at one point the player has to wade through wasp-infested treacle. The on-off code for this is

      if (GetLocalInt(oArea, "Treacle") != GetLocalInt(oTrigger, "Treacle"))
         {
           if (GetLocalInt(oTrigger, "Treacle"))
             {
               SetLocalInt(oArea, "Treacle", TRUE);
               FloatingTextStringOnCreature("Yuk! Thick sticky treacle!", oPC);
               ApplyEffectToObject(PERMANENT, EffectMovementSpeedDecrease(99), oPC);
             }
           else
             {
               DeleteLocalInt(oArea, "Treacle");
               RemoveSpecificEffect(EFFECT_TYPE_MOVEMENT_SPEED_DECREASE, oPC);
             }
         }

On reflection, it ought to be applied as a Supernatural effect so that it can’t be cancelled by rest.

1 Like

I like Proleric’s way since I’m a fan of max work in nwscript, but If you’re all NWNXy, you can use NWNX_Creature_SetMovementRate(). You could even go so far as to add a different movement speed into the 2da and change the PC’s appearance to match the speed, but that can be a bit mood breaking with the potential appearance issues.

1 Like

I’m sure Proleric’s script works, but if it somehow don’t work I downloaded a prefabarea, a swamp, a week ago (though it was for NWN2) and it had two scripts: one that when entering an area slowed down the PC and the party, and when exiting the area another was run with a reset (There’s a survival check in the script that one can take out if you don’t want it). They look like this, and I’m pretty sure they will work for NWN1 also, since scripting is fairly similar between the two games:

The OnEnter script:

//OnEnter Script
// SGK 2007/08/05
//
// Based on a script found on the forum.
// Use with the trigger "Movement Modifier" to set the variables
// make sure that the "iEffectID" is *UNIQUE* to every trigger
// there are some issues with overlapping triggers and the decreased movement icon

void main()
{
	object oPC = GetEnteringObject();
	int iMod = GetLocalInt(OBJECT_SELF, "iModifier");
	int iEffectID = GetLocalInt(OBJECT_SELF, "iEffectID");

	//remove survival ranks from modifier
	int iSurvival = GetSkillRank(SKILL_SURVIVAL,oPC);
	//check if survival skill is usable
	if (iSurvival == -1)
		{
			iSurvival = -10; // penalty for not having skill
		}
	if (iSurvival == 0)
		{
			iSurvival = -5; // penalty for skill not trained
		}
				
	// apply modifier to movement decrease
	iMod = iMod + iSurvival * 2;
	// check if negative or above 95
	if (iMod < 0)
		{
			iMod = 0;
		}
	if (iMod > 95)
		{
			iMod = 95;
		}
	//apply movement effect

	effect eEffect = EffectMovementSpeedDecrease(iMod);

	if (GetIsObjectValid(oPC))
  		{
   			ApplyEffectToObject(DURATION_TYPE_PERMANENT, SetEffectSpellId(eEffect,iEffectID), oPC);
		}
}

The OnExit script:

//OnExit
// SGK 2007/08/05
//
// Based on a script found on the forum.
//
void main()
{
	object oPC = GetEnteringObject();
	int iEffectID = GetLocalInt(OBJECT_SELF, "iEffectID");
	 if (GetIsObjectValid(oPC))
		{
			effect eCurrent = GetFirstEffect(oPC);
		  	while (GetIsEffectValid(eCurrent))
				{
				    if (GetEffectSpellId(eCurrent)==iEffectID)
						{
			      			RemoveEffect(oPC, eCurrent);
		      				return;
		    			}
					eCurrent = GetNextEffect(oPC);
		  		}
		}
}
1 Like

Thanks for your replys @Proleric, @tinygiant, @andgalf. More or less, i was doing what you suggested. But, knowing with your help that the script was valid, pointed me in the right direction.

It was my test PC, that somehow, was corrupted (yes, they were some game crashes prior to the problem, but nothing blatantly weird appeared, so i continued testing like before) ! Problem completely vanished using other PC characters. Works now ! :smile:

CG

1 Like

(this post contains product placement)

Hi, there’s yet another approach that avoids effects and is 100% reliable.

You can use LRA and add ItemPropertySpecialWalk to PC’s creature’s hide to prevent it from running. No icons and easy to toggle on/off.

LRA overrides the silly vanilla walkdead animation (zombie walk) with default walking animation, allowing exactly what is written above.