Noob question - Pistol

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
fuzzyfireball 1
Posts: 132
Joined: Sat Jan 01, 2005 10:11 pm
Location: Saint Paul, MN

Noob question - Pistol

Post by fuzzyfireball 1 »

I have a quick question.

How do I make it so you spawn with a random pistol weapon? For example. I start a new game and instead of the pistol, it's the Gold Wand. Then I start another new game, and instead of the Gold Wand, it's the pistol? I tried looking into the wiki,, put couldn't find anything. So if I missed it, sorry.

Anybody that can help me out?
User avatar
The NUtcracker
Posts: 843
Joined: Sun Jan 14, 2007 9:12 pm
Location: South Dakota
Contact:

Post by The NUtcracker »

I don't think you can do that without using ACS and only if the "PlayerClassChange" function is implemented.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Post by Matt »

One thing you can try is to create the playerclass and weapons as usual, but instead have the player begin with a weapon whose select state uses A_Jump to randomly give a weapon. The random weapon-giver then removes itself from the player's inventory and cannot be selected again.
fuzzyfireball 1
Posts: 132
Joined: Sat Jan 01, 2005 10:11 pm
Location: Saint Paul, MN

Post by fuzzyfireball 1 »

I'll try that, thanks :wink:
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

The following enter script swaps the player's starting inventory half the time.

Code: Select all

script 1 ENTER {
     if (random(0, 1)) {
          TakeInventory("Pistol", 1);
          TakeInventory("Clip", 50);
          GiveInventory("GoldWand", 1);
          GiveInventory("GoldWandAmmo", 20); // May need to adjust that number, that's from memory
     }
}
Note if this is to be used in a library, you will need a flag that disables it after the first time it is run. This is to avoid the script having an effect on subsequent maps.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

[2cents] 50 shots there, too. [/2cents]
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Ah, but how much does the GoldWand give? :)

The number above should be (NormalStartAmmo - GoldWandAmmoGive).
User avatar
Kirby
Posts: 2697
Joined: Thu Aug 26, 2004 1:23 pm

Post by Kirby »

This seems to work not too badly, given that I have terrible code writing skills and that it could be improved greatly :P
Attachments
random-test1.zip
I can't figure out though WHY the cell pack spawns everytime :/
(1.14 KiB) Downloaded 21 times
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

HotWax wrote:Ah, but how much does the GoldWand give? :)

The number above should be (NormalStartAmmo - GoldWandAmmoGive).
Then it should be 30. Eh, whatever, the player always likes more ammo.
...
Hmm, but it should be noted that the Elvenwand only has a maximum capacity of 100, as opposed to the pistol's 200.
fuzzyfireball 1
Posts: 132
Joined: Sat Jan 01, 2005 10:11 pm
Location: Saint Paul, MN

Post by fuzzyfireball 1 »

Wow, thanks a bunch guys. This is so much better then I could have done. :P
Locked

Return to “Editing (Archive)”