Fall Damage

Version:

3.0

Added on:

30 Dec 2014 16:30

Tags:

Description:
Well... in Jazz Jackrabbit 2 when you fall you don't lose hearts this is a simple script that makes you lose hearts when you fall.
  1. int fallTimer = 0;
  2. const double maxFallTime = 4;
  3.  
  4. void onMain() {
  5.     if (!jjMaskedPixel(p.xPos, p.yPos + 32) && p.ySpeed > 0) {
  6.       fallTimer++;
  7.   } else if (jjMaskedPixel(p.xPos, p.yPos + 32)) {
  8.     int repeats = (fallTimer / 70) / maxFallTime;
  9.                 if (fallTimer >= maxFallTime) {
  10.     for (int i = 0; i < (fallTimer / 70) / maxFallTime; i++) {
  11.         p.health = p.health - 1;
  12.         if (p.health < 0) p.health = 0;
  13.     }
  14.                 }
  15.       fallTimer = 0;
  16.   }
  17.     if (p.health == 0) {
  18.         fallTimer = 0;
  19.     }
  20. }
  21.