Announcement

Collapse
No announcement yet.

BR Mod display question

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

    BR Mod display question

    Hey,

    I am messing around with a Bombing Run mod that gives different point levels for the distance you are away from the goal. This has been out there for a little while, but I want to add to it. The following code determines the distance from the player to the goal:

    Code:
    If (Scorrer.PlayerReplicationInfo.Team.teamIndex==0)
    {
    Dist=Vsize(LocScorer-Level.Game.GameReplicationInfo.Teams[1].HomeBase.Location);
    
    }
    If (Scorrer.PlayerReplicationInfo.Team.teamIndex==1)
    {
    Dist=Vsize(LocScorer-Level.Game.GameReplicationInfo.Teams[0].HomeBase.Location);
    }
    Is there a really easy way that I can display that Dist variable on the screen so the players know how far away they are? I'm sure there is an easy syntax to put something on the screen like "Distance from Goal = ", Dist . This would allow people to know if they are in the 3, 4 or 5 point range.

    Thanks for any help!

    EDGE

    #2
    RenderOverlays(Canvas C) - Actor

    Comment


      #3
      Can you help me with the syntax for my specific function?


      "Distance from goal " and then the variable dist

      Comment


        #4
        Look through the functions available in the Canvas object. You'll probably want to mess with Font and font-related functions, then SetPos to pick a spot on the screen to draw on, and then DrawText to finally render it.

        As for where you can access a Canvas object, RenderOverlays in the BallLauncher class seems to make the most sense, and should make calculating the distance pretty easy, something like this, I guess:

        Code:
        simulated event RenderOverlays(Canvas C)
        {
        	local vector GoalLocation;
        	local float Dist;
        	local float x, y;
        	
        	super.RenderOverlays(C);
        	
        	if (PlayerController(Instigator.Controller) != None &&
        		PlayerController(Instigator.Controller).GameReplicationInfo != None &&
        		Instigator.PlayerReplicationInfo != None &&
        		Instigator.PlayerReplicationInfo.Team != None
        	) {
        		GoalLocation = PlayerController(Instigator.Controller).GameReplicationInfo.Teams[Instigator.PlayerReplicationInfo.Team.TeamIndex].HomeBase.Location;
        		Dist = VSize(GoalLocation - Instigator.Controller.Location);
        		C.SetPos(x, y); // specify an x and y if you want the text to display in a particular spot on the screen
        		C.DrawText("Distance from Goal ="@Dist);
        	}
        }

        Comment


          #5
          Actually it isnt that simple, you need to draw that as a HUD, HUDOverlay or Interaction. And I suggest you use HUDOverlay.
          Best way to add it would be through a mutator like:
          Code:
          Class MyMutator extends Mutator;
          
          function PostBeginPlay()
          {
          	if( Level.NetMode!=NM_DedicatedServer )
          		SetTimer(0.1,False);
          }
          function Timer()
          {
          	AddHudOverlay();
          }
          simulated function PostNetBeginPlay()
          {
          	if( Level.NetMode==NM_Client )
          		AddHudOverlay();
          }
          simulated function AddHudOverlay()
          {
          	local HudOverlay H;
          	local PlayerController PC;
          
          	PC = Level.GetLocalPlayerController();
          	if( PC==None ) Return;
          	H = Spawn(Class'MyHudOverlay',PC.myHUD);
          	H.Instigator = PC;
          	PC.myHUD.AddHudOverlay(H);
          }
          
          defaultproperties
          {
          	RemoteRole=ROLE_SimulatedProxy
          	bAlwaysRelevant=True
          }
          That should work online aswell...
          Then use simulated function Render( Canvas C ) on HUDOverlay class.

          Comment


            #6
            Code:
            function PostBeginPlay()
            {
            	if( Level.NetMode!=NM_DedicatedServer )
            		SetTimer(0.1,False);
            }
            function Timer()
            {
            	AddHudOverlay();
            }
            Why the hack?

            Comment


              #7
              Originally posted by Jrubzjeknf View Post
              Code:
              function PostBeginPlay()
              {
              	if( Level.NetMode!=NM_DedicatedServer )
              		SetTimer(0.1,False);
              }
              function Timer()
              {
              	AddHudOverlay();
              }
              Why the hack?
              Due to local playercontroller does not excist yet in local game in postbeginplay at the mutator, thats why it needs to be done at least 1 tick later.
              Just for your information: mutator's pre/post beginplay are called druing GameInfo.InitGame, becouse thats where they are spawned in. Problem is that mutators seam to get those events called double, 1 on initgame and another after initgame with all other actors.

              Comment


                #8
                Don't understand this statement:

                Then use simulated function Render( Canvas C ) on HUDOverlay class.
                I see how to syntax that function from above, but what do you mean by using it ON the HUDOverlay class?

                Comment


                  #9
                  Why can't I use the clientmessage command? I tried and couldn't get it to compile. Arrrrgggghhhhhh

                  Tried

                  ClientMessage("Distance From Goal= " $ String(Dist));

                  Comment


                    #10
                    Originally posted by .:..: View Post
                    Due to local playercontroller does not excist yet in local game in postbeginplay at the mutator, thats why it needs to be done at least 1 tick later.
                    Just for your information: mutator's pre/post beginplay are called druing GameInfo.InitGame, becouse thats where they are spawned in. Problem is that mutators seam to get those events called double, 1 on initgame and another after initgame with all other actors.
                    Did you know that all spawned PlayerControllers are passed through Mutator.IsRelevant()? ASMutator uses this method to change the PlayerController.

                    Comment


                      #11
                      Originally posted by Jrubzjeknf View Post
                      Did you know that all spawned PlayerControllers are passed through Mutator.IsRelevant()? ASMutator uses this method to change the PlayerController.
                      Ofcourse I know, but it isnt as reliable as modifing 1 tick after spawned to make sure the initial settings has been loaded (i.e. Hud has been spawned etc...). Also it gets slower in online play becouse IsRelevant is only serverside, and hudoverlay has to be set locally on player.

                      Comment


                        #12
                        k, thx for the info.

                        Comment


                          #13
                          try C.ClientMessage("Distance From Goal= " $ String(Dist));

                          Comment

                          Working...
                          X