Team effects in Monsterhunt

Discussions about Coding and Scripting
User avatar
Barbie
Godlike
Posts: 2925
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Team effects in Monsterhunt

Post by Barbie »

I messed around with this for weeks but I didn't find a working solution yet: For my Monsterhunt server I would like if the players can use the visual and acoustical effects like in team games - different colors for skin, HUD, the Glow of TranslocatorTarget :lol: (and everything else that have not come to my mind in this moment). The matching voice effects ("Red leader, I'm in position", "Blue leader...", ...) would be nice also. Furthermore the client should store this team assignment persistently and restores it at login.

I tried different approaches:
1) Just use the "real" team (0-3) instead of the team 0 that is usually used in MH. But there I have to hack the damage code including teleport fragging, "repair" enemy seeking rockets and probably some more stuff. Because I guess there are lots of maps outside that rely on players team=0 (eg TeamMonsters.u) this would break compatibility also. Bad approach.
2) Introducing a new storage ("VirtualTeam") for the team the player has chosen. Setting player's skin to that virtual team color is no problem in function AddToTeam() of a subclassed GameInfo. In the beginning I've put this variable "VirtualTeam" into a sub class of PlayerReplicationInfo and this has worked so far - with the disadvantage that this information is lost after logout (what happens with every map change). Because I need code to store the content of that variable at the client - preferably in USER.INI -, I decided to create a sub class of ReplicationInfo ("PlayerClientInfoSB") and have my stuff there instead of in PlayerReplicationInfoSB directly. PlayerReplicationInfoSB then only holds a reference to that class. But I didn't get it managed to store the VirtualTeam number in client's USER.INI nor having a manual set value replicated to server.

I followed these instructions: https://wiki.beyondunreal.com/Legacy:Ne ... _Variables and studied https://wiki.beyondunreal.com/Legacy:Re ... d_Function and nearly all stuff that is referenced by https://wiki.beyondunreal.com/Legacy:Replication.

Does anyone have a complete different idea to gain this? Or hints what is wrong with my code? (The code might be a bit messy because I tried many different variations.)
PlayerClientInfoSB

Code: Select all

class PlayerClientInfoSB expands ReplicationInfo config(User);

var byte VirtualTeam; // if Player switches team he will stay in Team=0 but *VirtualTeam* is set to new team number. This can be used for visual/acustical effects.
var config byte LastVirtualTeam; // local store for *VirtualTeam*
var bool bVirtualTeamChangeAllowed; // used by MonsterHuntSB.ChangeTeam(): if not allowed, team is not changed. MonsterHuntSB.PostLogin() sets this to TRUE and changes team then.


replication {
	reliable if ( Role == ROLE_Authority )
		VirtualTeam;
	reliable if (Role < ROLE_Authority)
		TeamChanged;
}


simulated function TeamChanged() { // this is executed on server but was never executed on client
	if ( ! bVirtualTeamChangeAllowed)
		return;
	LastVirtualTeam = VirtualTeam;
	//if (Role < ROLE_Authority)
	if (Level.NetMode != NM_DedicatedServer) // only client should save it
		SaveConfig();
}


static function bool PlayerClientInfoHave(Pawn Other, out PlayerClientInfoSB PCISB) {
/******************************************************************************
Just a shortcut for the wall of text for type casting.
Returns TRUE if *Other* has a *PlayerClientInfoSB* and sets *PCISB* to it.
******************************************************************************/
	if (Other.PlayerReplicationInfo != None)
		if (PlayerReplicationInfoSB(Other.PlayerReplicationInfo) != None)
			if (PlayerReplicationInfoSB(Other.PlayerReplicationInfo).PCISB != None)
			{
				PCISB = PlayerReplicationInfoSB(Other.PlayerReplicationInfo).PCISB;
				return true;
			}
	return false;
}


simulated function PostBeginPlay() { // by logging I found this is executed on server and client
	if (Role == ROLE_Authority)
		VirtualTeam = LastVirtualTeam;
	Super.PostBeginPlay();
}

defaultproperties {
	bVirtualTeamChangeAllowed=false
}
PlayerReplicationInfoSB

Code: Select all

class PlayerReplicationInfoSB expands PlayerReplicationInfo;
var PlayerClientInfoSB PCISB;
MonsterHuntSB

Code: Select all

class MonsterHuntSB expands TeamGamePlus config(BarbiesWorld);

function AddToTeam(int num, Pawn Other) {
const CMHTeamNum = 0;
local Pawn P;
local bool bSuccess;
local string SkinName, FaceName;
local PlayerClientInfoSB PCISB;

	if (Other == None)
	{
		warn("Added NONE to team" @ num);
		return;
	}

	if (Class'PlayerClientInfoSB'.static.PlayerClientInfoHave(Other, PCISB))
	{
		if (PCISB.bVirtualTeamChangeAllowed)
		{
			if (PCISB.VirtualTeam != num)
			{
				PCISB.VirtualTeam = num;
				PCISB.TeamChanged();
			}
		}
		else
			return;
	}
	else
		warn("PlayerReplicationInfoSB(Other.PlayerReplicationInfo).PCISB == None");
...
}

event PostLogin(playerpawn NewPlayer) {
local PlayerClientInfoSB PCISB;

	Super.PostLogin(NewPlayer);

	if (NewPlayer == None)
		Return;

	// if PCISB does not exist, create it
	if ( ! Class'PlayerClientInfoSB'.static.PlayerClientInfoHave(NewPlayer, PCISB))
		PlayerReplicationInfoSB(NewPlayer.PlayerReplicationInfo).PCISB = Spawn(Class'PlayerClientInfoSB', NewPlayer);

	// check again if PCISB exists now:
	if (Class'PlayerClientInfoSB'.static.PlayerClientInfoHave(NewPlayer, PCISB))
	{
		PCISB.bVirtualTeamChangeAllowed = true;
		ChangeTeam(NewPlayer, PCISB.VirtualTeam);
	}
}
"If Origin not in center it be not in center." --Buggie
User avatar
EvilGrins
Godlike
Posts: 10214
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA

Re: Team effects in Monsterhunt

Post by EvilGrins »

You are aware there's a, admittedly underused, TeamMonsterHunt gametype?

Google it, you'll need the mod.

Also, future reference, screenshots are helpful when trying to discuss what your progress is on any type of visual content.
Spoiler
Image
Last edited by EvilGrins on Thu Feb 04, 2016 1:05 am, edited 1 time in total.
JackGriffin
Godlike
Posts: 3776
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Team effects in Monsterhunt

Post by JackGriffin »

You need to talk to nelsona. I worked for years on this and could never get it right. He did though (that bastard).
So long, and thanks for all the fish
User avatar
Barbie
Godlike
Posts: 2925
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Team effects in Monsterhunt

Post by Barbie »

Screenshot? No problem:
ColoredSkins.jpg
EvilGrins wrote:TeamMonsterHunt gametype
A quick search showed that TMH has two "real" teams whose members are enemies. My aim is to have all players and bots in one team as usual in MH.
You do not have the required permissions to view the files attached to this post.
"If Origin not in center it be not in center." --Buggie
JackGriffin
Godlike
Posts: 3776
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Team effects in Monsterhunt

Post by JackGriffin »

You have to be careful though because many MH mods work on the assumption that all players will be on red team. Adding new teams will break replication, allow players to kill each other, mess up scoring, etc.
So long, and thanks for all the fish
User avatar
sektor2111
Godlike
Posts: 6438
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Team effects in Monsterhunt

Post by sektor2111 »

Team effect is 0 Zero if you allow SKIN changes NOT TEAM changes (that is nasty and might be more work for this goal).
Hint: You might have a better eye than me when is about figuring differences between DeathMatchPlus to TeamGamePlus and just get rid of skin changes and put player on team 0 with original skin ignoring relation with team. Looks like a half of job is done with an issue to be solved: Player switching from Blue to Gold (or any combination) color seems to lose all score instantly, but skin is happily changed and no problem with Damage or Bot getting mad at blue player or green player. There is a little fine tuning to do and is functional without to mock a crap-ton of new things.

Given affinity for team 0 but skins from any kind monsters used by me are team 3 just preserving a proper hate. If they are team 2 and used in a CTF match, they help Blues. In a DeathMatchPlus they attack everything more evilized than Berserker which tends to ignore a pupae. So to speak think at monsters as well and leave alone Team, SKIN is the key not Team. YOu can preserve skin for player in some actor tracker (I recommend to forget other replications - or you might see conflicts with maps having sort of nasty mods implemented) - follow default rules... But preventing TeamGamePlus to mess with a stupid link with team and skin as it does in default. In this case Cannons won't attack only 2 players ignoring other 3 and the same for monsters instructed to use team rules.

Just thoughts, you can break everything as you like if you consider that your way is better...

I was planning in future to do some map with other universal monsters (compatible DM, CTF, MH, ect fixed) but if you wanna change default teams making a team-soup this will be a no go, so I'm quit thinking then. I was working to solve attitude code at monster and writing even some educative code for Bot and this is about to go in trash when goes to blabbering teams. Of course years ago was some sort of idiot ( you'll see why, I cannot define a better term) which coded a package where a TeamCannon on team 0 is hunting players from team 0 ignoring team rules and doing a mess. I'll wipe my a$$ with that package and I'll put back team rules even causing a mismatch because I'm not agree with such bullshit :wth: . Even if he read this topic I don't give a fart on his opinion as long as what he did is pointless and retarded :loool: , or I'll replace those Cannons with proper classes just because if we love Cannons on Team 0, well... they won't attack hunters.

In default MH with setup to not use TeamColor ( is bugged anyway ) Bots are entering the game with their default skins with 0 problems - go figure what is messing up player. Actually at a Level change default MH will drop player skin back to RED. Or use a team change function which won't change anything but to allow Skin change.
I might do a check around again, perhaps I'll solve scoring thing issue.
JackGriffin wrote:I worked for years on this and could never get it right. He did though (that bastard).
And you can keep going because it doesn't bite anyone. You quit too easy and too fast. AND MH needs patience and love and ect. - and Skaarj (almost to forget)... and understanding difference between a hacked thing and a fixed one (recalling ReplaceWith related speech), and You know that UT needs HACKS to work correctly which I call PATCHES for elegance and comfortable feelings (imagine a beautiful colored butterfly sh!ting on a dirty bug - bug being in any meaning). This is how MH works needs to be done.
Keep moving, Barbie!
Letylove49
Adept
Posts: 282
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse

Re: Team effects in Monsterhunt

Post by Letylove49 »

with Nexgen112N if your setting usecolorteam is disable that will take your setting of the hud on Monsterhunt gametype. but your team will stay to red and your nick will be display to red.
Image





Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2925
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Team effects in Monsterhunt

Post by Barbie »




Thanks, but I solved that years ago. :lol2:
"If Origin not in center it be not in center." --Buggie
User avatar
papercoffee
Godlike
Posts: 10510
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: Team effects in Monsterhunt

Post by papercoffee »

:wth:

We should really start locking automatically Threads inactive and older than 4 years.

=CLOSED=