[Question] LevelUp not registering as picked up

Discussions about Coding and Scripting
Post Reply
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

[Question] LevelUp not registering as picked up

Post by ANUBITEK »

EDIT:

Reviving this topic 'cause I gotta get this functioning before I can work on anything else. I've decided to just keep the topic here and remove it from OldUnreal.

I need to make a level up item that should function the same way as ammo: when picked up, add 1. The script itself will compile and the item will spawn in-game, can be touched and will disappear after it is touched. The problem is that the player will touch the item and it will disappear as if it was picked up, but none of my log reports from RPG_LevelUp are appearing in Unreal.log and this leads me to believe it is not being added to the player's inventory. After looking over Pickup, I'm assuming I need to implement PickupFunction (maybe?), but I don't know how I would implement it properly:

Code: Select all

function PickupFunction(Pawn Other)
{
}
The only thing being printed to log is from the PlayerPawn, not from the item itself:

Code: Select all

Log: RPG_LionPlatformer Autoplay.RPG_LionPlatformer0 (Function Engine.PlayerPawn.PlayerWalking.PlayerMove:0256) GetAnimGroup: No mesh
ScriptLog: Pawn touched something. . .
ScriptLog: Pawn touched LevelUp
Here is what I have of the script so far, much like the cannon from earlier I have no idea what I'm doing with inventory:

Code: Select all

//=============================================================================
// RPG_LevelUp.
//=============================================================================
class RPG_LevelUp extends Pickup;

var() travel int ItemAmount;
var() travel int MaxItems;

var class<RPG_LevelUp> LevelUp;    // Class of ammo to be represented in inventory

function TravelPreAccept()	
{
	if ( Pawn(Owner).FindInventoryType(class) == None )
		Super.TravelPreAccept();
}

function bool HandlePickupQuery( inventory Item )
{
	if ( class == item.class )
	{
		if ( ItemAmount == MaxItems )
			log("HandlePickup: Max LevelUps, can't add to inventory!");
			return true;
		Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
		item.PlaySound( item.PickupSound );
		AddItem(RPG_LevelUp(item).ItemAmount);
		log("HandlePickup: items picked up:"$ItemAmount);
		item.SetRespawn();
		return true;
	}
	if ( Inventory == None )
		return false;

	return Inventory.HandlePickupQuery(Item);
}

function inventory SpawnCopy( Pawn Other )
{
	local Inventory Copy;

		Copy = spawn(class'RPG_LevelUp',Other);
		Copy.Tag           = Tag;
		Copy.Event         = Event;
		Copy.Instigator    = Other;
		RPG_LevelUp(Copy).ItemAmount = ItemAmount;
		Copy.BecomeItem();
		Other.AddInventory( Copy );
		Copy.GotoState('');
		SetRespawn();
		return Copy;
		
	Copy = Super.SpawnCopy(Other);
	RPG_LevelUp(Copy).ItemAmount = ItemAmount;
	return Copy;
}

function bool AddItem(int ItemToAdd)
{
	log("Player Picked up LevelUp, checking amount. . .");
	If ( ItemAmount >= MaxItems ) 
		log("AddItem: Max LevelUps, can't add to inventory!");
		return false;
	ItemAmount += ItemToAdd;
	log("AddItem: Adding LevelUp to inventory!");

	if ( ItemAmount > MaxItems ) 
	{
		ItemAmount = MaxItems;
		log("AddItem: Max LevelUps, dumping extras!");
		return true;
	}
}
/*
function GiveLevelUp(Pawn PlayerPawn)
{
	local RPG_LevelUp LevelUp;

	if ( ( PlayerPawn.FindInventoryType ( class'RPG_LevelUp' ) != none ) ^^ ( PlayerPawn.FindInventoryType ( class'RPG_LevelUp' ) == none ) && ( PlayerPawn.Health >= 1 ) )
	{
		if ( LevelUp.ItemAmount >= 0 )
		{
			LevelUp.RespawnTime = 0.0;
			LevelUp.GiveTo(PlayerPawn);
			self.CurrentLevel += LevelUp.ItemAmount;
			return;
		}
		if ( LevelUp.ItemAmount < self.CurrentLevel )
		{
			self.CurrentLevel = LevelUp.ItemAmount;
			log("CurrentLevel: " @ self.CurrentLevel );
//				LevelUp.Activate();
		}
	}
}*/

/*
ItemAmount=1 // Byte values may only consist of decimal digits and must not contain a sign. 
	Like byte values, int values may only consist of decimal digits. They may also be 
	preceded by a minus sign. Hexadecimal notation is not supported.
*/

defaultproperties
{
	ItemAmount=1
	MaxItems=50
	
}
Last edited by ANUBITEK on Sat Jan 23, 2016 6:20 pm, edited 2 times in total.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Making LevelUp Item

Post by JackGriffin »

I posted some code theory ideas over at Old Unreal that you may want to consider moving forward on this.
So long, and thanks for all the fish
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: Making LevelUp Item

Post by ANUBITEK »

Mind posting ljnks here for archiving purposes?
Edit:
Yeah, just keep all replies here. I'm honestly thinking of just asking general scripting questions here, if I have anything specifically 227 related I'll take it to OldUnreal.
Last edited by ANUBITEK on Sat Jan 23, 2016 5:04 pm, edited 1 time in total.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Making LevelUp Item

Post by JackGriffin »

Your style is to post everything to every board but I don't like to do that. Google archives nearly everything and it's a simple search to find something nowadays. It's my opinion that people will tend to start overlooking your posts if you post the same thing in several different places, especially if it's the same word-for-word post. You pick a forum and I'll be glad to discuss it but I'm not going to do it on several different ones.
So long, and thanks for all the fish
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: [Question] LevelUp not registering as picked up

Post by ANUBITEK »

EDIT:
Gonna keep all replies here, as well as any general scripting questions. If I have anything 227 related, I'll take it to OldUnreal immediately.

That being said, bumping the topic as I've edited the OP to better reflect the question. I need to get this working as the next few things I intend to make will require checking the amount of RPG_LevelUp items the player has.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: [Question] LevelUp not registering as picked up

Post by Barbie »

I just had a quick view at the code in the first post and I noticed that text indent tells other things than UScript syntax. For example this code:

Code: Select all

If ( ItemAmount >= MaxItems )
  log("AddItem: Max LevelUps, can't add to inventory!");
  return false;
ItemAmount += ItemToAdd;
Shouldn't it be:

Code: Select all

If ( ItemAmount >= MaxItems )
{
  log("AddItem: Max LevelUps, can't add to inventory!");
  return false;
}
ItemAmount += ItemToAdd;
Edit: Spell fix
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: [Question] LevelUp not registering as picked up

Post by JackGriffin »

So what's your issue B? It's not getting touched correctly?
So long, and thanks for all the fish
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: [Question] LevelUp not registering as picked up

Post by ANUBITEK »

I honestly don't know what the issue is, there are logs that should print in Unreal.log but they aren't printing so one of two things is wrong:
the item isn't being added to the player's inventory but is being touched,
or the item doesn't operate properly.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: [Question] LevelUp not registering as picked up

Post by JackGriffin »

Skype the mod over to me and let me look at it. I'm here, just hidden. I've been coding a maprotator for my coop server.
So long, and thanks for all the fish
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: [Question] LevelUp not registering as picked up

Post by ANUBITEK »

Boom, check your inbox homie.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: [Question] LevelUp not registering as picked up

Post by JackGriffin »

Got it. Will post you an answer tonight.
So long, and thanks for all the fish
Post Reply