Skip to content

Jump Item with Animation

I am having trouble getting an item to work. I created a Jump widget based on the CRAP jump. I don't want to use the trigger just simple jump option. I have the custom animation in my hak and have taken all the options I can find from the CRAP scripts so I don't need an include right now. This is what I got,


#include "x0_i0_position"
int nCnt =1;
float fDir = GetFacing(OBJECT_SELF);

const float JUMP_ANIM_DISTANCE_SCALAR = 6.3; // orig = 3.974

void Jump(object oPlayer);

// Returns TRUE if oCreature is encumbered.
// If oCreature is not a creature, it will be considered encumbered if it has weight.
// Uses a .2da lookup. Avoid calling this in loops.
int GetIsEncumbered(object oCreature);
int GetIsEncumbered(object oCreature)
{
int nStrength = GetAbilityScore(oCreature, ABILITY_STRENGTH);
int nLimit = StringToInt(Get2DAString("encumbrance", "Normal", nStrength));

return GetWeight(oCreature) > nLimit;
}
float GetAppearanceModifierFromABAScaling(object oPC)
{
int iRacialType = GetRacialType(oPC);

if (GetGender(oPC) == GENDER_MALE)
{
if(iRacialType == IP_CONST_RACIALTYPE_HUMAN)
return 1.0;
else if(iRacialType == IP_CONST_RACIALTYPE_HALFLING)
return 0.65;
else if(iRacialType == IP_CONST_RACIALTYPE_ELF)
return 0.895;
else if(iRacialType == IP_CONST_RACIALTYPE_DWARF)
return 0.68;
else if(iRacialType == IP_CONST_RACIALTYPE_GNOME)
return 0.63;
else return 1.03;
}
else
{
if(iRacialType == IP_CONST_RACIALTYPE_HUMAN)
return 0.988;
else if(iRacialType == IP_CONST_RACIALTYPE_HALFLING)
return 0.632;
else if(iRacialType == IP_CONST_RACIALTYPE_ELF)
return 0.883;
else if(iRacialType == IP_CONST_RACIALTYPE_DWARF)
return 0.648;
else if(iRacialType == IP_CONST_RACIALTYPE_GNOME)
return 0.63;
else return 0.997;
}
}
void AddnAnimWrapper(int iAnimIndex, float fAnimSpeed, float fAnimDuration)
{
DelayCommand(0.1, ClearAllActions());
DelayCommand(0.15, ActionPlayAnimation(iAnimIndex, fAnimSpeed, fAnimDuration));
return;
}
void main()
{
object oPlayer = GetItemActivator();
object oItem = GetItemActivated();
string sTag = GetTag(oItem);
location lPawStart = GetLocalLocation(oPlayer, "PAW_LOC");
location lCurrent = GetLocation(oPlayer);
float fDif = GetDistanceBetweenLocations(lPawStart, lCurrent);

if(GetIsEncumbered(oPlayer))
{
FloatingTextStringOnCreature("You are too encumbered to jump", oPlayer);
return;
}
if(fDif < 0.0f || fDif > 0.9f)
{
FloatingTextStringOnCreature("Position has changed: That action is no longer valid", oPlayer);
return;
}
float fPawFacing = GetLocalFloat(OBJECT_SELF, "PAW_FACING");
if((fPawFacing + 3.0f < fDir) || (fPawFacing - 3.0f > fDir))
{
FloatingTextStringOnCreature("Facing has changed: That action is no longer valid", oPlayer);
return;
}
DelayCommand(0.3, Jump(oPlayer));
}
void crp_PlayAnimation(int nAnim)
{
float fSpeed, fDur;
ActionPlayAnimation(ANIMATION_LOOPING_CUSTOM5, 2.5, 2.3);
}
void Jump(object oPlayer)
{

float fAppearanceModifier = GetAppearanceModifierFromABAScaling(oPlayer);
float fJumpLength = JUMP_ANIM_DISTANCE_SCALAR * fAppearanceModifier;
float fAngleOpposite = GetOppositeDirection(fDir);

location lJumpTo = GenerateNewLocation(oPlayer,
fJumpLength,
fDir,
fDir);

location lRunning = GenerateNewLocation(oPlayer,
DISTANCE_TINY,
fAngleOpposite,
fDir);

vector vCurrent = GetPositionFromLocation(GetLocation(oPlayer));
vector vToJump = GetPositionFromLocation(lJumpTo);
vector vRunning = GetPositionFromLocation(lRunning);

if (!LineOfSightVector(vCurrent, vToJump)) // Can't jump where you can't see
{
PlayVoiceChat(VOICE_CHAT_CANTDO, oPlayer);
SendMessageToPC(oPlayer, "Jump would carry character into a wall or other invalid area.");
return;
}
if(!LineOfSightVector(vCurrent, vRunning)) // Need distance to run
{
PlayVoiceChat(VOICE_CHAT_CANTDO, oPlayer);
SendMessageToPC(oPlayer, "Need space behind character to gather speed for a jump!");
return;
}
effect effTouchupInvis = EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY);
float fDis = GetDistanceBetween(OBJECT_SELF, GetNearestObject(OBJECT_TYPE_CREATURE));
if(fDis != 0.0f && fDis < 2.0)
PlayVoiceChat(VOICE_CHAT_MOVEOVER);

SetFootstepType(FOOTSTEP_TYPE_NONE, oPlayer);
DelayCommand(0.3, SetCommandable(FALSE, oPlayer));
crp_PlayAnimation(ANIMATION_LOOPING_CUSTOM5);
DelayCommand(2.63, SetCommandable(TRUE, oPlayer));
DelayCommand(2.65, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, effTouchupInvis, oPlayer, 0.90));
DelayCommand(2.70, AssignCommand(oPlayer, ClearAllActions()));
DelayCommand(2.80, ActionJumpToLocation(lJumpTo));
DelayCommand(3.25, SetFootstepType(FOOTSTEP_TYPE_DEFAULT, oPlayer));
}

Maybe its the target location but I am not sure it seems to move the PC up to jump but never happens. Can anyone help me out?

Comments

  • LordLestatLordLestat Member Posts: 17
    I have tried everything I can think of but no luck. I found on the vault an upload that does it from a feat but it doesn't move the actual players location. They do the jump but just return to their original location.

    This would be used in a number of places like in some caves where areas are unaccessable by walking or across streams or other tileset obstructions.
  • LordLestatLordLestat Member Posts: 17
    I got it basically working. Thanks for the help folks.
  • LordLestatLordLestat Member Posts: 17
    Got it all worked out. Thanks for giving me a place to look for help.
Sign In or Register to comment.