Trying to make a simple announcer mod

Discussions about Coding and Scripting
Post Reply
User avatar
LDinos
Novice
Posts: 15
Joined: Mon Aug 15, 2022 5:40 am
Contact:

Trying to make a simple announcer mod

Post by LDinos »

Hello, very beginner of unreal script, so maybe I don't even know what I am doing and I can't find what's wrong with my code.
My idea: I wanted to make a simple announcer mutator where it will say "triple kill", "ludicrous kill", "holy shit".

First and foremost, I made a ExtendedAnnouncer.uax file adding all the announcement sounds that I need (from doublekill until holy shit)

Then I made the folders LDinosAnnouncerMod -> Classes -> ExtendedAnnouncer.uc and this is the code:

Code: Select all

class ExtendedAnnouncer extends MultiKillMessage;
#exec OBJ LOAD FILE=..\Sounds\ExtendedAnnouncer.uax

var(Messages) localized string MegaKillString;
var(Messages) localized string LudKillString;
var(Messages) localized string HolyshitKillString;

static function string GetString( optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
{
  switch( Switch )
  {
    case 0:  return "";
       break;
    case 1:  return default.DoubleKillString;
       break;
   case 2:  return default.TripleKillString;
       break;
    case 3:  return default.MultiKillString;
       break;
    case 4:  return default.MegaKillString;
       break;
    case 5:  return default.UltraKillString;
       break;
    case 6: return default.MonsterKillString;
     break;
     case 7: return default.LudKillString;
     break;
    default: return default.HolyshitKillString;
       break;
  }
}

static simulated function ClientReceive( PlayerPawn P, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
{
  super( LocalMessagePlus ).ClientReceive( P, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );

  switch( Switch )
  {
    case 0:  break;
    case 1:  P.ClientPlaySound( sound'ExtendedAnnouncer.DoubleKill', , true );
       break;
    case 2:  P.ClientPlaySound( sound'ExtendedAnnouncer.TripleKill', , true );
       break;
    case 3:  P.ClientPlaySound( sound'ExtendedAnnouncer.MultiKill', , true );
       break;
    case 4:  P.ClientPlaySound( sound'ExtendedAnnouncer.MegaKill', , true );
       break;
    case 5:  P.ClientPlaySound( sound'ExtendedAnnouncer.UltraKill', , true );
       break;
    case 6:  P.ClientPlaySound( sound'ExtendedAnnouncer.MonsterKill', , true );
       break;
    case 7:  P.ClientPlaySound( sound'ExtendedAnnouncer.ludicrousKill', , true );
       break;
    default: P.ClientPlaySound( sound'ExtendedAnnouncer.holyshit', , true );
       break;
  }
}

defaultproperties
{
    MegaKillString="MEGA KILL!!"
    LudKillString="L U D I C R O U S  K I L L ! ! !"
    HolyshitKillString="H O L Y  S H I T ! ! ! "
}
Then, I used UMake, and it created LDinosAnnouncerMod.u, and I created LDinosAnnouncerMod.int myself with this code

Code: Select all

[Public]

Object=(Name=LDinosAnnouncerMod.ExtendedAnnouncer,Class=Class,MetaClass=Engine.Mutator,Description="Extended Announcer Mod")
All good so far, I open the game, insert my mutator before joining a map, but nothing really changes. The announcer says the default phrases. What am I doing wrong?
User avatar
ExpEM
Adept
Posts: 298
Joined: Wed Nov 09, 2016 1:48 am

Re: Trying to make a simple announcer mod

Post by ExpEM »

The first problem appears to be that you haven't actually made a mutator.
It only shows up in your mutator list because of the int file you made but if you check your log you should see some error messages along the lines of "blah blah file not found".

I'll let you figure out where to go from here with a hint, you need to create a Mutator that will call your ExtendedAnnouncer for the game to use.
Signature goes here.
User avatar
LDinos
Novice
Posts: 15
Joined: Mon Aug 15, 2022 5:40 am
Contact:

Re: Trying to make a simple announcer mod

Post by LDinos »

I see, so I need to make a different file (say ExtendedAnnouncerMut) that needs to be the mutator that will initiate the announcer, right? However I am bit lost with all this and I am not sure how to initiate such a thing. If it was a weapon replacement mutator or something similar, I could have taken some ideas from the other existing mutators, but now I am confused on what function I need to use to deploy my announcer through my mutator. Do I just need to put an event with a "Spawn(class'ExtendedAnnouncer')" inside of it? Again, sorry if the question is very noobish :)
User avatar
OjitroC
Godlike
Posts: 3605
Joined: Sat Sep 12, 2015 8:46 pm

Re: Trying to make a simple announcer mod

Post by OjitroC »

Perhaps have a look at anth's 2k4Sounds? This changes some of the announcer sounds.
User avatar
TankBeef
Masterful
Posts: 585
Joined: Tue Apr 13, 2021 12:56 am

Re: Trying to make a simple announcer mod

Post by TankBeef »

Proasm.com has done something like this with the SmartSB. Maybe check that one too.
User avatar
LDinos
Novice
Posts: 15
Joined: Mon Aug 15, 2022 5:40 am
Contact:

Re: Trying to make a simple announcer mod

Post by LDinos »

Thanks for your help guys! I managed to do it. In total I made three files and here is the code for each of them

ExtendedAnnouncer.uc

Code: Select all

class ExtendedAnnouncer extends MultiKillMessage;
#exec OBJ LOAD FILE=..\Sounds\ExtendedAnnouncer.uax

var(Messages) localized string MegaKillString;
var(Messages) localized string LudKillString;
var(Messages) localized string HolyshitKillString;

event PostBeginPlay() {
   Super.PostBeginPlay(); 
}

static function string GetString( optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
{
  switch( Switch )
  {
    case 0:  return "";
       break;
    case 1:  return default.DoubleKillString;
       break;
   case 2:  return default.TripleKillString;
       break;
    case 3:  return default.MultiKillString;
       break;
    case 4:  return default.MegaKillString;
       break;
    case 5:  return default.UltraKillString;
       break;
    case 6: return default.MonsterKillString;
     break;
     case 7: return default.LudKillString;
     break;
    default: return default.HolyshitKillString;
       break;
  }
}

static simulated function ClientReceive( PlayerPawn P, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
{
  super( LocalMessagePlus ).ClientReceive( P, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );

  switch( Switch )
  {
    case 0:  break;
    case 1:  P.ClientPlaySound( sound'ExtendedAnnouncer.DoubleKill', , true );
       break;
    case 2:  P.ClientPlaySound( sound'ExtendedAnnouncer.TripleKill', , true );
       break;
    case 3:  P.ClientPlaySound( sound'ExtendedAnnouncer.MultiKill', , true );
       break;
    case 4:  P.ClientPlaySound( sound'ExtendedAnnouncer.MegaKill', , true );
       break;
    case 5:  P.ClientPlaySound( sound'ExtendedAnnouncer.UltraKill', , true );
       break;
    case 6:  P.ClientPlaySound( sound'ExtendedAnnouncer.MonsterKill', , true );
       break;
    case 7:  P.ClientPlaySound( sound'ExtendedAnnouncer.ludicrousKill', , true );
       break;
    default: P.ClientPlaySound( sound'ExtendedAnnouncer.holyshit', , true );
       break;
  }
}

defaultproperties
{
    MegaKillString="MEGA KILL!!"
    LudKillString="L U D I C R O U S  K I L L ! ! !"
    HolyshitKillString="H O L Y  S H I T ! ! ! "
}
ExtendedDeathMessage.uc

Code: Select all

class ExtendedDeathMessage extends DeathMessagePlus;

static function ClientReceive (PlayerPawn P, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject)
{
  local string MultiStr;

  if ( RelatedPRI_1 == P.PlayerReplicationInfo )
  {
    if ( TournamentPlayer(P).myHUD != None )
    {
      TournamentPlayer(P).myHUD.LocalizedMessage(Default.ChildMessage,Switch,RelatedPRI_1,RelatedPRI_2,OptionalObject);
      TournamentPlayer(P).myHUD.LocalizedMessage(Default.Class,Switch,RelatedPRI_1,RelatedPRI_2,OptionalObject);
    }
    if ( Default.bIsConsoleMessage )
    {
      TournamentPlayer(P).Player.Console.AddString(GetString(Switch,RelatedPRI_1,RelatedPRI_2,OptionalObject));
    }
    if ( (RelatedPRI_1 != RelatedPRI_2) && (RelatedPRI_2 != None) )
    {
      if ( (TournamentPlayer(P).Level.TimeSeconds - TournamentPlayer(P).LastKillTime < 3) && (Switch != 1) )
      {
        TournamentPlayer(P).MultiLevel++;
        TournamentPlayer(P).ReceiveLocalizedMessage(Class'ExtendedAnnouncer',TournamentPlayer(P).MultiLevel,RelatedPRI_1);
      } else {
        TournamentPlayer(P).MultiLevel = 0;
      }
      TournamentPlayer(P).LastKillTime = TournamentPlayer(P).Level.TimeSeconds;
    } else {
      TournamentPlayer(P).MultiLevel = 0;
    }
    if ( ChallengeHUD(P.myHUD) != None )
    {
      ChallengeHUD(P.myHUD).ScoreTime = TournamentPlayer(P).Level.TimeSeconds;
    }
  } else {
    if ( RelatedPRI_2 == P.PlayerReplicationInfo )
    {
      TournamentPlayer(P).ReceiveLocalizedMessage(Class'VictimMessage',0,RelatedPRI_1);
      Super(LocalMessage).ClientReceive(P,Switch,RelatedPRI_1,RelatedPRI_2,OptionalObject);
    } else {
      Super(LocalMessage).ClientReceive(P,Switch,RelatedPRI_1,RelatedPRI_2,OptionalObject);
    }
  }
}
ExtendedAnnouncerMut.uc

Code: Select all

class ExtendedAnnouncerMut extends Mutator;

event PostBeginPlay()
{
    Level.Game.DeathMessageClass = Class'ExtendedDeathMessage';
    log("Extended Announcer mode initialized");
}

The trick was to look into DeathMessagePlus and use my class there :)

Here it is in action: https://cdn.discordapp.com/attachments/ ... /hlsht.mp4
Post Reply