UE3 - UT3 MutPipedSwitchWeapon3

  • 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.

Ethax

!Concept Art Maniac!
Sep 19, 2008
7
0
0
Hi all!

This is my first thread on this forum and sorry for my bad English...

I planning to make my first mutator, but I haven't any experiences in UScript, only in C++ and Java. This mutator will bring back the PipedSwitchWeapon for UT3...

So, my first problem is that dont know how to verify does desired weapon has any ammo or not, because if hasn't then don't change the active weapon to desired one. (Does it possible to change to an empty weapon?)
The second is that down know which variable type is 'weapon'. I read in an article that IsActiveWeapon function is waiting for weapon variable to compare does the Pawn's active weapon is the desired weapon or not.

Here is the uncompleted code (maybe it's totally wrong, but I'm a n00b in this issue :lol:):
Code:
class mpsw3 extends UTMutator;
//MutPipedSwitchWeapon3

bool bMajor = false;		//If true then blocks the following piped switches
string ConsoleCommand = "";

function Switch(byte WeaponNumber)
{
	if(IsActiveWeapon(WeaponNumber))
	{
		bMajor = false;
	}
	else
	{
		//Here need to check does the desired weapon has any ammo or not
		//If hasn't then don't do anything
		bMajor = true;
		ConsoleCommand = "SwitchWeapon" + " " + WeaponNumber;
		//Does it correct? How can I send a console command?
		command(ConsoleCommand);
	}
}

function Piped(byte WeaponNumber)
{
	if(!bMajor)
	{
		//Here need to check does the desired weapon has any ammo or not
		//If hasn't then don't do anything
		bMajor = true;
		ConsoleCommand = "SwitchWeapon" + " " + WeaponNumber;
		//Does it correct? How can I send a console command?
		command(ConsoleCommand);
	}
}

function Best()
{
	if(IsActiveWeapon(GetBestWeapon()))
	{
		bMajor = false;
	}
	else
	{
		//Here need to check does the desired weapon has any ammo or not
		//If hasn't then don't do anything
		bMajor = true;
		ConsoleCommand = "SwitchToBestWeapon";
		//Does it correct? How can I send a console command?
		command(ConsoleCommand);
	}
}

DefaultProperties
{
	//What do I need to write here?
}

If it will work, do I can call it from console by:

Code:
;mpsw3 = MutPipedSwitchWeapon3
mutate mpsw3 switch 9 | mutate mpsw3 piped 6 | mutate mpsw3 piped 2

..or use it as bind?

I wish to lean the UScript but not in that way to read many articles. I more like trial by error...
 

brold9999

New Member
Apr 5, 2009
142
0
0
I can understand that you want to get straight into this mod without having to spend a lot of time learning UScript, but it will be impossible to give advice at a high enough level until you have some mastery of the basics.

Tutorials are one way to learn. Another is by studying the existing code and producing variants based on that code. Tweaked weapons is a place that a lot of people start.
 

Ethax

!Concept Art Maniac!
Sep 19, 2008
7
0
0
Tutorials are one way to learn. Another is by studying the existing code and producing variants based on that code. Tweaked weapons is a place that a lot of people start.

I started to read tutorials, but I wish to finish this if I started. Meantime when I searched for good tutorials, found an article where read about exec functions. So, I completely changed my code to only expand PlayerInput, and not be a mutator. For now I also can't verify does the desired weapon has ammo or does it available for player. Here is the modified code:

Code:
class ExtendedInput extends PlayerInput config (ExtendedInput);
//PipedSwitchWeapon alternative by Etahx

var bool bDone;

/*
 * Syntax for keybinds:
 * 
 * SwitchTo BestWeapon - Switches to the Player's best weapon
 * SwitchTo DesiredWeapon <number> - Switches to the selected weapon
 * SwitchTo AlternativeWeapon <number> - If the desired weapon hasn't ammo or Player hasn't that weapon, then switches to the here added weapon
 * 
 * Example:
 * Bindings=(Name="Q",Command="SwitchTo DesiredWeapon 9 | SwitchTo AlternativeWeapon 6 | SwitchTo AlternativeWeapon 2")
 * 
 * Special numbers:
 * 88 - AVRiL
 * 10 - Redeemer
 * 11 - Translocator
*/
exec function SwitchTo(string SwitchMode, optional byte WeaponNumber)
{
	switch(SwitchMode){
	case "DesiredWeapon":
		if(IsActive(WeaponNumber))
			bDone = false;
		else if(CheckAmmo(WeaponNumber))
			ChangeIt(WeaponNumber);
		else
			bDone = false;
		break;
	case "BestWeapon":
		if(InventoryManager.IsActiveWeapon(InventoryManager.GetBestWeapon))
			bDone = false;
		else if(CheckAmmo(WeaponNumber))
			ChangeIt(WeaponNumber);
		else
			bDone = false;
		break;
	case "AlternativeWeapon":
		if(!bDone){
			if(IsActive(WeaponNumber))
				bDone = true;
			else if(CheckAmmo(WeaponNumber))
				ChangeIt(WeaponNumber);
			else
				bDone = false;
		}
		break;
	}
}
function bool IsActive(byte WeaponNumber)
{
	switch(WeaponNumber){
	case 1:
		return InventoryManager.IsActiveWeapon('UTWeap_ImpactHammer');
		break;
	case 2:
		return InventoryManager.IsActiveWeapon('UTWeap_Enforcer');
		break;
	case 3:
		return InventoryManager.IsActiveWeapon('UTWeap_BioRifle');
		break;
	case 4:
		return InventoryManager.IsActiveWeapon('UTWeap_ShockRifle');
		break;
	case 5:
		return InventoryManager.IsActiveWeapon('UTWeap_LinkGun');
		break;
	case 6:
		return InventoryManager.IsActiveWeapon('UTWeap_Stinger');
		break;
	case 7:
		return InventoryManager.IsActiveWeapon('UTWeap_FlakCannon');
		break;
	case 8:
		return InventoryManager.IsActiveWeapon('UTWeap_RocketLauncher');
		break;
	case 88:
		return InventoryManager.IsActiveWeapon('UTWeap_Avril');
		break;
	case 9:
		return InventoryManager.IsActiveWeapon('UTWeap_SniperRifle');
		break;
	case 10:
		return InventoryManager.IsActiveWeapon('UTWeap_Redeemer');
		break;
	case 11:
		return InventoryManager.IsActiveWeapon('UTWeap_Translocator');
		break;
	default:
		return false;
	}
}
function bool CheckAmmo(byte WeaponNumber)
{
	switch(WeaponNumber){
	case 1:
		if(UTWeap_ImpactHammer.IsActiveWeapon())
			return Inventory.UTWeap_ImpactHammer.HasAnyAmmo();
		else
			return false;
		break;
	case 2:
		if(UTWeap_Enforcer.IsActiveWeapon())
			return UTWeap_Enforcer.HasAnyAmmo();
		else
			return false;
		break;
	case 3:
		if(UTWeap_BioRifle.IsActiveWeapon())
			return UTWeap_BioRifle.HasAnyAmmo();
		else
			return false;
		break;
	case 4:
		if(UTWeap_ShockRifle.IsActiveWeapon())
			return UTWeap_ShockRifle.HasAnyAmmo();
		else
			return false;
		break;
	case 5:
		if(UTWeap_LinkGun.IsActiveWeapon())
			return UTWeap_LinkGun.HasAnyAmmo();
		else
			return false;
		break;
	case 6:
		if(UTWeap_Stinger.IsActiveWeapon())
			return UTWeap_Stinger.HasAnyAmmo();
		else
			return false;
		break;
	case 7:
		if(UTWeap_FlakCannon.IsActiveWeapon())
			return UTWeap_FlakCannon.HasAnyAmmo();
		else
			return false;
		break;
	case 8:
		if(UTWeap_RocketLauncher.IsActiveWeapon())
			return UTWeap_RocketLauncher.HasAnyAmmo();
		else
			return false;
		break;
	case 88:
		if(UTWeap_Avril.IsActiveWeapon())
			return UTWeap_Avril.HasAnyAmmo();
		else
			return false;
		break;
	case 9:
		if(UTWeap_SniperRifle.IsActiveWeapon())
			return UTWeap_SniperRifle.HasAnyAmmo();
		else
			return false;
		break;
	case 10:
		if(UTWeap_Redeemer.IsActiveWeapon())
			return UTWeap_Redeemer.HasAnyAmmo();
		else
			return false;
		break;
	case 11:
		return UTWeap_Translocator.IsActiveWeapon();
		break;
	default:
		return false;
	}
}
function ChangeIt(byte WeaponNumber)
{
	switch(WeaponNumber){
	case 88:
		ConsoleCommand("switchweapon 0");
		break;
	case 10:
		ConsoleCommand("switchweapon 10");
		break;
	case 11:
		ConsoleCommand("ToggleTranslocator");
		break;
	default:
		ConsoleCommand("SwitchWeapon"@string(WeaponNumber));
		break;
	}
	bDone=true;
}
DefaultProperties
{
	bDone = false;
}

I tried to build this, but are some errors in my code, so it wasn't successful. :(
 

brold9999

New Member
Apr 5, 2009
142
0
0
I can understand your desire to learn by doing on this mod rather than a simpler one, but you need to have a firm grasp of the fundamentals. People here like to help but not with trifling details like basic compile errors. The information you need to at least get the code compiling is readily available already.