1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

[UT2004] Mutator Modifying Adrenaline

Discussion in 'Programming' started by SlayerDragon, Apr 22, 2004.

  1. SlayerDragon

    SlayerDragon LLLLLLLLLLLLLLLLLADIES

    Joined:
    Feb 3, 2003
    Messages:
    7,666
    Likes Received:
    0
    I am trying to randomly set the amount of points a pill gives you to a negative amount. Here is the code:
    Code:
    var() float chanceOfDowner;
    
    function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
    {
    	local AdrenalinePickup P;
    	if( AdrenalinePickup(Other)!=NONE )
    	{
    		if( FRand() <= chanceOfDowner )
    		P = AdrenalinePickup(Other);
    		P.AdrenalineAmount = - P.AdrenalineAmount; //invert adrenaline amount
    	}
    	return false;	//don't replace
    }
    
    defaultproperties
    {
    	chanceOfDowner = 0.5;
    }
    
    This refuses to change the AdrenalineAmount! I have tried doing it like this:

    Code:
    	P.default.AdrenalineAmount = - P.default.AdrenalineAmount;
    
    Still, no effect. I tried changing the pickup message, and this is the only one that worked:

    Code:
    	P.default.PickupMessage = "Downer ";
    
    However, this changes the pickup message for ALL pills in the level.

    :( Anyone know what I am doing wrong?
     
  2. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    Check the code:
    Code:
    auto state Pickup
    {   
        function Touch( actor Other )
        {
            local Pawn P;
                
            if ( ValidTouch(Other) ) 
            {           
                P = Pawn(Other);    
                [b]P.Controller.AwardAdrenaline(2);[/b]
                AnnouncePickup(P);
                SetRespawn();           
            }
        }
    }
    Looks like the amount of adrenaline given by the pickup is hard-coded, despite the (misleading) presence of that variable. Bad luck. :hmm:
     
  3. SlayerDragon

    SlayerDragon LLLLLLLLLLLLLLLLLADIES

    Joined:
    Feb 3, 2003
    Messages:
    7,666
    Likes Received:
    0
    Bah. Thanks. I was working on that before I went to bed last night so it was bothering me this morning while I'm at school. Looks like I will have to replace the pickup with my own then. :)
     

Share This Page