Announcement

Collapse
No announcement yet.

Negative arguments are stupid?

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

    Negative arguments are stupid?

    Okay, so, for some reason, whenever I pass a negative argument to HealthRegenerate(Pawn Other, int Amount)'s Amount variable, it comes at me with a critical error stating an infinite recursion occurred upon calling FindInventoryType (which is in there; when I comment it out, no errors occur). The thing works fine as long as I pass a positive argument. Is this some known error, or am I screwed? I have tried both '-variable' and '0-variable' as far as passing the argument.

    Feel free to ask for any information you need. I just wanted to keep the post short.

    #2
    What does the HealthRegenerate function do? The way it is written it might be incompatible with negative values. If it isn't native you could rewrite the function so it deals with negative values properly.

    Comment


      #3
      It was made to simplify the process of "find the instigator's regeneration inventory (controls all regeneration), and add a number to it's regeneration speed". Here's the code.

      Code:
      function HealthRegenerate( Pawn Other, int Amount )
      {
      	local Inventory Inv;
      	local Ench_HealthRegeneration Ench;
      	Inv = Other.FindInventoryType(class'Ench_HealthRegeneration');
      	if ( Ench_HealthRegeneration( Inv ) != None )
      	{
      		Ench = Ench_HealthRegeneration( Inv );
      		Ench.RegenArrows += Amount;
      		if ( Ench.RegenArrows - Amount == 0 )
      			Ench.Timer();
      	}
      	Log("HealthRegenerate("$Other$", "$Amount$") called...");
      }
      RegenArrows is just the term I use for the speed which the player regenerates. 'Arrows' being the unit.

      The error I recieve upon being hit (when a negative argument is given) is the following:

      xPawn DM-1on1-Albatross.xPawn (Function Engine.Pawn.FindInventoryType:0000) Infinite script recursion (250 calls) detected

      The rest is irrelevant, because it just refers to NetDamage as the culprit (which is the case, in a sense).

      ...I think I may have found the problem. What happens when a variable is zero, and you mark the variable as negative when referring it as an argument? Though that doesn't relate to what it says is the problem, it very well may be the bad factor.

      Comment


        #4
        hmm that is odd. I can't see why FindInventoryType is being called so many times, or why it has anything to do with the amount argument. The only thing I could think of is that there's something about the way this healthregenerate function is called that means for some reason it is called repeatedly if you take damage. So it's not neccessarily because it has a negative value passed to it. Does it still happen if you give it a positive value when you take damage?

        Comment


          #5
          Okay, after half an hour of putting in Log()s after every statement, I believe I have found the culprit... Take a look at this set of Log()s:
          Code:
          ScriptLog: START MATCH
          ScriptLog: Hit...
          ScriptLog: after the inventory check...
          ScriptLog: After typecast check...
          ScriptLog: After typecast...
          ScriptLog: After bFullHealth = false...
          ScriptLog: After function called...
          ScriptLog: After function called...
          ScriptLog: After function called...
          ScriptLog: After function called...
          ScriptLog: After function called...
          ScriptLog: After function called...
          ScriptLog: After function called...
          (it continues for another 30 lines or so,)
          (leading straight into the 'Critical: Infinite Loop')
          The noted function is called after finding a certain Inventory for the player (from which the function is called). Therefore, I believe the problem lies in the locating of the Inventory and the insertion of the data into a variable, and perhaps the typecasting that follows. The following is in my NetDamage function:
          Code:
          function int NetDamage( int OriginalDamage, int Damage, Pawn Injured, Pawn InstigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
          {
          	local Inventory Inv;
          	local Ench_InherentRegeneration Ench;
          
          	Log("Hit...");
          	Inv = Injured.FindInventoryType(class'Ench_InherentRegeneration');
          	Log("after the inventory check...");
          	if ( Ench_InherentRegeneration( Inv ) != None )
          	{
          		Log("After typecast check...");
          		Ench = Ench_InherentRegeneration( Inv );
          		Log("After typecast...");
          		Ench.bFullHealth = false;
          		Log("After bFullHealth = false...");
          		Ench.Interrupted();
          		Log("After interruption...");
          	}
          	return Super.NetDamage(OriginalDamage, Damage, Injured, InstigatedBy, HitLocation, Momentum, DamageType);
          }
          So I'm thinking that for some reason, it screws up finding the inventory, looping forever, and calling the following function. The Interrupted() function:
          Code:
          function Interrupted()
          {
          	Log("After function called...");
          	HealthRegenerate(Instigator, -RegenerationCounter); // NEGATIVE RegenerationCounter
          	Log("After HealthRegenerate...");
          	RegenerationCounter = 0;
          	if ( !bFullHealth )
          	{
          		SetTimer(4, false);
          		Log("Interrupted, not Full Health...");
          	}
          	else
          		Log("Interrupted, Full Health...");
          }
          However, if it were looping continually, "After HealthRegenerate..." would pop up a million times too. Any ideas?

          Comment


            #6
            NVM im an idiot

            Comment


              #7
              ...?

              Comment


                #8
                Well I'll be d**ned... After another hour of logging after every single freaking command, I found that the code does indeed loop itself. Whuddathunkit. The errors it showed, about FindInventoryType() and stuff, were totally irrelevant. I admit, I was wrong about the whole 'only negative arguments' thing. Boy, that sucked. Ah well. Thanks for all your help :3.

                Comment

                Working...
                X