Autor Thema: Can some one help me with this Script functions Hunter, Timer,  (Gelesen 3652 mal)

Uancon

  • Tentakelschleim
  • *
  • Beiträge: 4
    • Profil anzeigen
I been looking at the Global Script  in the Mad house starter

How do i use the functions Hunter, Timer, 

Can some so tell me how they work and how ton use them

//On Timer:


// ============================= Timer ===========================================
#define OWNTIMERBASE 400
int amountoftimers = 0;

function SetOwnTimer (int timerid, int timeout){
  if (amountoftimers < timerid) amountoftimers = timerid;
  SetGlobalInt (OWNTIMERBASE - timerid, timeout + 1);
}

function IsOwnTimerExpired (int timerid){
  if (GetGlobalInt (OWNTIMERBASE - timerid) == 1)
  {
    SetGlobalInt (OWNTIMERBASE - timerid, 0);
    return 1;
  }
  else return 0;
}

function CheckTimers (){
  int timers = OWNTIMERBASE - 1;
  while (timers >= OWNTIMERBASE - amountoftimers)
  {
    if (GetGlobalInt (timers) >= 2) SetGlobalInt (timers, GetGlobalInt (timers) - 1);
    timers--;
  }
}




//On Hunter





// ============================= hunter ===========================================
// this section after cutscene functions
int hunter_char = NO_CHAR;
// two-dimeanional hunting
#define STEPS_UNTIL_DIR 10
int steps = STEPS_UNTIL_DIR;
int lastx = -1;
int lasty = -1;
// give player time to act
#define COUNTDOWN_OFF -1
#define COUNTDOWN_START 400
#define COUNTDOWN_STOPPED -2
int countdown = COUNTDOWN_OFF;
int hunter_area = -1;

function StartHunting (int hunter){
  hunter_char = hunter;
  lastx = -1;
  lasty = -1;
  countdown = COUNTDOWN_OFF;
  // switch player disabled
  // avo- SetGlobalInt (291, 1); // avo veraltet
}

function StartCountdown (){
  // give player some time to think and react
  // but player can't move
  SetGlobalInt (2, 0);
  hunter_area = GetWalkableAreaAt (character [GetPlayerCharacter ()].x - GetViewportX (), character [GetPlayerCharacter ()].y - GetViewportY ());
  RemoveWalkableArea (hunter_area);
  countdown = COUNTDOWN_START;
}

function StopHunting (){
  hunter_char = NO_CHAR;
  // player may move
  if (hunter_area >= 0)
  {
    RestoreWalkableArea (hunter_area);
    hunter_area = -1;
  }
  SetGlobalInt (2, 1);
  // switch player enabled
  // avo- SetGlobalInt (291, 0); // avo veraltet
}

function IsHunting (){
  int result = hunter_char != NO_CHAR;
  if (result)
  {
    // stop hunting when chars are in different rooms
    if (character [hunter_char].room != character [GetPlayerCharacter ()].room)
    {
      StopHunting ();
      result = hunter_char != NO_CHAR;
    }
  }
  return result;
}

function HunterSucceeded (){
  int hunter = hunter_char;
}

function TimeToActIsOver (){
  int hunter = hunter_char;
}

function DoHunting (){
  int caught = 0;
  int charid = GetPlayerCharacter ();
  int px = character [charid].x;
  int py = character [charid].y;
  // check distance
  int dx = px - character [hunter_char].x;
  int dy = py - character [hunter_char].y;
  if ((dx * dx + dy * dy) <= 500)
  {
    caught = 1;
    HunterSucceeded ();
  }
  else if (steps <= 0)
  {
    if ((px != lastx) || (py != lasty))
    {
      // correct HUNTER's direction
      MoveCharacter (hunter_char, px, py);
      lastx = px;
      lasty = py;
    }
    steps = STEPS_UNTIL_DIR;
  }
  else steps--;
  return caught;
}

function RepExec_Hunting (){
  int caught = 0;
  if (IsHunting ())
  {
    if (countdown == COUNTDOWN_OFF) caught = DoHunting ();
    else if (countdown == 0)
    {
      countdown = COUNTDOWN_OFF;
      TimeToActIsOver ();
    }
    else if (countdown > 0) countdown--;
  }
  return caught;
}

KhrisMUC

  • Moderator
  • volljähriger Tentakel
  • *****
  • Beiträge: 989
    • Profil anzeigen
Re: Can some one help me with this Script functions Hunter, Timer,
« Antwort #1 am: 06. Dezember 2006, 00:47:31 »
Rubacant, forget it. What you're trying here is borderline pathetic.