• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code OK, this is just plain silly (CheckReplacement)

IconoclastDX

Grizzled Veteran
Mar 23, 2006
156
0
Is this or is the not the proper implementation of "CheckReplacement"?

Code:
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
      if(Other.IsA('ROPawn'))
      {
            ReplaceWith(Other,"ROPawn");
            return false;
      }
      return true;
}
Yes, im replacing 'ROPawn' with 'ROPawn' but Im trying to keep this as simple as possible. I have, of course tried replacing 'ROPawn' with an all but empty class in the 'ReplaceWith' parameter (e.g. "MyROPawn") but I get the same result (no spawing).

THX! :D
 
Last edited:
have you checked with some log or broadcast if it eventually enters the if clause?

Have you tried this syntax?

Code:
if(ROPawn'Other') !=None)
{
...
}

Should do the same, but thats the one I see more often.

Btw. why do your return false when the replace happens?
That seems odd to me. The code in the wiki about CheckReplacement returns true in case of success.
 
Upvote 0
Well I figured out why my ROPawn replaces ROPawn wouldnt work (infinite loop, duh) but Im still not sure why it wouldnt replace it with MyROPawn.

As I understand it, If you want CheckReplacement to replace an actor you must return false, which tells IsRelevant that you want to throw away the original actor. If you are just using the function to, say, modify starting ammo but not replacing the actor then you can return true.

There also appear to be a few different ways to identify your actor. A lot of the examples use a class check
<< if ( xWeaponBase(Other).WeaponType == class'Minigun' ) >>
or use a longer dot syntax when making the checks
<< ReplaceWith( Other, "FastRifle.FastRifle" ); >>

I dont know enough about OOP to know which is better for any given situation so Ill try them all I suppose.

About log entries, could I simply place "Log("xyz")" in between any line to create a log message telling me it go that far? It sure would be helpful.

THX! :D
 
Upvote 0