mutator, removing items

Discussions about Coding and Scripting
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

mutator, removing items

Post by Rakiayn »

I want a mutator to check in the map for certain items and remove those.
only I want it to be done only 1 time, when the mutator is spawned.
so using CheckReplacement is no option because it will check all the time for these items
Darkness
Experienced
Posts: 81
Joined: Mon Mar 01, 2010 10:12 pm
Location: Brazil

Re: mutator, removing items

Post by Darkness »

Rakiayn wrote:I want a mutator to check in the map for certain items and remove those.
only I want it to be done only 1 time, when the mutator is spawned.
so using CheckReplacement is no option because it will check all the time for these items
It is an option.

You can set a timer at the mutator, and it arrives the time, it sets a boolean variable to true.

And on checkreplacement, set to replace only if this boolean is false. Then it'll stop replacing after the timer ticks, which will set that variable to true.


Of you can perform a foreach all at the beggining and replace them manually, if you really don't want to use the checkreplacement.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: mutator, removing items

Post by Rakiayn »

tried both.
very weird. but the actors I want to replace are still there. so now i have two items at the same place
I dont dare to destroy them. i heard it is not good to do

and when i tried the the bool thing in the checkreplacement function, only one item got replaced lol

this is what i have now

Code: Select all

function tick(float deltatime)
{ 
removestuff();
disable('tick');

}



function removestuff()
{
local ammo other1;

	foreach AllActors( class 'ammo', other1 )
	{

		if ( (other1 != none)  && ( !other1.isa('A_MasterAmmo') )&& ( !other1.isa('A_MMAmmo')))
		{
			ReplaceWith( Other1, "Monstermatch.A_MMAmmo" );

		}
	}
}
Darkness
Experienced
Posts: 81
Joined: Mon Mar 01, 2010 10:12 pm
Location: Brazil

Re: mutator, removing items

Post by Darkness »

ReplaceWith don't remove items on its own... since the checkreplacement function only removes items if you return false there. When returning true, there'll be two spawns (the original, and the replacement).

So you'd better put something like other1.destroy() bellow the ReplaceWith.
gopostal

Re: mutator, removing items

Post by gopostal »

Man be careful with destroy though. One incorrect destroy can wreak havoc in your coding. I had one singular destroy miscoded in the RedeemerWorlds mod and it stopped the whole mod from functioning. Took me for-freaking-ever to find it out as the cause. I keep a mental list of my destroys now.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: mutator, removing items

Post by Rakiayn »

ok thnx .
right now i have the checkreplacement using from the beginning, until the timer stops
the timer is set to 1.

should i also be carefull with ''return false'' in checkreplacement?
Darkness
Experienced
Posts: 81
Joined: Mon Mar 01, 2010 10:12 pm
Location: Brazil

Re: mutator, removing items

Post by Darkness »

Rakiayn wrote:ok thnx .
right now i have the checkreplacement using from the beginning, until the timer stops
the timer is set to 1.

should i also be carefull with ''return false'' in checkreplacement?
Only if your IF is not very well specified. Otherwise there won't be any trouble.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: mutator, removing items

Post by Rakiayn »

hmm. its replaces all ammo,pickups and weapons
with a few exceptions. I guess thats not specified enough right?
problem is that I dont want any pickups in the map.
just like instagib
Darkness
Experienced
Posts: 81
Joined: Mon Mar 01, 2010 10:12 pm
Location: Brazil

Re: mutator, removing items

Post by Darkness »

Rakiayn wrote:hmm. its replaces all ammo,pickups and weapons
with a few exceptions. I guess thats not specified enough right?
problem is that I dont want any pickups in the map.
just like instagib
What's not being replaced? Check this...

Code: Select all

var bool bStarted, bReplaced;

function PostBeginPlay()
{
	if ( bStarted )
		Return;
	bStarted = True;
	SetTimer(1.0,false); // Whatever timer is needed, might need testing
	Super.PostBeginPlay();
}

function Timer()
{
	bReplaced = true;
}

function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
	local Inventory Inv;

	if ( bReplaced || Other.IsA('ClassYouWannaKeepIfAnyAtAll') )
		return true;
	else if ( Other.IsA('Pickup') )
		return false;
	else
		return true;
}
This could work.
User avatar
abc
Novice
Posts: 9
Joined: Thu Apr 20, 2017 12:18 am

Re: mutator, removing items

Post by abc »

BeltDelay.uc

Code: Select all

class BeltDelay extends Mutator; 

var bool bStarted, bReplaced;

var Actor A;

function PostBeginPlay()
{
	if ( bStarted ) 
		Return;
	bStarted = True;
	bReplaced = False;
	SetTimer(55.0,false);
	Super.PostBeginPlay();
}

function Timer()
{
	bReplaced = True;
	Spawn(class'UT_Shieldbelt', , , A.location, A.rotation);
}

function bool CheckReplacement(Actor Other, out byte bSuperRelevant) 
{
	if ( Other.IsA('UT_Shieldbelt') )
	{
		A = Other; 
		if ( !bReplaced ) 
		{
			return False;
		}
	}
	bSuperRelevant = 0;
	return True;
}

BeltDelay.int

Code: Select all

[Public]
Object=(Name=BeltDelay.BeltDelay,Class=Class,MetaClass=Engine.Mutator,description="Belt Delay")
Attachments
BeltDelay.int
(105 Bytes) Downloaded 7 times
BeltDelay.u
(1.71 KiB) Downloaded 7 times
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: mutator, removing items

Post by Barbie »

Argl, it is still alive
Zombie.png
Zombie.png (25.94 KiB) Viewed 572 times
Furthermore: I don't get the sense of that mutator.
What happens if there is no UT_Shieldbelt in the map? Access None.
What happens if there are multiple UT_Shieldbelts in the map? Only the last one will be treated.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: mutator, removing items

Post by sektor2111 »

I don't get the point of making a large over-thinking resulting in lousy codes with doubtful logic.
#1 Set a timer or a state for working a single time, wait a second and do replacements based on TWO lists ListOriginal[ i ], ListReplacement[ j ] with desired sanity checks. This can be subject for a server actor, you don't even need to send anything else in client than packages required by replacements.
What replacement ? A custom one, Spawn Item J at Item I location, copy some values if are needed and then simply destroy initial Item I, and stay latent after doing the task. Is not even needed CheckReplacement. If Item J is nothing, just delete Item I if is being found. - Pointing at TITLE.

Slash Cadaver Topic On
Rakiayn wrote: Sat Mar 06, 2010 10:54 pm so using CheckReplacement is no option because it will check all the time for these items
Slash Cadaver Topic Off
#2 A mutator using "CheckReplacement" only if Level.bStartUp = True. If Level.bStartUp is being passed just stay latent - stop touching replacements.
Here locations can be saved somewhere in whatever array and then... bring new things over there after a configured time. Here can be simulated a dynamic array by Spawning certain "guards" in each location and then using them as guide for bringing other items there with a delay which can be configured or calculated based on whatever factors.

#3 According to the topic's title - removing items is More Simple, just delete items from a configured list after one second.

Personal "private public" note: I don't see any deal "myMarker" - "markedItem" and then... I don't get this sudden revelation about a delayed shield which is not very "hunted" by plain stock A.I. A new shield spawns and that's all ?

And... Good Morning ! - after 12 years from last posting date.
User avatar
SilverSound
Adept
Posts: 344
Joined: Fri Nov 06, 2015 10:12 am
Personal rank: Curious
Location: St. Cloud, Florida

Re: mutator, removing items

Post by SilverSound »

Ignoring the two bozos with nothing of merit to add: Looks fine enough.

Don't let people acting like this get in the way of you providing answers to widely unanswered dead threads.

Especially since Google links to this thread regardless of age.
"Woah what?! I wish I was recording that...."
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: mutator, removing items

Post by Barbie »

SilverSound wrote: Sat Jun 25, 2022 2:36 am Ignoring the two bozos with nothing of merit to add
You don't take care of quality?

Apart from topic: don't poison the atmosphere here with such insults, please.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: mutator, removing items

Post by sektor2111 »

SilverSound wrote: Sat Jun 25, 2022 2:36 am Ignoring the two bozos with nothing of merit to add: Looks fine enough.
Not for "bozos". And no, if map has no "shield" see what it does - Nothing great, but dealing with nothing. Buzzzz... either way "mutator" is off-topic.
I have already something for removing items, for the moment I don't have public plans for that, exactly because of these type of "replies" having nothing to do with topic but aiming people. But... because today I'm not fully evil, I'll point direction about doing a "delayed spawn" without any corruption: See recent MH conversions with items delayed "spawned" by triggering - that is a "How To" for this case, not using "Trigger" but a timer or a state code.
Locked