Not logged inOpenClonk Forum
Up Topic Variable Jump height

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Sven2
To test the jump idea, I created it in a test scenario (attached): Download

Copy this either into your user folder or clonk installation folder and start the scenario "Treasure Hunt [JumpTest]" to try it out.

You jump the default height if you hold the key, and much lower if you just tap it.

If you want to test it in other scenarios, copy this script into its System.ocg:
#appendto Clonk

public func ControlJumpExecute(int ydir, ...)
{
  if (inherited(ydir, ...))
  {
    // Add a timer to adjust vertical speed if not holding the jump key
    if (this.jumpfx) RemoveEffect(this.jumpfx);
    this.jumpfx = CreateEffect(FxJumpTests, 1, 1);
    return true;
  }
  return false;
}

static const FxJumpTests = new Effect
{
  Timer = func(int time)
  {
    if (time > 60) return FX_Execute_Kill;
    if (!Target) return FX_Execute_Kill;
    if (Target->GetProcedure() != DFA_FLIGHT) return FX_Execute_Kill;
    var ydir = Target->GetYDir();
    if (ydir > 0) return FX_Execute_Kill;
    var plr = Target->GetController();   
    if (GetPlayerType(plr) == C4PT_User)
    {
      if (!GetPlayerControlState(plr, CON_Up))
      {
        Target->SetYDir(ydir + 3);
      }
    }
    return FX_OK;
  },

  Destruction = func()
  {
    if (Target) Target.jumpfx = nil;
  }
};

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill