Removing ammo without removing weapons

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

Removing ammo without removing weapons

Post by Kismet »

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: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Removing ammo without removing weapons

Post by Barbie »

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: 10
Joined: Sat Nov 05, 2022 9:45 pm

Re: Removing ammo without removing weapons

Post by Kismet »

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: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: Removing ammo without removing weapons

Post by Buggie »

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: 10
Joined: Sat Nov 05, 2022 9:45 pm

Re: Removing ammo without removing weapons

Post by Kismet »

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: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: Removing ammo without removing weapons

Post by Buggie »

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: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Removing ammo without removing weapons

Post by sektor2111 »

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: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Removing ammo without removing weapons

Post by papercoffee »

just replace ammo with decoration... :mrgreen:
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Removing ammo without removing weapons

Post by sektor2111 »

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