Announcement

Collapse
No announcement yet.

Give player the flag?

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

    Give player the flag?

    Hi there. I hope it's okay to post something in the UT2k4 section. I looked around but couldn't find any rules against it. I know the game is 12 years old at this point, but I'm hoping someone out there will be able to help me.

    I've been feeling the modding itch, and since my current computer can't run UT3 or 4, I thought I'd take a crack at something in good old UT2k4 based on a mod I was working on back when I could run UT3. I'm working on a VIP/Hunted/Assassination gametype, and so far it's going okay. I still need to figure out how to set up different "classes" (i.e., the VIP, a sniper class, a medic class, etc.), but first I'm just trying to see if I can set one person to be a target for the enemy team. I figured the easiest way to do this would be to have someone start with a flag; in this case, the bomb from Bombing Run, since it's a single-flag sort of gametype.

    However, from digging through the xBombFlag, GameObject, and Decoration classes, it seems the only way to get a flag is to physically touch it. At that point, it takes the touching Pawn's controller and sets that to be the flag's owner. I've tried calling the xBombFlag directly in the gametype's PostBeginPlay(), which seems to be when the match starts, but I couldn't figure out the correct syntax to do so. I also tried creating a new instance of my custom GameObject and assigning it to a player, but I couldn't find any examples of spawning something through code, and the things I tried didn't work.

    Does anyone have any ideas on how I might accomplish this? Is this something that can really only be accomplished through level design (like putting the spawn for the "flag" over one of the player spawns so they automatically become the VIP)? Any help on this is greatly appreciated!

    #2
    I think I remember trying to make a similar game type 6 or 7 years ago (I did have a game type where there was a single flag that each team tried to hold, the holding team had to defend their flag carrier and the, non-flag holding team had to kill them). I probably released it with the last version of my YARM mod (the custom gametypes could be played with 'vanilla' UT2k4, I just packaged them with YARM because I liked how they played). I'll see if I can dig it up in the next couple of days.

    Comment


      #3
      That would be really helpful, thank you! I tried looking for a copy of YARM to try it out, but the only links I could find redirected to The Escapist magazine for some reason.

      Comment


        #4
        Yep Gamefront is gone, there was a lot of of content for this game on there.
        Here is a link to Yarm.
        https://dl.dropboxusercontent.com/u/..._May292013.zip

        Comment


          #5
          Thanks, Parkis! (Clicking any of the Reply buttons causes the page to freeze for some reason, so sorry for not directly tagging.)

          I've been able to assign my custom game object to someone! As far as I can tell it gives it to the first Pawn to spawn, but I'm still trying to see who exactly gets it. Important to note, I had to move the code to do this into the StartMatch() function of the gametype, as it seems PostBeginPlay() is before anyone is actually in the game yet. I also had to set "bStatic" to false in the custom game object's default properties.

          I noticed that the gametype is currently leveraging the message system of HudCBombingRun despite my not using xBombFlag to give to the pawns. (If you start with the custom game object, it flashes the "you have the flag" message on your screen.) I'm looking into why this might be and how to change it. Also still need to figure out how to assign different classes and such.

          Anyway, here's my code:

          Gametype:
          Code:
          class HuntedMod extends xBombingRun;
          
          var HM_Flag hmFlag;
          
          function PostBeginPlay()
          {
              Super.PostBeginPlay();
              Log("HuntedMod.uc");
          }
          
          function StartMatch()
          {
              local Controller C;
          
              Super.StartMatch();
              
              Log("HM: Starting match");
          
              hmFlag = Spawn(class'HM_Game.HM_Flag');
          
              for ( C=Level.ControllerList; C!=None; C=C.nextController )
              {
                  Log("HM: C - "@C);
                  if ( (C.PlayerReplicationInfo != None) && !C.PlayerReplicationInfo.bOnlySpectator )
                  {
                      if ( C.Pawn != None )
                      {
                          
                          //player = PlayerController(C);
                          Log("HM: Attempting to set flag holder to Controller");
                          hmFlag.SetHolder(C);
                          break;
                      }
                  }
              }
              
              if(hmFlag.Holder == None)
              {
                  Log("HM: No one is the Hunted");
              }else{
                  Log("HM: The Hunted exists!");
              }
          }
          
          defaultproperties
          {
          	bDefaultTranslocator=false
          	bAllowTrans=false
              bScoreTeamKills=False
              bWeaponStay=true
              bSpawnInTeamArea=true
              BeaconName="BR"
              //BeaconName="HNT"
              GameName="Hunted"
              //HUDType="XInterface.HudCBombingRun"
              HUDType="HM_GUI.HM_HuntedHUD"
              GoalScore=15
              MapPrefix="BR"
              //MapPrefix="HNT"
              MapListType="XInterface.MapListBombingRun"
              //MapListType="Hunted.HuntedMapList"
              ADR_Kill=2.0
          	DefaultEnemyRosterClass="xGame.xTeamRoster"
          	 bMustHaveMultiplePlayers=false
          
              PlayerControllerClass=Class'HM_Player'
              PlayerControllerClassName="HM_Player"
              //GameReplicationInfoClass=Class'HuntedGameReplicationInfo'
          
              DeathMessageClass=class'XGame.xDeathMessage'
              ResetTimeDelay=11
          
              TeamAIType(0)=class'UnrealGame.BombingRunTeamAI'
              TeamAIType(1)=class'UnrealGame.BombingRunTeamAI'
              bTeamScoreRounds=false
          
              ScreenShotName="UT2004Thumbnails.BRShots"
              DecoTextName="XGame.BombingRun"
          
              Acronym="HNT"
          
          	OtherMesgGroup="BombingRun"
          
          	BRPropText="Delay ball contact"
          	BRDescText="If checked, a player must wait a few seconds after throwing the ball before picking it up again."
          
          	// bBallDrainsTransloc=true
          	// BRPropText2="BallLauncher drains Translocator"
          	// BRDescText2="If checked, a player must wait a few seconds after throwing the ball before being able to translocate (or until someone else catches or picks up the ball)."
          
              Description="The Hunted must get from one end of the level to the other. His or her teammates must protect them. Assassins must kill them."
          
               BRHints(0)="You can use %BASEPATH 0% to see the path to the Red Team base and %BASEPATH 1% to see the path to the Blue Team base."
               BRHints(1)="Firing the translocator sends out your translocator beacon.  Pressing %FIRE% again returns the beacon, while pressing %A:TFIRE% teleports you instantly to the beacon's location (if you fit)."
               BRHints(2)="While carrying the ball, you can target teammates by pressing %ALTFIRE%.  Pressing %FIRE% will pass the ball to the targeted teammate."
               BRHints(3)="Pressing %SWITCHWEAPON 10% after tossing the Translocator allows you to view from its internal camera."
               BRHints(4)="Pressing %FIRE% while your %ALTFIRE% is still held down after teleporting with the translocator will switch you back to your previous weapon."
          }
          Custom game object:
          Code:
          class HM_Flag extends GameObject;
          
          // State transitions
          function SetHolder(Controller C)
          {
              local BombingRunSquadAI S;
              local Pawn P;
          
              // update AI before changing states
              if ( Bot(C) != None )
                  S = BombingRunSquadAI(Bot(C).Squad);
              else if ( (PlayerController(C) != None) && (UnrealTeamInfo(C.PlayerReplicationInfo.Team).AI != None) )
              {
                  S = BombingRunSquadAI(UnrealTeamInfo(C.PlayerReplicationInfo.Team).AI.FindHumanSquad());
                  if ( S != None && S.SquadLeader != C )
                      S = None;
              }
              if ( S != None )
                  S.BombTakenBy(C);
          
              Super.SetHolder(C);
              Instigator = Holder;
              //bThrownBomb = false;
              Level.Game.GameReplicationInfo.FlagTarget = None;
          
              P = C.Pawn;
              if (P==None)
                  return;
          
              Log("HM: Gave the flag to the Hunted");
          }
          
          defaultproperties
          {
              bStatic=False
          	GameObjBone=FlagHand
              MaxDropTime=25.f
              Physics=PHYS_None
          	bUseCylinderCollision=true
          	bAlwaysZeroBoneOffset=true
          	bIgnoreVehicles=true
              MessageClass=class'HM_Game.HM_HuntedFlagMessage'
          }

          Comment

          Working...
          X