NewsUnrealEdFilesModsFragBULiandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > BeyondUnreal > Games > Unreal Series > Unreal 2

Closed Thread
 
Thread Tools Display Modes
Old 25th May 2004, 09:08 PM   #1
takwu
cXp coder Tak®
 
takwu's Avatar
 
Join Date: Feb. 5th, 2004
Posts: 614
Question Script question: is it ok to change values in the GRI?

Ok, first of all a bit of why: there's no gametype in XMP (I have no idea what AsteroidGame is doing there). GameRules seem to do nothing useful (generic dm stuff, nothing about artifacts?). I want to change the rules just a little bit, so even if gametype is avail I'm not sure if i want to use it, and get no server to host it.

Now, I'm not trying to change the structure of the GRI, just want to change the values of the variables in it as I see fit. I really have no idea about all this replication stuff... and reading about all those warnings on tuts just makes me more confused. so the question is, if I just change something in Level.Game.GRI, is it ok??

Another related question would be other vars in Level.Game, is it ok to change them directly too?

I just started learning UScript for a week or two, so excuse me
takwu is offline  
Old 26th May 2004, 03:46 AM   #2
[GDC]Faust
Goblin Hunter
 
[GDC]Faust's Avatar
 
Join Date: Apr. 29th, 2004
Posts: 314
I wouldn't change them if I where you... you would have to make new .u-files and then have version-mismatches everywhere you go. But the Gamerules-class can be used for additional editing (see the friendlyfire-mutator for how it's done).

But I would say that you better try something a bit more easy for a first mutator! ;-)
__________________
_____________________________
Grids are for girlies!
[GDC]Faust is offline  
Old 26th May 2004, 04:01 AM   #3
takwu
cXp coder Tak®
 
takwu's Avatar
 
Join Date: Feb. 5th, 2004
Posts: 614
hmm, the friendlyfire mutator... is it the one by crokx? I thought the source is not available. i'd love to look at that... and for that matter any source of any xmp mutator, hehe.

as for me writting mutator... I looked into that, but couldn't figure out a way to do some stuff. for example if using replacewith(), all configurable var() seem to have lost their data and got default values instead. i'm currently trying to work it thru placing those actors in the map in the first place and configuring them there instead of replacing them thru a mutator at checkreplacement().

man i sound like a headless chicken, lol

Last edited by takwu; 26th May 2004 at 05:04 AM.
takwu is offline  
Old 26th May 2004, 06:07 AM   #4
[GDC]Faust
Goblin Hunter
 
[GDC]Faust's Avatar
 
Join Date: Apr. 29th, 2004
Posts: 314
Yeah, the replacewith-function has some issues in XMP imho... as for the source of the friendlyfire-mut: (I hope I'm not gettin' in trouble here, but I didn't change anything, so it should be ok)

Code:
//=============================================================================
// TypeKilling and Friendly fire Mutator. Author: -=Musc@t=-
// Write type killing, Friendly Fire informations in your server's log and show up a message on the screen.
//=============================================================================

class FriendlyFireMut extends Mutator;


function PostBeginPlay()
{
   local GameRules G;

	Super.PostBeginPlay();

	G = Spawn( class'FriendlyFire107nc.FriendlyFireGameRules' );
	if( Level.Game.GameRulesModifiers == None )
		Level.Game.GameRulesModifiers = G;
	else
		Level.Game.GameRulesModifiers.AddGameRules( G );

}
//
// server querying
//
function GetServerDetails( out GameInfo.ServerResponseLine ServerState )
{
	local int i;
	local class<FriendlyFireGameRules> G;

	G = class'FriendlyFire107nc.FriendlyFireGameRules';
	
	i = ServerState.ServerInfo.Length;
	ServerState.ServerInfo.Length = i+6;
	ServerState.ServerInfo[i].Key = "Mutator";
	ServerState.ServerInfo[i].Value = GetHumanReadableName();
	ServerState.ServerInfo[i+1].Key = "FriendlyFire Version";
   	ServerState.ServerInfo[i+1].Value = "1.07nc";
	ServerState.ServerInfo[i+2].Key = "KickTeamKiller";
   	ServerState.ServerInfo[i+2].Value = string(G.default.bKickTeamKiller);
	ServerState.ServerInfo[i+3].Key = "MaxTeamKilling";
   	ServerState.ServerInfo[i+3].Value = string(G.default.MaxTeammateFrag);
	ServerState.ServerInfo[i+4].Key = "MinimumScore";
   	ServerState.ServerInfo[i+4].Value = string(G.default.LowerScoreLimit);
	ServerState.ServerInfo[i+5].Key = "TeamKillerDie";
   	ServerState.ServerInfo[i+5].Value = string(G.default.bTeamkillerDie);
	
   	
	
}
function bool MutatorIsAllowed()
{
	return true;
}

defaultproperties
{
	FriendlyName="FriendlyFire v107nc (no config, no log)"
	Description="This mutator Simply add type Killing and friendly fire informations in your server log and send a message to the TypeKiller, Team Killer and Killed players."
}
and further, the FriendlyFireGameRules-class:

Code:
// Show up a FriendlyFire or type killing message -=Musc@t=-


Class FriendlyFireGameRules extends GameRules;

var bool bTeamkillerDie,       //Kill TeamKiller
	 bKickTeamKiller,      //Kick TeamKiller
	 bTraitorSwitch,       //Traitor switchteam
	 bInjuredSeeMessages;  //Injured players see Team Kill messages

var int LowerScoreLimit,	// lower negative score before the Kick
	MaxTeammateFrag,        // Max Teammate frag before the Kick
	MaxTraitorFrag;         // Max Teammate frag before the switchteam

var float FriendlyFireScale;
var bool bFixTeamDamage;

function PostBeginPlay()
{
	super.PostBeginPlay();
	FriendlyFireScale = XMPGame(Level.game).TeamDamage;
	if (Level.game.Version <= 6497)
		bFixTeamDamage = True;
	else
		bFixTeamDamage = False;

}

function String RemColorCode(string name)
{
	local int i;
	
	local string tag;

	tag = "^#";

	i = InStr(name, tag);
	while (i != -1)
	{
		name = Left(name, i)$Right(name, Len(name)-i-3);
		i = InStr(name, tag);
	}

	Return name;	
}

function int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
{
	local bool bTypeKilling, bTeamKilling;
	local playercontroller P;

	bTeamKilling=False;
	bTypeKilling=False;

	if (instigatedBy != None && Damagetype != None  && instigatedBy != injured  && instigatedBy.playerReplicationInfo != None )
	{
		if ( instigatedBy.SameTeam(injured) )
		{
				if (bFixTeamDamage)
				{
					Momentum *= 0.3;
					Damage *= FriendlyFireScale;
				}
				
				if (PlayerController(instigatedBy.controller) != None )
				{
					if (FriendlyFireScale > 0)
					{
						if (injured.health > Damage && Damagetype != class'Crushed' && Damagetype != class'DamageTypeBiologicalGas' && Damagetype != class'DamageTypeImpact')
						{
							Playercontroller(instigatedBy.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',6, instigatedBy.controller.PlayerReplicationInfo);
						}
						else if (injured.Health - Damage <= 0)
						{	
							Playercontroller(instigatedBy.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',8, instigatedBy.controller.PlayerReplicationInfo);							
							bTeamKilling = true;
						}
					}
					else if (Damagetype != class'Crushed' && Damagetype != class'DamageTypeBiologicalGas' && Damagetype != class'DamageTypeImpact' )
						Playercontroller(instigatedBy.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',6, instigatedBy.controller.PlayerReplicationInfo);
					if (Damagetype == class'Crushed')
						Playercontroller(instigatedBy.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',12, instigatedBy.controller.PlayerReplicationInfo);
				}

				if (bInjuredSeeMessages && PlayerController(injured.controller) != None)
				{	
					if (FriendlyFireScale > 0)
					{
						if (injured.health > Damage && Damagetype != class'Crushed' && Damagetype != class'DamageTypeBiologicalGas' && Damagetype != class'DamageTypeImpact')
						{							
							Playercontroller(injured.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',7, injured.controller.PlayerReplicationInfo);
						}
						else if (injured.Health - Damage <= 0)
						{	
							Playercontroller(injured.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',9, injured.controller.PlayerReplicationInfo);
							bTeamKilling = true;	
						}
					}
					else if (Damagetype != class'Crushed' && Damagetype != class'DamageTypeBiologicalGas' && Damagetype != class'DamageTypeImpact')
						Playercontroller(injured.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',7, injured.controller.PlayerReplicationInfo);
					if (Damagetype == class'Crushed')
						Playercontroller(injured.controller).ReceiveLocalizedMessage(class'TkMutatorMessage',13, injured.controller.PlayerReplicationInfo);
				}
				
				if (bTeamKilling && instigatedBy.playerReplicationInfo != None && instigatedBy.controller != None)
				{	
					bTeamKilling = False;

					/*if (Playercontroller(instigatedBy.controller) != None && Playercontroller(injured.controller) != None)
						Log("--------------------------------->Killer:"$RemColorCode(instigatedBy.GetPlayerName())$"   Killed:"$RemColorCode(injured.GetPlayerName()),'TEAM KILLING');
					else if (Playercontroller(instigatedBy.controller) == None && Playercontroller(injured.controller) != None)
						Log("-------------(Bot)--------------->Killer: It's a bot   Killed:"$RemColorCode(injured.GetPlayerName()),'TEAM KILLING');
					else if (Playercontroller(instigatedBy.controller) != None && Playercontroller(injured.controller) == None)
						Log("-------------(Bot)--------------->Killer:"$RemColorCode(instigatedBy.GetPlayerName())$"   Killed: It's a bot",'TEAM KILLING');
					else 
						Log("-------------(Bot)--------------->Killer: It's a bot   Killed: It's a bot",'TEAM KILLING');*/

					P = playercontroller(instigatedBy.controller);
					// StatPlrScore[37] is the teammate killing score
					
					if (bKickTeamKiller && (P.PlayerReplicationInfo.score <= LowerScoreLimit || P.PlayerReplicationInfo.StatPlrScore[37] >= MaxTeammateFrag))
					{
						/*Log("--------------------------------->Kicked: "$RemColorCode(instigatedBy.GetPlayerName())$"   Score: "$P.PlayerReplicationInfo.score$"   IP: "$P.GetPlayerNetworkAddress(),'TEAM KILLING');*/
						Level.Game.BroadcastDeathMessage(injured.Controller, instigatedBy.Controller, class'DamTypeKicked');
						Level.Game.Kick(P.PlayerReplicationInfo);
						
					}
					else if (bTraitorSwitch && P.PlayerReplicationInfo.StatPlrScore[37] == MaxTraitorFrag)
					{
						P.ReceiveLocalizedMessage(class'TkMutatorMessage',11, instigatedBy.controller.PlayerReplicationInfo);
						Level.Game.BroadcastDeathMessage(injured.Controller, instigatedBy.Controller, class'DamTypeTraitor');
						if ( (P.PlayerReplicationInfo.Team == None) || (P.PlayerReplicationInfo.Team.TeamIndex == 1) )
							P.ChangeTeam(0);
						else
							P.ChangeTeam(1);
						P.PlayerReplicationInfo.StatPlrScore[37] = MaxTraitorFrag+1;
					}
					else if (bKickTeamKiller && P.PlayerReplicationInfo.StatPlrScore[37] == MaxTeammateFrag-1)
						P.ReceiveLocalizedMessage(class'TkMutatorMessage',10, instigatedBy.controller.PlayerReplicationInfo);

					Level.Game.BroadcastDeathMessage(injured.Controller, instigatedBy.Controller, class'DamTypeTeamKilling');
					if (bTeamKillerDie)
					{
						P.suicide();
					}
				}
				
		}	
	}
	if ( NextGameRules != None )
		return NextGameRules.NetDamage( OriginalDamage,Damage,injured,instigatedBy,HitLocation,Momentum,DamageType );
	return Damage;
}

defaultproperties
{
	bKickTeamKiller=True
	bInjuredSeeMessages=True
	LowerScoreLimit=-2000
	MaxTeammateFrag=5
	MaxTraitorFrag=3
}
__________________
_____________________________
Grids are for girlies!
[GDC]Faust is offline  
Old 26th May 2004, 01:05 PM   #5
takwu
cXp coder Tak®
 
takwu's Avatar
 
Join Date: Feb. 5th, 2004
Posts: 614
thx this code is cool.
So this gamerules mainly changes the damage inflicted on a player, ok.
But it seems the gamerules has nothing to do with XMP specific stuff at all. It seems to be designed genericly for all gametypes in UT or something. It would be nice if they subclass the base gamerules class for each gametype so we can write specific rules.
Thx Faust, I'll keep digging into this stuff, hehe.
takwu is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer