1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Script question: is it ok to change values in the GRI?

Discussion in 'Unreal 2' started by takwu, May 25, 2004.

Thread Status:
Not open for further replies.
  1. takwu

    takwu cXp coder Tak®

    Joined:
    Feb 5, 2004
    Messages:
    614
    Likes Received:
    0
    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 :eek:
     
  2. [GDC]Faust

    [GDC]Faust Goblin Hunter

    Joined:
    Apr 29, 2004
    Messages:
    314
    Likes Received:
    0
    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! ;-)
     
  3. takwu

    takwu cXp coder Tak®

    Joined:
    Feb 5, 2004
    Messages:
    614
    Likes Received:
    0
    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: May 26, 2004
  4. [GDC]Faust

    [GDC]Faust Goblin Hunter

    Joined:
    Apr 29, 2004
    Messages:
    314
    Likes Received:
    0
    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
    }
    
     
  5. takwu

    takwu cXp coder Tak®

    Joined:
    Feb 5, 2004
    Messages:
    614
    Likes Received:
    0
    thx :D 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.
     
Thread Status:
Not open for further replies.

Share This Page