Announcement

Collapse
No announcement yet.

Visible Timers for Pickups [Code Included]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Visible Timers for Pickups [Code Included]

    Hi all,

    Currently I'm trying to create several pickups with timers attached. The pickups and timers work great, the only thing I can't manage to get working is a timer like the double damage pickup has: one that is actually visible on screen with the time remaining before the pickups runs out. Could someone please point me to the correct class where I could find info on how to do it, or perhaps even give me a bit of sample code?

    Greetz Profound

    #2
    You'll need an Interaction Class. Which you can spawn an interaction HUD to display textures, widgets and icons on the players hud.

    http://wiki.beyondunreal.com/wiki/HUD_Interactions

    You'll need to learn how to place stuff on the HUD first, I guess.

    Comment


      #3
      Ok thanks, I'll look into that I found out that by calling ClientSetUDamageTime() I could get the UDamage Counter to show up with the correct setting Problem is that with multiple pickups they tend to interfere with eachother leading to about 90 seconds worth of time with all 3 pickups active

      greetz Profound

      Comment


        #4
        You could also use a HUDMutator class, if you dont need all the stuff an interaction gives you, like key inputs and such.

        Comment


          #5
          @pcmods
          Would I need 3 different Interactions for the 3 pickups I have at the moment?

          PC.Player.InteractionMaster.AddInteraction("Moso_v 1e.AirbagPickup", PC.Player);
          PC.Player.InteractionMaster.AddInteraction("Moso_v 1e.AfterburnerPickup", PC.Player);
          PC.Player.InteractionMaster.AddInteraction("Moso_v 1e.TriggerHappyPickup", PC.Player);

          Comment


            #6
            ok got it working, only if i restart the map, two timers are overlapping eachother... I think it might be fixed if I remove the interaction on EndGame().

            PC.Player.InteractionMaster.RemoveInteraction("Mos o_v1e.Airbag_interaction"); PC.Player.InteractionMaster.RemoveInteraction("Mos o_v1e.Afterburner_interaction");
            PC.Player.InteractionMaster.RemoveInteraction("Mos o_v1e.TriggerHappy_interaction");

            above code failed Type mismatch in parameter 1. So i guess i need the actual interaction, how could I find that one?

            Comment


              #7
              Not sure what the parameter type is, but Interactions get a LevelChanged event, you can have them remove itself, if that is really necessary.

              Comment


                #8
                yeah Bonehed316 i noticed that and it worked only have a different problem now. Timer does showup in singleplayer / instant action (offline) but not when running a server...

                Code:
                //=============================================================================
                // TriggerHappy Interaction Class
                //=============================================================================
                
                Class TriggerHappy_interaction extends Interaction;
                
                #exec OBJ LOAD FILE=MosoTextures_v1e.utx
                
                Var GameReplicationInfo GRI;
                
                event Initialized()
                {
                    //log("TriggerHappy Interaction Initialized");
                    foreach ViewportOwner.Actor.DynamicActors(class'GameReplicationInfo', GRI)
                        If (GRI != None)
                            Break;
                }
                
                function Tick(float DeltaTime)
                {
                    if ( ViewportOwner.Actor.Pawn == None )
                    {
                        Master.RemoveInteraction(self);
                        return;
                    }
                    if ( MosoRifle(xPawn(ViewportOwner.Actor.Pawn).Weapon).TriggerHappyCurrent > 0.0 )
                        bVisible = True;
                    else
                        bVisible = False;
                }
                
                function PostRender( canvas Canvas )
                {
                    local float X, Y;
                
                    //ViewportOwner.Actor.ClientMessage("Hit: TriggerHappy");
                    if ( Canvas.ClipX <= 640 )
                        X=16;
                    else if ( Canvas.ClipX <= 800 )
                        X=20;
                    else if ( Canvas.ClipX <= 1024 )
                        X=26;
                    else if ( Canvas.ClipX <= 1280 )
                        X=32;
                    else if ( Canvas.ClipX <= 1600 )
                        X=40;
                    else
                        X=24;
                
                    if ( Canvas.ClipY <= 480 )
                        Y=240;
                    else if ( Canvas.ClipY <= 600 )
                        Y=300;
                    else if ( Canvas.ClipY <= 768 )
                        Y=384;
                    else if ( Canvas.ClipY <= 960 )
                        Y=480;
                    else if ( Canvas.ClipY <= 1024 )
                        Y=512;
                    else if ( Canvas.ClipY <= 1200 )
                        Y=600;
                    else
                        Y=320;
                
                    Canvas.Style = 1;
                    Canvas.SetDrawColor(255,255,255);
                    Canvas.SetPos(Canvas.ClipX - (X+32), (Y+96));
                    Canvas.DrawIcon(Texture'MosoTextures_v1e.TriggerHappy', 1.0);
                    Canvas.SetPos(Canvas.ClipX - (X+64), (Y+96+8));
                    Canvas.FontScaleX = 2.0;
                    Canvas.FontScaleY = 2.0;
                    Canvas.DrawText(int(MosoRifle(xPawn(ViewportOwner.Actor.Pawn).Weapon).TriggerHappyCurrent - GRI.Level.TimeSeconds));
                }
                
                defaultproperties
                {
                    bVisible=True
                    bActive=True
                    bRequiresTick=True
                }

                Comment


                  #9
                  your Tick function, no offence, is kind of odd in my perspective :weird: lol

                  what i would do is remove the tick funtion and add:
                  Code:
                  event NotifyLevelChange()
                  {
                      if( CatchActor != None )
                          CatchActor.Destroy();
                      ViewportOwner.Actor.ConsoleCommand("set input "$sTalkKey$" Talk");
                      Master.RemoveInteraction(self);
                  }
                  P.S: could you post the function where the player gets the interaction? it may be why it does not function in Instant Action / Single

                  Comment


                    #10
                    Originally posted by ^::B!G-A::
                    your Tick function, no offence, is kind of odd in my perspective :weird: lol

                    P.S: could you post the function where the player gets the interaction? it may be why it does not function in Instant Action / Single
                    It does function in instant action, just not on servers. After some messing around i got the timers to show up on servers, but the time it's showing is completely off. instead of counting from 20 to 0 it counts from 35 to 15

                    Code:
                    //=============================================================================
                    // TriggerHappy Interaction Class
                    //=============================================================================
                    
                    Class TriggerHappy_interaction extends Interaction;
                    
                    #exec OBJ LOAD FILE=MosoTextures_v1e.utx
                    
                    var GameReplicationInfo GRI;
                    
                    simulated function Initialized()
                    {
                        //log("TriggerHappy Interaction Initialized");
                        foreach ViewportOwner.Actor.DynamicActors(class'GameReplicationInfo', GRI)
                            If (GRI != None)
                                Break;
                    }
                    
                    function NotifyLevelChange()
                    {
                    	GRI = None;
                            Master.RemoveInteraction(self);
                    }
                    
                    simulated function Tick(float DeltaTime)
                    {
                        if ( ViewportOwner.Actor.Pawn == None )
                            return;
                        if ( MosoRifle(xPawn(ViewportOwner.Actor.Pawn).Weapon).TriggerHappyCurrent > 0.0 )
                            bVisible = True;
                        else
                            bVisible = False;
                    }
                    
                    simulated function PostRender( canvas Canvas )
                    {
                        local float X, Y;
                    
                        //ViewportOwner.Actor.ClientMessage("Hit: TriggerHappy");
                        if ( Canvas.ClipX <= 640 )
                            X=16;
                        else if ( Canvas.ClipX <= 800 )
                            X=20;
                        else if ( Canvas.ClipX <= 1024 )
                            X=26;
                        else if ( Canvas.ClipX <= 1280 )
                            X=32;
                        else if ( Canvas.ClipX <= 1600 )
                            X=40;
                        else
                            X=24;
                    
                        if ( Canvas.ClipY <= 480 )
                            Y=240;
                        else if ( Canvas.ClipY <= 600 )
                            Y=300;
                        else if ( Canvas.ClipY <= 768 )
                            Y=384;
                        else if ( Canvas.ClipY <= 960 )
                            Y=480;
                        else if ( Canvas.ClipY <= 1024 )
                            Y=512;
                        else if ( Canvas.ClipY <= 1200 )
                            Y=600;
                        else
                            Y=320;
                    
                        Canvas.Style = 1;
                        Canvas.SetDrawColor(255,255,255);
                        Canvas.SetPos(Canvas.ClipX - (X+32), (Y+96));
                        Canvas.DrawIcon(Texture'MosoTextures_v1e.TriggerHappy', 1.0);
                        Canvas.SetPos(Canvas.ClipX - (X+64), (Y+96+8));
                        Canvas.FontScaleX = 1.0;
                        Canvas.FontScaleY = 1.0;
                        Canvas.DrawText(int(MosoRifle(xPawn(ViewportOwner.Actor.Pawn).Weapon).TriggerHappyCurrent - GRI.Level.TimeSeconds));
                    }
                    
                    defaultproperties
                    {
                        bVisible=True
                        bActive=True
                        bRequiresTick=True
                    }
                    and from the mutator tick is called like this:
                    Code:
                    simulated function Tick(float DeltaTime)
                    {
                    	// If the player has an interaction already, exit function.
                    	if (bHasInteraction)
                    		Return;
                    	PC = Level.GetLocalPlayerController();
                    
                    	// Run a check to see whether this mutator should create an interaction for the player
                    	if ( PC != None && ((PC.PlayerReplicationInfo.bIsSpectator && bAffectSpectators) || (bAffectPlayers && !PC.PlayerReplicationInfo.bIsSpectator)) )
                    	{
                    		PC.Player.InteractionMaster.AddInteraction("Moso_v1e.Airbag_interaction", PC.Player); // Create the interaction
                    		PC.Player.InteractionMaster.AddInteraction("Moso_v1e.Afterburner_interaction", PC.Player);
                    		PC.Player.InteractionMaster.AddInteraction("Moso_v1e.TriggerHappy_interaction", PC.Player);
                    		bHasInteraction = True; // Set the variable so this lot isn't called again
                    	}
                    }

                    Comment


                      #11
                      Can anyone please help me with this? I can't get it to work right. The timers are showing the wrong time (35-15 instead of the normal 20-0 counting) what could be wrong? i guess it has to do with replication?

                      Comment


                        #12
                        Send me you code, and i'll fix it.
                        PM me for my email.

                        Firstly, Interactions can be set in the ModifyPlayer() , don't use the Tick().
                        Example:
                        Code:
                        Function ModifyPlayer(Pawn Other){
                        	local PlayerController PC;
                        	local int i;
                        
                        	Super.ModifyPlayer(Other);
                        	if (Other==None) return;
                        	PC = PlayerController(Other.Controller);
                        	if (PC != None) {
                        		for (i = 0; i < PC.Player.LocalInteractions.Length; i++){
                        			if ( !PC.Player.LocalInteractions[i].IsA('TimerInteraction') ) {
                        				PC.Player.InteractionMaster.AddInteraction("TestTimer.TimerInteraction", PC.Player);
                        				break;
                        			}
                        		}
                        	}
                        }
                        This way your not using the Tick() code to check a players interaction. If you need to use the Tick() then I guess you must, but should be a last resort.

                        Comment

                        Working...
                        X