How do I start a map with custom health/ammo/etc.?
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.
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.
- TheSoldiersShadow
- Posts: 35
- Joined: Wed Apr 06, 2016 4:29 pm
- Location: Canada
How do I start a map with custom health/ammo/etc.?
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).
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).
- 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.?
You need an ENTER script for the player which gives or takes the appropriate items. Something like:
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.

Code: Select all
script 1337 ENTER
{
takeinventory("health",25);
takeinventory("clip",40);
}Re: How do I start a map with custom health/ammo/etc.?
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 
- 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.?
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. 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.

Code: Select all
script 2012 (void)
{
teleport(14,0,0);
clearinventory();
giveinventory("fists",1);
}Re: How do I start a map with custom health/ammo/etc.?
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.
- 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.?
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?Caligari87 wrote:Code: Select all
script 1337 ENTER { takeinventory("health",25); takeinventory("clip",40); }
- 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.?
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.

- 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.?
Alright, I understand. But there's something that confuses me (sorry if i'm annoying, but i'm REALLY trying to understand this)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.
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);
} - Caligari87
- Admin
- Posts: 6242
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact: