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)
{
}
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
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
}