How do I start a map with custom health/ammo/etc.?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
TheSoldiersShadow
Posts: 35
Joined: Wed Apr 06, 2016 4:29 pm
Location: Canada

How do I start a map with custom health/ammo/etc.?

Post by TheSoldiersShadow »

Ok, say I want to start a level with a specific amount of health and/or ammo (eg: 75% health and 10 pistol ammo, or no ammo at all). How would I achieve this?

I am using Doom Builder 2 and I'm pretty sure it has something to do with ACS (which I'm really not good at using).
User avatar
Caligari87
Admin
Posts: 6242
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do I start a map with custom health/ammo/etc.?

Post by Caligari87 »

You need an ENTER script for the player which gives or takes the appropriate items. Something like:

Code: Select all

script 1337 ENTER
{
  takeinventory("health",25);
  takeinventory("clip",40);
}
Would work for a level where the player is expected to be doing a default pistol start. If the player might already have something when starting the level, you could [wiki]ClearInventory[/wiki] and then just give what's needed in the same way.

8-)
User avatar
Reactor
Posts: 2091
Joined: Thu Feb 03, 2011 6:39 pm
Location: Island's Beauty, Hungary

Re: How do I start a map with custom health/ammo/etc.?

Post by Reactor »

Hm! I was wondering...does your solution works during levels too? For instance, the player teleports from point "A", and when he arrives to point "B", he is stripped down to bare fists? I don't plan to use it, just curiousity :)
User avatar
Caligari87
Admin
Posts: 6242
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do I start a map with custom health/ammo/etc.?

Post by Caligari87 »

You could do that if you wanted to, as well! I'd really recommend reading the [wiki]ACS[/wiki] reference page on the wiki and [wiki]A_quick_beginner's_guide_to_ACS[/wiki], because it's really not hard at all to understand. You can write a simple script to do almost anything you want, any time you want.

Code: Select all

script 2012 (void)
{
  teleport(14,0,0);
  clearinventory();
  giveinventory("fists",1);
}
Have the teleporter call the script instead of the normal teleport action, and the script can do the teleport + taking all the player's stuff! Note that the scripts I've given you so far are untested and just examples, you'd have to tweak them to make them work and fit your project.

8-)
User avatar
Reactor
Posts: 2091
Joined: Thu Feb 03, 2011 6:39 pm
Location: Island's Beauty, Hungary

Re: How do I start a map with custom health/ammo/etc.?

Post by Reactor »

I noticed this phenomenon in another game (the Freddy Krueger one), on level 5 and level 9, where the player loses the entire inventory before fighting the "guardian" and given a single dagger, whilst on level 9, Freddy takes away all the keys. I'm also glad to see that this works vice-versa, the player can get stuff for free, not just lose them.
User avatar
TheSoldiersShadow
Posts: 35
Joined: Wed Apr 06, 2016 4:29 pm
Location: Canada

Re: How do I start a map with custom health/ammo/etc.?

Post by TheSoldiersShadow »

Caligari87 wrote:

Code: Select all

script 1337 ENTER
{
  takeinventory("health",25);
  takeinventory("clip",40);
}
8-)
Thank you! Just one problem: When I do the command, instead of giving 25% health and 40 bullets, all I get is 10 bullets, and my health doesn't even change. Any reason for this?
User avatar
Caligari87
Admin
Posts: 6242
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do I start a map with custom health/ammo/etc.?

Post by Caligari87 »

For the first, change "health" to a health powerup like "medkit" or "stimpack", that should work. For the second, remember the player (script activator) starts normally with 50 bullets, so takeinventory("clip",40) takes away 40 of those, leaving you with 10. Change the number as desired to leave the player with the result. The opposite command is [wiki]GiveInventory[/wiki], which adds to the activator.

8-)
User avatar
TheSoldiersShadow
Posts: 35
Joined: Wed Apr 06, 2016 4:29 pm
Location: Canada

Re: How do I start a map with custom health/ammo/etc.?

Post by TheSoldiersShadow »

Caligari87 wrote:For the first, change "health" to a health powerup like "medkit" or "stimpack", that should work. For the second, remember the player (script activator) starts normally with 50 bullets, so takeinventory("clip",40) takes away 40 of those, leaving you with 10. Change the number as desired to leave the player with the result. The opposite command is [wiki]GiveInventory[/wiki], which adds to the activator.

8-)
Alright, I understand. But there's something that confuses me (sorry if i'm annoying, but i'm REALLY trying to understand this)

So, I renamed "health" to "medkit". Then, if I were to put:

takeinventory("medkit",25);

Should I lose 25% health? Because when I did that, it still says I have 100% health. Here's what my script looks like:

Code: Select all

#include "zcommon.acs"

script 999 ENTER
{
  clearinventory();
  takeinventory("medkit",25);
} 
As you can see, I added clearinventory(); to the code, and it works. Not sure if that has anything to do with it. The answer is probably simple, so i'm sorry for wasting your time with this.
User avatar
Caligari87
Admin
Posts: 6242
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do I start a map with custom health/ammo/etc.?

Post by Caligari87 »

Ah, figured it out: It's "medikit", not "medkit".

8-)
Locked

Return to “Editing (Archive)”