Announcement

Collapse
No announcement yet.

Spawning Inventories, Inventory Checking...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Spawning Inventories, Inventory Checking...

    I'm making a small base for a larger mutator on Unreal Tournament 2004. This base sets up 'regeneration arrows'. Those of you who have played Guild Wars know what I'm talking about. Little arrows that represent various speeds of re/degeneration. So I've set up four pieces of code, which I will cite. The code looks right to me, but check for yourself. The whole thing compiles fine, no errors or warnings, but in the game nothing happens.
    Code:
    class MutKohanRPG extends Mutator;
    
    function ModifyPlayer( Pawn Other )
    {
    	local Inventory Inv;
    
    	Super.ModifyPlayer(Other);
    
    	if (Other.Controller == None || !Other.Controller.bIsPlayer)
    		return;
    	Inv = Other.FindInventoryType(class'Ench_HealthRegeneration');
    	if ( Inv == None )
    	{
    		Spawn(class'Ench_HealthRegeneration', Other, , , rot(0, 0, 0));
    	}
    	Inv = Other.FindInventoryType(class'Ench_EnergyRegeneration');
    	if ( Inv == None )
    	{
    		Spawn(class'Ench_EnergyRegeneration', Other, , , rot(0, 0, 0));
    	}
    }
    
    defaultproperties
    {
    	 bAddToServerPackages=True
    	 GroupName="RPG"
    	 FriendlyName="KohanRPG"
    	 Description="UT2004 with 'Attributes' that modify the player's strength, speed, health, et cetera."
    }
    Code:
    class Enchantment extends Inventory;
    
    function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    }
    
    function int HealthRegenerate( Pawn Other, int Amount )
    {
    	local Inventory Inv;
    	Inv = Other.FindInventoryType(class'Ench_HealthRegeneration');
    	if ( Ench_HealthRegeneration( Inv ) != None )
    	{
    		Ench_HealthRegeneration( Inv ).RegenArrows += Amount;
    	}
    	return 1;
    }
    
    function int EnergyRegenerate( Pawn Other, int Amount )
    {
    	local Inventory Inv;
    	Inv = Other.FindInventoryType(class'Ench_EnergyRegeneration');
    	if ( Ench_EnergyRegeneration( Inv ) != None )
    	{
    		Ench_EnergyRegeneration( Inv ).RegenArrows += Amount;
    	}
    	return 1;
    }
    
    defaultproperties
    {
    }
    Code:
    class Ench_HealthRegeneration extends Enchantment;
    
    var int RegenArrows;
    
    function PostBeginPlay()
    {
    	SetTimer( 0.5 / float(RegenArrows), false );
    	Super.PostBeginPlay();
    }
    
    function Timer()
    {
    	Instigator.GiveHealth( 1, Instigator.HealthMax );
    	SetTimer( 0.5 / float(RegenArrows), false );
    }
    
    defaultproperties
    {
    	RegenArrows=2;
    }
    Code:
    class Ench_EnergyRegeneration extends Enchantment;
    
    var int RegenArrows;
    
    function PostBeginPlay()
    {
    	SetTimer( 3.0 / float(RegenArrows), false );
    	Super.PostBeginPlay();
    }
    
    function Timer()
    {
    	Instigator.Controller.Adrenaline += 1;
    	SetTimer( 3.0 / float(RegenArrows), false );
    }
    
    defaultproperties
    {
    	RegenArrows=2;
    }
    I'm assuming it's some stupid mistake I'm making, but I've tried multiple alternatives, and nothing has worked. By the way, in the SetTimers, are the float-casts necessary to get a float out of the division?

    #2
    Come on, people, is it really that hard? If it is, just tell me .

    Comment


      #3
      Write to the log at various stages and see if they come up. That way you'll know how far it's getting, and at what stage it's going wrong.

      Comment


        #4
        Warning: Ench_HealthRegeneration DM-1on1-Albatross.Ench_HealthRegeneration (Function KohanRPG.Ench_HealthRegeneration.Timer:0006) Accessed None 'Instigator'

        It doesn't know what Instigator is?

        Edit: Aha! I haven't thew foggiest why, but instead of using Instigator, a Pawncasted Owner works. In this case:
        Code:
        Instigator.GiveHealth( 1, Instigator.HealthMax ); // Instead of this...
        Pawn( Owner ).GiveHealth( 1, Pawn( Owner ).HealthMax ); // Use this instead.
        So you don't have to ask, Owner requires casting because it is an Actor, which does not have GiveHealth; Pawns do. Thanks for your help, dude.

        Update: Great, a new problem. First of all (albeit the mutator does work), the log file says Accessed None 'Owner'. Not that much of a problem, but it's there. Second, whenever you perform an Adrenaline Combo, you seem to gain another regenerating inventory, so both Health and Adrenaline increase at twice the pace... the rythm is off, so that means it must be another inventory, not simply an increase in Regeneration speed. I'm looking through Combo De/Activation code right now to see what might cause it...

        Comment


          #5
          Just a clean up.
          You should really do this for spawning you inventory

          Code:
          function ModifyPlayer( Pawn Other ){
          	local Inventory Inv;
          	local Enchantment Enchantment_Inv;
          
          	Super.ModifyPlayer(Other);
          	if (Other.Controller == None || !Other.Controller.bIsPlayer) return;
          	Inv = Other.FindInventoryType(class'Ench_HealthRegeneration');
          	if ( Inv == None ){
          		Enchantment_Inv	= Spawn(class'Ench_HealthRegeneration');
          		if (Enchantment_Inv != None)
          			Enchantment_Inv.GiveTo(Other, None);
          	}
          	Inv = Other.FindInventoryType(class'Ench_EnergyRegeneration');
          	if ( Inv == None ){
          		Enchantment_Inv	= Spawn(class'Ench_EnergyRegeneration');
          		if (Enchantment_Inv != None)
          			Enchantment_Inv.GiveTo(Other, None);
          	}
          }
          Should fix up your Accessed None on the Instigator and Owner vars.

          Comment


            #6
            O_O... I praise you as my lord and god for the moment.

            Thank you so much! It works flawlessly! Now to test in netplay... Muhahaha...

            Comment

            Working...
            X