logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How should UnrealShare.CoopGame.AddDefaultInventory depend on Level.DefaultGameType? (Read 815 times)
Masterkent
Developer Team
Offline



Posts: 1337
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
How should UnrealShare.CoopGame.AddDefaultInventory depend on Level.DefaultGameType?
Oct 20th, 2014 at 4:51pm
Print Post  
Engine.GameInfo.AddDefaultInventory is defined as follows:

Code
Select All
function AddDefaultInventory( pawn PlayerPawn )
{
	local Weapon newWeapon;
	local class<Weapon> WeapClass;
	local GameRules G;

	PlayerPawn.JumpZ = PlayerPawn.Default.JumpZ * PlayerJumpZScaling();

	if ( PlayerPawn.IsA('Spectator') )
		return;

	if ( DefaultWeapon==None )
		goto'ModifyPL';

	// Spawn default weapon.
	WeapClass = BaseMutator.MutatedDefaultWeapon();
	if ( (WeapClass!=None) && (PlayerPawn.FindInventoryType(WeapClass)==None) )
	{
		newWeapon = Spawn(WeapClass,,, PlayerPawn.Location);
		if ( newWeapon != None )
		{
			newWeapon.Instigator = PlayerPawn;
			newWeapon.BecomeItem();
			PlayerPawn.AddInventory(newWeapon);
			newWeapon.BringUp();
			newWeapon.GiveAmmo(PlayerPawn);
			newWeapon.SetSwitchPriority(PlayerPawn);
			newWeapon.WeaponSet(PlayerPawn);
		}
	}
ModifyPL:
	if ( GameRules!=None )
	{
		for ( G=GameRules; G!=None; G=G.NextRules )
			if ( G.bNotifySpawnPoint )
				G.ModifyPlayer(PlayerPawn);
	}
} 


The implementation of UnrealShare.CoopGame.AddDefaultInventory invokes Engine.GameInfo.AddDefaultInventory only if DefaultGameType of the current level is not UnrealShare.VRikersGame:

Code
Select All
function AddDefaultInventory( pawn PlayerPawn )
{
	local Translator newTranslator;

	if ( Level.DefaultGameType != class'VRikersGame' )
		Super.AddDefaultInventory(PlayerPawn);

	// Spawn translator.
	if ( PlayerPawn.IsA('Spectator') || PlayerPawn.FindInventoryType(class'Translator') != None )
		return;
	newTranslator = Spawn(class'Translator',,, Location);
	if ( newTranslator != None )
	{
		newTranslator.bHeldItem = true;
		newTranslator.GiveTo( PlayerPawn );
		PlayerPawn.SelectedItem = newTranslator;
		newTranslator.PickupFunction(PlayerPawn);
	}
} 


So, if Level.DefaultGameType == class'VRikersGame', then

Code
Select All
	PlayerPawn.JumpZ = PlayerPawn.Default.JumpZ * PlayerJumpZScaling(); 


Code
Select All
	if ( GameRules!=None )
	{
		for ( G=GameRules; G!=None; G=G.NextRules )
			if ( G.bNotifySpawnPoint )
				G.ModifyPlayer(PlayerPawn);
	} 


won't be executed. Was such dependency on DefaultGameType defined intentionally? I'd expect that adjustment of PlayerPawn.JumpZ along with modification of player by GameRules object would apply regardless of DefaultGameType - as if UnrealShare.CoopGame.AddDefaultInventory would be defined as

Code
Select All
function AddDefaultInventory( pawn PlayerPawn )
{
	local Weapon newWeapon;
	local class<Weapon> WeapClass;
	local Translator newTranslator;
	local GameRules G;

	PlayerPawn.JumpZ = PlayerPawn.default.JumpZ * Level.Game.PlayerJumpZScaling();

	if (PlayerPawn.IsA('Spectator'))
		return;

	if (Level.Game.DefaultWeapon == none || Level.DefaultGameType == class'VRikersGame')
		goto'ModifyPL';

	// Spawn default weapon.
	WeapClass = Level.Game.BaseMutator.MutatedDefaultWeapon();
	if (WeapClass != none && PlayerPawn.FindInventoryType(WeapClass) == none)
	{
		newWeapon = Spawn(WeapClass,,, PlayerPawn.Location);
		if (newWeapon != none)
		{
			newWeapon.Instigator = PlayerPawn;
			newWeapon.BecomeItem();
			PlayerPawn.AddInventory(newWeapon);
			newWeapon.BringUp();
			newWeapon.GiveAmmo(PlayerPawn);
			newWeapon.SetSwitchPriority(PlayerPawn);
			newWeapon.WeaponSet(PlayerPawn);
		}
	}
ModifyPL:
	if (Level.Game.GameRules != none)
	{
		for (G = Level.Game.GameRules; G != none; G = G.NextRules)
			if (G.bNotifySpawnPoint)
				G.ModifyPlayer(PlayerPawn);
	}
	if (PlayerPawn.FindInventoryType(class'Translator') == none)
	{
		newTranslator = Spawn(class'Translator',,, PlayerPawn.Location);
		if (newTranslator != none)
		{
			newTranslator.bHeldItem = true;
			newTranslator.GiveTo(PlayerPawn);
			PlayerPawn.SelectedItem = newTranslator;
			newTranslator.PickupFunction(PlayerPawn);
		}
	}
} 


UPak.UPakCoopGame also looks weird

Code
Select All
function AddDefaultInventory( pawn PlayerPawn )
{
	local Translator newTranslator;

	if ( Level.DefaultGameType != class'VRikersGame' )
		Super.AddDefaultInventory(PlayerPawn);

	// Spawn translator.
	if( PlayerPawn.IsA('Spectator') || PlayerPawn.FindInventoryType(class'Translator') != None )
	{
		CheckScubaGear( PlayerPawn );
		return;
	}
	newTranslator = Spawn(class'Translator',,, Location);
	if( newTranslator != None )
	{
		newTranslator.bHeldItem = true;
		newTranslator.GiveTo( PlayerPawn );
		PlayerPawn.SelectedItem = newTranslator;
		newTranslator.PickupFunction(PlayerPawn);
	}
} 


I wonder why it's not defined as

Code
Select All
function AddDefaultInventory( pawn PlayerPawn )
{
	Super.AddDefaultInventory(PlayerPawn);
	CheckScubaGear(PlayerPawn);
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo