Dropping Keycards

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
konamikode
 
Posts: 21
Joined: Sat Oct 11, 2014 11:11 pm

Dropping Keycards

#1

Post by konamikode » Fri Jul 17, 2015 6:28 am

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)

Fused
Contributor
Posts: 687
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

RE: Dropping Keycards

#2

Post by Fused » Fri Jul 17, 2015 8:23 am

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.
Image Image

Collaborate and join the community
Image Image

User avatar
agaures
Forum Regular
Posts: 591
Joined: Mon Dec 10, 2012 6:34 am
Location: New Zealand

RE: Dropping Keycards

#3

Post by agaures » Fri Jul 17, 2015 8:55 am

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.
<agaures> I'm guessing you haven't played many doom mods before huh? :p
<Zuplin> i have played master of puppets zombies doom center and a couple more
<agaures> so not many
<Zuplin> i thought that was everything

Fused
Contributor
Posts: 687
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

RE: Dropping Keycards

#4

Post by Fused » Fri Jul 17, 2015 11:12 am

Thanks for clarifying I guess. So if you have a teleporter, create a script that teleports him and also removed the keycards using takeinventory.
Image Image

Collaborate and join the community
Image Image

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: Dropping Keycards

#5

Post by Dusk » Fri Jul 17, 2015 3:52 pm

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);
    }
  }
}

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: Dropping Keycards

#6

Post by Vincent(PDP) » Fri Jul 17, 2015 4:13 pm

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.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

User avatar
konamikode
 
Posts: 21
Joined: Sat Oct 11, 2014 11:11 pm

RE: Dropping Keycards

#7

Post by konamikode » Fri Jul 17, 2015 7:39 pm

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.

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: Dropping Keycards

#8

Post by Vincent(PDP) » Sat Jul 18, 2015 9:51 am

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.
Last edited by Vincent(PDP) on Sat Jul 18, 2015 9:53 am, edited 1 time in total.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Post Reply