PowerUp doesn't activate at spawn

Discussions about Coding and Scripting
Post Reply
User avatar
FXANBSS
Skilled
Posts: 230
Joined: Thu Dec 26, 2013 7:03 pm

PowerUp doesn't activate at spawn

Post by FXANBSS » Sun May 01, 2016 1:24 am

Hello!

I have a problem, it's related to the UDamage, well, i am making a mutator (For myself).
I want to spawn automatically with the UDamage. But it can't manage to do it even if i put bActive=true

Here is the code:

Code: Select all

class FXBUTGiveUDamage expands FXBUTGiveSinglePowerUp;

function ModifyPlayer(Pawn Other)
{
	local inventory Inv;

	inv = Spawn(class'Botpack.UDamage');
	if( inv != None )
	{
		inv.bHeldItem = true;
		inv.RespawnTime = 0.0;
		inv.GiveTo(Other);
		inv.bActive = true;
	}

	if ( NextMutator != None )
		NextMutator.ModifyPlayer(Other);
}
I hope that this is not complex to fix, i also want this for other Power-Ups. (which uses the UDamage code, Ex: PentaPower from EXU2.)

Thanks.

Spectra
Masterful
Posts: 542
Joined: Tue Jan 22, 2013 5:23 pm
Personal rank: Nullified!
Location: (X) Unable To Locate....

Re: PowerUp doesn't activate at spawn

Post by Spectra » Sun May 01, 2016 5:25 am

Remove bActive and add this:

Code: Select all

inv.Activate();
Also do some more sanity checks like Other != None:

Code: Select all

function ModifyPlayer(Pawn Other)
{
   local inventory Inv;

   if(Other != None)
   {
      inv = Spawn(class'Botpack.UDamage');
      if( inv != None )
      {
         inv.bHeldItem = true;
         inv.RespawnTime = 0.0;
         inv.GiveTo(Other);
         inv.Activate();
      }
   }

   if ( NextMutator != None )
      NextMutator.ModifyPlayer(Other);
}

User avatar
FXANBSS
Skilled
Posts: 230
Joined: Thu Dec 26, 2013 7:03 pm

Re: PowerUp doesn't activate at spawn

Post by FXANBSS » Sun May 01, 2016 5:38 am

Wow, thanks!

I've seen the Activate() thing when looking at code, but i didn't know it would work like that!
Sorry, i am still a bit N00b at this, i like to play with UED! :)

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

Re: PowerUp doesn't activate at spawn

Post by sektor2111 » Sun May 01, 2016 6:30 am

Skaarj code:

Code: Select all

inv.RespawnTime = 0.0;
inv.Touch(Other);
I very think that Udamage do self activate at picking it up + has message. No need bHeldItem because it's not weapon, and simulates like you get it from a spot.

UTX
Skilled
Posts: 214
Joined: Fri Aug 28, 2015 3:39 am

Re: PowerUp doesn't activate at spawn

Post by UTX » Sun May 01, 2016 8:30 pm

Yes, pickups activate on their own when picked up because DMMutator, the base Deathmatch mutator, makes all pickups automatically activate. However, when you give pickups to a pawn or a playerpawn this way, they are not being picked up and so they are not always activated. You can use "Inv.Activate ();" but if that doesn't work you can always try "Inv.GoToState ('Activated');" it's what works for me.

Not sure if bHeldItem is necessary, but it is the same code found in Last Man Standing where players get Armor, so I guess it doesn't hurt either.

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

Re: PowerUp doesn't activate at spawn

Post by sektor2111 » Mon May 02, 2016 8:53 pm

Not sure if doesn't always work, in my customs I don't have too many bAutoActivate things and UDamage is auto-activating when is pick up all the time. Give an example of game where default UDamage did not become active at pickup. I assure you that I'm using such thing even in MH2 at bonus amp and it did not fail - replacements must be done correctly and amp used must be called the replaced one, else original one. When player pick that up TOUCH is called and it works properly - if I'm not mistaking Old Amplifier does the same when Owner has Dispersion and/or ASMD. Also I loved this way for some other weapons and Bot doesn't return RateSelf craps and neither monsters. I think I figured where the problem was. Ammo load went too late and A.I. was rating None things, LOL. Actually if you do things well, A.I. any loads stuff properly with No errors.

Post Reply