Page 1 of 1

Dropping Keycards

Posted: Fri Jul 17, 2015 6:28 am
by konamikode
Hello! I want it that every time you take a teleporter, you lose all of the keycards you had.

(FYI I am using Doom in Hexen Format)

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 8:23 am
by Fused
I'm not sure if keys can be removed after being grabbed, but perhaps change the keys to inventory items and check for those at locked doors. Those can definitely be removed from the player's inventory.

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 8:55 am
by agaures
Fused wrote: I'm not sure if keys can be removed after being grabbed, but perhaps change the keys to inventory items and check for those at locked doors. Those can definitely be removed from the player's inventory.
What? Of course they can be removed. Just use takeinventory using acs.

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 11:12 am
by Fused
Thanks for clarifying I guess. So if you have a teleporter, create a script that teleports him and also removed the keycards using takeinventory.

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 3:52 pm
by Dusk
Maybe something like this for a global solution? Haven't tested but should work in theory..

Code: Select all

function int abs (int a)
{
  if (a < 0)
    return -a;

  return a;
}

script 123 ENTER
{
  int dx, dy, prevx, prevy;

  while (true)
  {
    prevx = GetActorX (0);
    prevy = GetActorY (0);
    delay (1);
    dx = GetActorX (0) - prevx;
    dy = GetActorY (0) - prevy;

    // Check if player moved faster than he is moving
    if (abs (dx) > abs (GetActorVelX (0)) || abs (dy) > abs (GetActorVelY (0)))
    {
      TakeInventory ("RedCard", 1);
      TakeInventory ("BlueCard", 1);
      TakeInventory ("YellowCard", 1);
      TakeInventory ("RedSkull", 1);
      TakeInventory ("BlueSkull", 1);
      TakeInventory ("YellowSkull", 1);
    }
  }
}

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 4:13 pm
by Vincent(PDP)
In Zan 3.0 you should be able to use the A_CheckFlag DECORATE function to check if the TELEPORT flag is set.

But for now I'd go with Dusk's or Fused's solution.

RE: Dropping Keycards

Posted: Fri Jul 17, 2015 7:39 pm
by konamikode
Dusk wrote: Maybe something like this for a global solution? Haven't tested but should work in theory..

Code: Select all

function int abs (int a)
{
  if (a < 0)
    return -a;

  return a;
}

script 123 ENTER
{
  int dx, dy, prevx, prevy;

  while (true)
  {
    prevx = GetActorX (0);
    prevy = GetActorY (0);
    delay (1);
    dx = GetActorX (0) - prevx;
    dy = GetActorY (0) - prevy;

    // Check if player moved faster than he is moving
    if (abs (dx) > abs (GetActorVelX (0)) || abs (dy) > abs (GetActorVelY (0)))
    {
      TakeInventory ("RedCard", 1);
      TakeInventory ("BlueCard", 1);
      TakeInventory ("YellowCard", 1);
      TakeInventory ("RedSkull", 1);
      TakeInventory ("BlueSkull", 1);
      TakeInventory ("YellowSkull", 1);
    }
  }
}
That just removes any keycard I grab.

RE: Dropping Keycards

Posted: Sat Jul 18, 2015 9:51 am
by Vincent(PDP)
If the player's running speed is Doom's default then he is running about 10-15 mapunits/sec I think (without jumping or straferunning). If you measure his speed in different situations you can check if he moves alot faster than the greatest one of them. (Like if he moves faster than strafejumping and running at the same time). You should always also check the player's speed via GetActorProperty (and possibly multiply the highest value with it) to make sure that it not takes your keys just because you've uses the "turbo" command or got a turbosphere.
I'll see later if I can create a script for you.