[Solved]HolywarsNexgenHudFix

Discussions about Coding and Scripting
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

[Solved]HolywarsNexgenHudFix

Post by Letylove49 »

I'm trying to make a fix for the "HolyWars" game mode but I get a fatal error when I try to compile. Somone can help me to understand why i got this error ? what i have forgot ?

here the sceehsot for see what i'm trying to fix :
Shot00219.png
the color must be :
Gold for the saint
Red for the Heretic
Blue for the player ( default color on this game type)

Code: Select all

 Class HolywarsNexgenHudFix extands HolyWarsHud;

Local class = Holywars.HolywarsGame;

Var NexgenHudColors[3]; // Colors of the Hud on Holywars Gametype.
var theSaintName;	     // Player who is the saint.
var bHeretic;           // Player who is a Hertic Loser !.
var MyName;             // Player who must kill the saint to ern the halo to become the saint.		

// Fonction set the NexgenHud

Function setNexgenHud int NexgenHudColor, NexgenHudcolorsNum;
Local Nexgenclient Client;

Check if(!Gameclass=HolyWars.HolyWarsGame & useUTHUDColor=False);


{ 

if (player == SaintName || HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).TheSaint == SaintName || HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).TheSaint == SaintName) {
		NexgenHUDColors = NexgenHudColors[0]; }
 else
if (player == bHertic || HolyPRI(PlayerOwner.PlayerReplicationInfo).bHeretic; == bHertic || HolyPRI(PlayerOwner.PlayerReplicationInfo).bHeretic; == bHertic) {
		NexgenHUDColors = NexgenHudColors[1];}
 else
 if (player == MyName || PlayerOwner.PlayerReplicationInfo.PlayerName== MyName || PlayerOwner.PlayerReplicationInfo.PlayerName== MyName ){
		NexgenHUDColors = NexgenHudColors[2];}
else 
¨let the others mutators do their job.}
          

 
}


/***************************************************************************************************
 *
 *  $DESCRIPTION  Default properties block.
 *
 **************************************************************************************************/

defaultproperties
{
NexgenHudColors[0] GoldColor=(R=255,G=255)
NexgenHudColors[1] RedColor=(R=255)
NexgenHudColors[2] BlueColor=(B=255)	
version=1.00
versionCode=1
PackageName="HolywarsNexgenHudFix"
Author Letylove49
} 

Code: Select all

 Heading: --------------------HolyWars--------------------
Heading: --------------------NexgenCC--------------------
Heading: --------------------Nexgen112SDL--------------------
Heading: --------------------HolywarsNexgenHudFix--------------------
Warning: Failed to load 'HolywarsNexgenHudFix.u': Can't find file 'HolywarsNexgenHudFix.u'
Warning: Failed loading package: Can't find file 'HolywarsNexgenHudFix.u'
Log: Analyzing...
Log: FactoryCreateText: Class with ClassFactoryUC (0 1 ..\HolywarsNexgenHudFix\Classes\HolywarsNexgenHudFix.uc)
Critical: UClassFactoryUC::FactoryCreateText
Critical: UFactory::StaticImportObject
Critical: UMakeCommandlet::Main
Exit: Executing UObject::StaticShutdownAfterError
Exit: Exiting.
Uninitialized: Name subsystem shut down
Uninitialized: Log file closed, 10/01/22 00:16:57
   

here the class HolywarsHud

Code: Select all

 //=============================================================================
// HolyWarsHUD.
//=============================================================================
class HolyWarsHUD expands ChallengeHUD;

simulated function HUDSetup(canvas canvas)
{
	local String MyName, SaintName;
	local bool bHeretic;

	Super.HUDSetup(canvas);

	MyName = PlayerOwner.PlayerReplicationInfo.PlayerName;
	bHeretic = HolyPRI(PlayerOwner.PlayerReplicationInfo).bHeretic;
	SaintName = HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).TheSaint;

	if( MyName == SaintName )
		HUDColor = GoldColor;
	else if( bHeretic )
		HUDColor = RedColor;
	else
		HUDColor = BlueColor;

	SolidHUDColor = HUDColor;
	if ( Level.bHighDetailMode )
		HUDColor = Opacity * 0.0625 * HUDColor;
}

simulated function PostRender( canvas Canvas )
{
	super.PostRender( Canvas);

	// Display HolyWars Information
	if( !PlayerOwner.bShowScores )
		DrawHolyInfo( Canvas );
}

simulated function DrawHolyInfo( canvas Canvas )
{
	local float XOffset, YOffset, XL, YL;
	local String HolyMessage, VersionMessage, MyName, SaintName;
	local bool bHaloSpawned, bHeretic;

	MyName = PlayerOwner.PlayerReplicationInfo.PlayerName;
	bHeretic = HolyPRI(PlayerOwner.PlayerReplicationInfo).bHeretic;
	SaintName = HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).TheSaint;
	bHaloSpawned = HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).bHaloSpawned;

	Canvas.Font = MyFonts.GetBigFont( Canvas.ClipX );

	if( MOTDFadeOutTime > 0 )
	{
		VersionMessage = "HolyWars"@HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).Version;
		Canvas.StrLen(VersionMessage, XL, YL);
		XOffset = (Canvas.ClipX - XL ) / 2; 
		YOffset = Canvas.ClipY - 128*Scale - 2 * YL;
		Canvas.SetPos(XOffset, YOffset);
		Canvas.DrawColor = WhiteColor;
		Canvas.DrawText(VersionMessage, False);
		
		HolyMessage = "http://www.planetunreal.com/flatware";
		Canvas.DrawColor = GoldColor;
	}	
	else if( bHeretic )
	{
		HolyMessage = "You're a Heretic, loser!";
		Canvas.DrawColor = RedColor;
	}
	else if( MyName == SaintName )
	{
		HolyMessage = "You are the saint! Go berserk!";
		Canvas.DrawColor = GoldColor;
	}
	else if( !bHaloSpawned )
	{
		HolyMessage = "Waiting for the Halo to spawn...";
		if( !PlayerOwner.PlayerReplicationInfo.bIsSpectator )
			HolyMessage = HolyMessage@"Get ready to rock...";
		Canvas.DrawColor = WhiteColor;
	}
	else if( SaintName == "" )
	{
		if( !PlayerOwner.PlayerReplicationInfo.bIsSpectator )	
			HolyMessage = "Find the Halo! Hurry!";
		else
			HolyMessage = "The Halo is free.";
		Canvas.DrawColor = GreenColor;
	}
	else
	{
		HolyMessage = SaintName@"is the Saint!";
		if( !PlayerOwner.PlayerReplicationInfo.bIsSpectator )
			HolyMessage = HolyMessage@"Kill that bastard!";
		Canvas.DrawColor = GoldColor;
	}

	Canvas.StrLen(HolyMessage, XL, YL);			// Check string's length
	XOffset = (Canvas.ClipX - XL ) / 2; 		// Center message
	YOffset = Canvas.ClipY - 128*Scale - YL;	// Place it over weaponinfo
	Canvas.SetPos(XOffset, YOffset);
	Canvas.DrawText(HolyMessage, False);
	Canvas.DrawColor = WhiteColor;

}

defaultproperties
{
} 
Last edited by Letylove49 on Fri Oct 28, 2022 11:38 pm, edited 3 times in total.
Image



Letylove49 aka Alicia
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: HolywarsNexgenHudFix

Post by Buggie »

..\HolywarsNexgenHudFix\Classes\HolywarsNexgenHudFix.uc - this file not valid unreal script file.

Look like it broken in the end:

Code: Select all

defaultproperties
{
NexgenHudColors[0] GoldColor=(R=255,G=255)
NexgenHudColors[1] RedColor=(R=255)
NexgenHudColors[2] BlueColor=(B=255)	
version=1.00
versionCode=1
PackageName="HolywarsNexgenHudFix"
Author Letylove49
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: HolywarsNexgenHudFix

Post by Letylove49 »

Buggie wrote: Fri Sep 30, 2022 11:38 pm ..\HolywarsNexgenHudFix\Classes\HolywarsNexgenHudFix.uc - this file not valid unreal script file.

Look like it broken in the end:

Code: Select all

defaultproperties
{
NexgenHudColors[0] GoldColor=(R=255,G=255)
NexgenHudColors[1] RedColor=(R=255)
NexgenHudColors[2] BlueColor=(B=255)	
version=1.00
versionCode=1
PackageName="HolywarsNexgenHudFix"
Author Letylove49
i have forgot to past the "}" wheh i have do my post here.
Image



Letylove49 aka Alicia
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: HolywarsNexgenHudFix

Post by Buggie »

It still not valid default properties.
Author Letylove49
What is that?
version=1.00
versionCode=1
PackageName="HolywarsNexgenHudFix"
This too not relevant things, which not connected with any exists fields from classes listed above.

It is not dark magic or random stuff. It is default properties.
List of know fields with specific values.
You can not write here random stuff.
Once format not fit what expected, all goes to hell.

There some lucky coincidence - compiler ignore unknown properties. If It not do so, it will be broken on first unknown field.
But now it broken of first break of format of write it.

Key value format. Split by "=".
I not see it here:
Author Letylove49
I even not know for what is that.
In best case this info throw away and not get into final package.
In worst case... Look at your first post.

Automatically merged

Oh. I just look in details...
NexgenHudColors[0] GoldColor=(R=255,G=255)
NexgenHudColors[1] RedColor=(R=255)
NexgenHudColors[2] BlueColor=(B=255)
This one not valid stuff either.
Local class = Holywars.HolywarsGame;

Var NexgenHudColors[3]; // Colors of the Hud on Holywars Gametype.
var theSaintName; // Player who is the saint.
var bHeretic; // Player who is a Hertic Loser !.
var MyName; // Player who must kill the saint to ern the halo to become the saint.
This one too.

It is completely broken file which is not unreal script.

"Local" can not appear outside function. And it serve for specify local variables. Idk what going here. Define friend class like do in C++? Define local class? Whatever, this is wrong.
Var require typename and variable name. 3 pieces, like
var int i;
It is not correct unreal script function definition:
Function setNexgenHud int NexgenHudColor, NexgenHudcolorsNum;
else
¨let the others mutators do their job.}
What is that at all?

It is like text file for humans. In best case some draft, for coder. not actual code for compiler.

You can not open text file, write in english your wishes in it
¨let the others mutators do their job
Try compile and expect this is work.

Automatically merged

If you not know how write code, you need read unreal script reference for understand formats, how what write and in which cases.

And not use compile from text files. Need use UnrealEd.
Open package with already exists class, or create new, compile it. Then after you change it. Slowly. Line-by-line. And compile after each change, which able compile. In baby steps.
Not write whole text file and try compile it. Because if you do so, compiler not able tell you where is error and what kind of it. It only can say "holy shit" and crash.
Eternity
Skilled
Posts: 166
Joined: Sat Nov 30, 2019 10:56 pm

Re: HolywarsNexgenHudFix

Post by Eternity »

Buggie wrote: Sat Oct 01, 2022 1:38 am And not use compile from text files. Need use UnrealEd.
Not write whole text file and try compile it. Because if you do so, compiler not able tell you where is error and what kind of it. It only can say "holy shit" and crash.
It is able, and always was... But not in this case, because it seems compiler doesn't even "understand" what is about to compile...
Class HolywarsNexgenHudFix extands HolyWarsHud;
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: HolywarsNexgenHudFix

Post by Buggie »

I mean, if you not know how write scripts, attempt write whole file, blindly, from scratch, goes to hell. OFC if you know what to do, you can write text files and compile them. Even blindly and from first attempt.
Even if you make few mistakes, it usually end with clear message what wrong.
But if on input such files as on first post, on output can not be something useful.

It is same as with text mistakes. if you make one mistake per word, then spell checker (or human) able understand what you mean and suggest some correction.
But if you make too many mistakes per each word, then no one, even human, not able understand what you mean.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: HolywarsNexgenHudFix

Post by sektor2111 »

Letylove49 wrote: Fri Sep 30, 2022 11:23 pm I'm trying to make a fix for the "HolyWars" game mode but I get a fatal error when I try to compile. Somone can help me to understand why i got this error ? what i have forgot ?
A lot... there are way too many lines that are not UScript - not even definitions for variables.
I read:

Code: Select all

var theSaintName;	     // Player who is the saint.
var bHeretic;           // Player who is a Hertic Loser !.
var MyName;
I'll start by turning on GUESSING mode.
Perhaps is:

Code: Select all

var name theSaintName;
var bool bHeretic;
var name MyName;
Either way bHeretic might be another name ( or string ) type based on comment pointed...
And then it turns into...

Code: Select all

var name theSaintName, Heretic, Myname; //A Single line doesn't hurt anybody and no "b"
Perhaps I won't speak about that bHeretic - as recommended in docs, "b" added would be supposed to be a "bool" variable... but now days nobody cares about conventions, all is chaos and sudden new "rules" which I don't get - this is another story and we don't need to go "off-topic" - Epic themselves ignored "conventions"...
The rest ? The rest means relations between classes and type of vars used and... THE LOGIC in making deals with them.

A mod won't work based on coder's intentions (good or bad intentions), it works based on a code syntax which are RULES for compiler that shouldn't be broken... even if result would be compiled, these must work based on logic variables, not dealing with null points and assigning something to nowhere. It's about using logs and ensuring that all are doing what they need to do and not just running codes.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: HolywarsNexgenHudFix

Post by Barbie »

I noticed this also

Code: Select all

Class HolywarsNexgenHudFix extands HolyWarsHud;
"extands" needs to be "extends" or "expands".
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: HolywarsNexgenHudFix

Post by sektor2111 »

Eternity wrote: Sat Oct 01, 2022 2:20 am It is able, and always was... But not in this case, because it seems compiler doesn't even "understand" what is about to compile...
Class HolywarsNexgenHudFix extands HolyWarsHud;
Yes noticed by Eternity but... in my opinion this is probably human format of some hybrid word between expands and extends resulting "Extands" and perhaps there could be more useless tries such as "Expends". :? Anyway - recently in forum a dude has demanded an option in compiler to ignore errors. Now try to imagine results if you will compile such a class - perhaps the dude will understand now that compiler returning errors is mandatory in coding and not just generating some trash which won't work not even by accident, when it comes to such a "source-code" - it's not even code.
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: HolywarsNexgenHudFix

Post by Letylove49 »

Barbie wrote: Sat Oct 01, 2022 10:47 am I noticed this also

Code: Select all

Class HolywarsNexgenHudFix extands HolyWarsHud;
"extands" needs to be "extends" or "expands".
yes thanks. i have don't thinking to look afer a bad expression .

Automatically merged

first thanks for your help .

I would like to make sure that this function is only used with ther gametype "Holywars" otherwise this function must not be used that's why I put a conditional function
the class is HolyWars.HolyWarsGame.

but i got this :
Error: C:\UT coding\UnrealTournament\HolywarsNexgenHudFix\Classes\HolywarsNexgenHudFix.uc(28) : Error, Unexpected 'if'

Code: Select all

Class HolywarsNexgenHudFix extends HolyWarsHud;



var name SaintName;	        // Player who is the saint.
var bool Heretic;           // Player who is a Hertic Loser !.
var name MyName;             // Player who must kill the saint to ern the halo to become the saint.
var int MaxAllowedHeresys;   // max of kill before to become a hertic.

//Holywars Colors Hud
const C_RED = 0;
const C_BLUE = 1;
const C_GOLD = 2;		
/***************************************************************************************************
 *
 *  $DESCRIPTION  set the NexgenHud for Holywars.
 *
 **************************************************************************************************/



// Fonction set the NexgenHud

Function setNexgenHUDColor( int BaseHUDColor);

// check if the game is Holywars

 if(class == HolyWars.HolyWarsGame && useUTHUDColor=False);


{ 

if (player == SaintName || HolyWarsReplicationInfo( PlayerOwner.GameReplicationInfo ).TheSaint;  {
		baseHUDColor = C_GOLD;}
 else
if (player == Hertic || HolyPRI(PlayerOwner.PlayerReplicationInfo).bHeretic; {
		baseHUDColor =  C_RED;}
 else
 if (player == MyName || PlayerOwner.PlayerReplicationInfo.PlayerName; {
		baseHUDColor =  C_BLUE;}

          
}
 



/***************************************************************************************************
 *
 *  $DESCRIPTION  Default properties block.
 *
 **************************************************************************************************/



defaultproperties
{

PackageName="HolywarsNexgenHudFix"

}  
Image



Letylove49 aka Alicia
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: HolywarsNexgenHudFix

Post by Buggie »

> Function setNexgenHUDColor( int BaseHUDColor);

This mean "define empty function setNexgenHUDColor without any body (code) inside".
So later "if" goes to class scope, not to function scope. And this appear is unexpected.

Look like you need remove semicolon and add open figure bracket.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: HolywarsNexgenHudFix

Post by Barbie »

Letylove49 wrote: Sun Oct 02, 2022 8:16 pm if(class == HolyWars.HolyWarsGame && useUTHUDColor=False);
1) if (Level.Game.IsA('HolyWarsGame')

2) If the IF condition ends with a semicolon, nothing is executed if condition is TRUE. So you should use

Code: Select all

if ((Level.Game.IsA('HolyWarsGame') && useUTHUDColor=False)
{
  ...
}

Automatically merged

Barbie wrote: Sun Oct 02, 2022 9:22 pm 1) if (Level.Game.IsA('HolyWarsGame')
I just realized that class is a HUD and IMO it is owned by player. Is Level.Game available then?
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: HolywarsNexgenHudFix

Post by Letylove49 »

Buggie wrote: Sun Oct 02, 2022 9:18 pm > Function setNexgenHUDColor( int BaseHUDColor);

This mean "define empty function setNexgenHUDColor without any body (code) inside".
So later "if" goes to class scope, not to function scope. And this appear is unexpected.

Look like you need remove semicolon and add open figure bracket.
i must remove this ( ) ?

> Function setNexgenHUDColor, int BaseHUDColor;
{ if (player == the saint) NSCHud C_GOLD;
else if (player == heretic) =NSCHud C_RED;
else NSCHud C_BLUE; }

Automatically merged

Barbie wrote: Sun Oct 02, 2022 9:28 pm
Letylove49 wrote: Sun Oct 02, 2022 8:16 pm if(class == HolyWars.HolyWarsGame && useUTHUDColor=False);
1) if (Level.Game.IsA('HolyWarsGame')

2) If the IF condition ends with a semicolon, nothing is executed if condition is TRUE. So you should use

Code: Select all

if ((Level.Game.IsA('HolyWarsGame') && useUTHUDColor=False)
{
  ...
}

Automatically merged

Barbie wrote: Sun Oct 02, 2022 9:22 pm 1) if (Level.Game.IsA('HolyWarsGame')
I just realized that class is a HUD and IMO it is owned by player. Is Level.Game available then?

I don't understand what you mean by" LevelGame" you want the gametype ?

the mod Holywars use a custum hud you can see it in my first post in section Holywarsud.
Image



Letylove49 aka Alicia
Buggie
Godlike
Posts: 2697
Joined: Sat Mar 21, 2020 5:32 am

Re: HolywarsNexgenHudFix

Post by Buggie »

Letylove49 wrote: Mon Oct 03, 2022 10:53 am i must remove this ( ) ?
Buggie wrote: Sun Oct 02, 2022 9:18 pm Look like you need remove semicolon and add open figure bracket.
https://en.wikipedia.org/wiki/Semicolon
Letylove49 wrote: Mon Oct 03, 2022 10:53 am I don't understand what you mean by" LevelGame" you want the gametype ?
Level.Game always None on client side.
HUD spawn and exists on client-side. So Level.Game always None.
User avatar
Deepu
Adept
Posts: 350
Joined: Mon Nov 11, 2013 7:56 am
Personal rank: Average
Location: India
Contact:

Re: HolywarsNexgenHudFix

Post by Deepu »

Write the code related to owner's hud color, Nexgen just checking for the team colors only.
Post Reply