Removing ammo without removing weapons

Discussions about Coding and Scripting
Kismet
Novice
Posts: 4
Joined: Sat Nov 05, 2022 9:45 pm

Removing ammo without removing weapons

Post by Kismet » Sat Nov 05, 2022 10:03 pm

I made a mutator that removes some ammo from the level. Weapons must remain. I do it like this (ordinary code):

Code: Select all

function bool CheckReplacement(Actor other, out byte bSuperRelevant) {
	if (other.IsA('BioAmmo')) {
		return false;
	}
	return true;
}
But at the same time, those ammo that are in the weapon are also removed. Please tell me how to separate ammo in weapons from ammo on the ground.

P.S. English is not my native language.

User avatar
Barbie
Godlike
Posts: 2479
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Removing ammo without removing weapons

Post by Barbie » Sat Nov 05, 2022 11:09 pm

Add the condition IsInState('Pickup'):

Code: Select all

function bool CheckReplacement(Actor other, out byte bSuperRelevant) {
	if (other.IsA('BioAmmo') && Other.IsInState('Pickup')) return false;
	return true;
}
(untested)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

Kismet
Novice
Posts: 4
Joined: Sat Nov 05, 2022 9:45 pm

Re: Removing ammo without removing weapons

Post by Kismet » Sat Nov 05, 2022 11:35 pm

Unfortunately not working.

When the player gets the weapon, script always runs CheckReplacement() for its ammo (I knew it before). And other.IsInState('Pickup') also return true.

Buggie
Godlike
Posts: 1763
Joined: Sat Mar 21, 2020 5:32 am

Re: Removing ammo without removing weapons

Post by Buggie » Sun Nov 06, 2022 12:42 am

Just iterate over All actors on map start and destroy ammo.
This partially help. Dynamically created ammo will be left.

Another approach - spawn custom actor which held link to ammo. On first tick it check in which state ammo. if it is pickup, then ammo destroyed.
At end first tick helper actor destroy self.

Kismet
Novice
Posts: 4
Joined: Sat Nov 05, 2022 9:45 pm

Re: Removing ammo without removing weapons

Post by Kismet » Sun Nov 06, 2022 12:49 am

Thanks for the reply. But I just found simple solution:

Code: Select all

Inventory(other).MyMarker != none
Ammo that spawns on the ground contains a navigation point in that property.

Buggie
Godlike
Posts: 1763
Joined: Sat Mar 21, 2020 5:32 am

Re: Removing ammo without removing weapons

Post by Buggie » Sun Nov 06, 2022 5:25 am

Usual ammo yes. But some mods can spawn or drop ammo to ground without it. Or it can be produced be breakable things and so on.
If this not case, your way must work fine.

User avatar
sektor2111
Godlike
Posts: 6030
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Removing ammo without removing weapons

Post by sektor2111 » Sun Nov 06, 2022 9:12 am

Replacing/Removing ammo during "Level.bStartUp" - it takes in account even those without "Marker" and no further replacements are in account.

User avatar
papercoffee
Godlike
Posts: 10178
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: Removing ammo without removing weapons

Post by papercoffee » Sun Nov 06, 2022 2:26 pm

just replace ammo with decoration... :mrgreen:

User avatar
sektor2111
Godlike
Posts: 6030
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Removing ammo without removing weapons

Post by sektor2111 » Sun Nov 06, 2022 9:35 pm

papercoffee wrote:
Sun Nov 06, 2022 2:26 pm
just replace ammo with decoration... :mrgreen:
That's easy...