Mutator Question/Problem

Discussions about Coding and Scripting
Post Reply
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Mutator Question/Problem

Post by Feralidragon »

luluthefirst wrote:I have a question, how to give weapon to a player?
Idk what exactly you want to do and in which type of actor, but this is what I often use myself to give a new weapon to a player/pawn.

Code: Select all

local Weapon newWeapon; // The new weapon
local Pawn P;  // The pawn/player in question

newWeapon = Spawn(Class'TheWeapon');
		
if (newWeapon != None)
{
	newWeapon.bTossedOut = false;
	newWeapon.Instigator = P;
	newWeapon.RespawnTime = 0.0;
	newWeapon.bHeldItem = true;
	newWeapon.BecomeItem();
	P.AddInventory(newWeapon);
	newWeapon.GiveAmmo(P);
	newWeapon.SetSwitchPriority(P);
	newWeapon.WeaponSet(P);
}
luluthefirst wrote: and i have a problem... the super.function(PlayerPawn); don't work, the compilator say me the function doesn't exist :noidea

thank for your help.
You have to be more specific. Which function are we talking? In which class?
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Mutator Question/Problem

Post by Feralidragon »

luluthefirst wrote:The class is UND and the function is PlayerWeapon

Function PlayerWeapon( Pawn PlayerPawn )
{
Super.PlayerWeapon(PlayerPawn);
GiveWeapon(PlayerPawn, "UND.SuperEnforcer");
}
Ok, but what class it extends into? Mutator, info, actor?
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Mutator Question/Problem

Post by Feralidragon »

luluthefirst wrote:Ah, is mutator
Then the mystery is solved: there isn't really any function with that name in Mutator, Info, Actor or even Object.

That function is new in your class, so there isn't any function with that name in the super classes, so the compiler is right.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Mutator Question/Problem

Post by Feralidragon »

Yeah, and where's that function?
Function PlayerWeapon( Pawn PlayerPawn )
It isn't there in that mutator anywhere by what I see.

What I can see is that you might just got mistaken with the function.
Didn't you want the function function ModifyPlayer(Pawn Other) instead?
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Mutator Question/Problem

Post by Feralidragon »

luluthefirst wrote:In bpak is the function ModifyPlayer

Code: Select all

function ModifyPlayer(Pawn Other)
{
   Super.ModifyPlayer(Other);

   if (WeaponReplaceType != None)
      GiveWeapon(Other, WeaponReplaceType);
   else
      GiveWeapon(Other, WeaponNewType);
   Other.Health = 1500;
   Other.Fatness = 128;
   if ( NextMutator != None )
      NextMutator.ModifyPlayer(Other);
}
So, wasn't that function you wanted to use instead?
Because there's really no function like the one you created in the super classes, and in that class neither.
Post Reply