Mutator's ScoreKill regarding teams.

Discussions about Coding and Scripting
Post Reply
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Mutator's ScoreKill regarding teams.

Post by Unknown »

Why is this not working?

Code: Select all

Class ClassName Extends Mutator; 

Var Int Current; 

Function AddMutator (Mutator M) 
{ 
	If (M != Self) Super.AddMutator (M); 
} 

Function Mutate (String MutateString, PlayerPawn Sender) 
{ 
	Local Inventory Inv; 
	If (MutateString ~= "String") 
	{ 
		Inv = Sender.FindInventoryType (Class 'ClassName'); 
		If (Inv != None) 
		{ 
			ClassName (Inv).Variable (); 
		} 
	} 
	If (NextMutator != None) NextMutator.Mutate (MutateString, Sender); 
} 

Function ScoreKill (Pawn Killer, Pawn Other) 
{ 
	Local Inventory Inv; 
	Inv = Killer.FindInventoryType (Class 'ClassName'); 
	If ((Inv != None) && (ClassName (Inv).Variable < 03)) 
	{ 
		If (Level.Game.bTeamGame || Level.Game.IsA ('TeamGamePlus')) 
		{ 
			If ((Killer.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) && (Killer != Other)) 
			{ 
				Killer.ReceiveLocalizedMessage (Class 'FailureMessage', 00, None, None, Self.Class); 
				Current = 00; 
			} 
			Else Current += 01; 
		} 
		Else Current += 01;
		If (Current == 10) 
		{ 
			Killer.ReceiveLocalizedMessage (Class 'SuccessMessage', 00, None, None, Self.Class); 
			ClassName (Inv).Variable+= 01; 
			Current = 00; 
		} 
	} 
} 

DefaultProperties 
{ 
	Current=00 
} 
This code is supposed to reward the owner of this certain inventory by increasing one of it's variables, which works. What is not working is the bit about the teams. The reward must be achieved every ten kills but it should fail and reset to zero for any team kill yet this only works in CTF, any other team game just skips over it without the failed message nor the resetting.
Last edited by Unknown on Sun Mar 29, 2015 5:40 am, edited 1 time in total.
User avatar
EvilGrins
Godlike
Posts: 9668
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: Mutator's ScoreKill regarding teams.

Post by EvilGrins »

I'm at work, so I can't download the file and even if I could there's no UT here for me to test it on... however, I have a question.

Is there documentation (ReadMe) that comes with the mutator that says, by any chance, it's CTF specific?

Some mutators only work with certain gametypes, this could be one of those.
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Re: Mutator's ScoreKill regarding teams.

Post by Unknown »

Where do you work at?

I didn't make it gametype specific, I'm just using "Level.Game.bTeamGame" to determine if it is a team game or not, for some strange reason it only works on CTF and not in the other team gametypes.
Spectra
Masterful
Posts: 542
Joined: Tue Jan 22, 2013 5:23 pm
Personal rank: Nullified!
Location: (X) Unable To Locate....

Re: Mutator's ScoreKill regarding teams.

Post by Spectra »

Try to replace it with:

Code: Select all

if(Level.Game.IsA('TeamGamePlus'))
{
//Rest of codes
}
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Re: Mutator's ScoreKill regarding teams.

Post by Unknown »

It didn't work Rocky, it behaves the same way.
Spectra
Masterful
Posts: 542
Joined: Tue Jan 22, 2013 5:23 pm
Personal rank: Nullified!
Location: (X) Unable To Locate....

Re: Mutator's ScoreKill regarding teams.

Post by Spectra »

Looking at your codes looks like it should work.
Put the whole codes of your Mutator so I can take a close look at other functions also.
User avatar
EvilGrins
Godlike
Posts: 9668
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: Mutator's ScoreKill regarding teams.

Post by EvilGrins »

That may well be, but seeing as it's only working in CTF for you it may be specific to that game. Empirical evidence and all that.
Unknown wrote:Where do you work at?
I sometimes wonder that myself.
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
User avatar
Wises
Godlike
Posts: 1089
Joined: Sun Sep 07, 2008 10:59 am
Personal rank: ...

Re: Mutator's ScoreKill regarding teams.

Post by Wises »

Decompile this code using wotGreal > Advanced Exporter;

http://www.unrealadmin.org/forums/showt ... hp?t=23777

everything team related in there and more.
:tu:
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Re: Mutator's ScoreKill regarding teams.

Post by Unknown »

There, I edited the post to show the full code.

Don't worry about class names, that's not the issue, I changed it to not give away my project that soon, I want it to be a surprise until finished.
MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: Mutator's ScoreKill regarding teams.

Post by MrLoathsome »

Looks like you left out a call to Super.ScoreKill in your function.

If I recall correctly, that needs to be there or things wont be working right.
blarg
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Mutator's ScoreKill regarding teams.

Post by sektor2111 »

MrLoathsome wrote:Looks like you left out a call to Super.ScoreKill in your function.
This is problem 1)
and Problem(s) 2)
This one for me has 0 value code
  • If ((Killer.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) && (Killer != Other))
If non-player hit other as flockpawn or whatever thing or if is used in games with other creatures this

Code: Select all

Killer.PlayerReplicationInfo.Team
will do sucks. When you call something into a function better made sure about its existence first

Code: Select all

if (Killer != None && Killer.PlayerReplicationInfo != None ... )
Will prevent errors when Other died in lava and/or killer is/isn't a creature non-player. And also might be good to be used

Code: Select all

&& Other.PlayerReplicationInfo != None)
as long as you call replication owned by pawn and NOT all pawn have this thing.

The fast head code is

Code: Select all

if (Level.Game.bTeamGame)
Checking boolean is faster than "ISA" and if exist this opportunity, using it will be a bless. I'm curious what Higor thinks.

Moving back to mutate function
  • If (MutateString ~= "String")
I don't know what you wanna say here. "String" is an internal variable definition. Your function should call properly your own string.
Next

Code: Select all

Function AddMutator (Mutator M)
{
   If (M != Self) Super.AddMutator (M);
} 
I never used such code, default UT can add mutators itself as long as this function gets called from outside.
Your other problem might be

Code: Select all

Level.game.registerdamagemutator(Self);
called from whatever event PostBeginPlay, allowing it to be registered else I might have doubts about functionality.
The rest of ClassName used in 2 places also is confusing me: one is Mutator and other is Inventory which is not the same thing...

Edit: And the Hint
Using a log line you can easily spy if your mutator is working at a moment or not

Code: Select all

//goes in scorekill
log(Self$" has ScoreKill called by "$Other.GetHumanName() );
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Re: Mutator's ScoreKill regarding teams.

Post by Unknown »

I added the Super.ScoreKill and it still behaves the same way as before, everything in the code works except the Team Game part:

Code: Select all

   If ((Inv != None) && (ClassName (Inv).Variable < 03))
   {
      If (Level.Game.bTeamGame || Level.Game.IsA ('TeamGamePlus'))
      {
         If ((Killer.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) && (Killer != Other))
         {
            Killer.ReceiveLocalizedMessage (Class 'FailureMessage', 00, None, None, Self.Class);
            Current = 00;
         }
         Else Current += 01;
      }
      Else Current += 01;
It has no problems with people dying on damage zones (lava, space, etc. ) and it won't trigger on other people killing themselves because of this:

Code: Select all

   If ((Inv != None) && (ClassName (Inv).Variable < 03))
It checks that the function is only activated when the killer has this item in its inventory, and there is only one in the map so only one player can trigger this.
I also added this part:

Code: Select all

If (Level.Game.bTeamGame || Level.Game.IsA ('TeamGamePlus'))
      {
         If ((Killer.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) && (Killer != Other)) 
For the bonus to not be triggered when the player kills a team mate, because that would be cheap or enable it to be abused and the (Killer != Other) prevents the code to be activated via suicide, which then wouldn't do anything but I want to avoid it from happenning.
So far it works nicely on all non team games and on CTF, which I don't understand since it doesn't work on other team games but CTF is fine.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Mutator's ScoreKill regarding teams.

Post by sektor2111 »

Then post console with a log fragment, I have still doubts about killer towards other.PlayerReplicationInfo. Killer might be Player with item but Other might be... Bird or Biterfish or a Fly. It would be better to explain what other team-games have you tried with this thing and it is refusing to work.
Unknown
Average
Posts: 48
Joined: Sun Mar 08, 2015 1:16 am

Re: Mutator's ScoreKill regarding teams.

Post by Unknown »

I have tried all default game types, none of them with monsters but I don't have a problem with it also counting monster kills, I want it to work on single player as well.
It works except on AS, DOM and TDM, on those it just skips this part:

Code: Select all

If (Level.Game.bTeamGame || Level.Game.IsA ('TeamGamePlus'))
      {
         If ((Killer.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) && (Killer != Other))
         {
            Killer.ReceiveLocalizedMessage (Class 'FailureMessage', 00, None, None, Self.Class);
            Current = 00;
         }
So it does not give the failure message or return the Current variable to zero, which it should every time the owner of the item kills a team mate.
Post Reply