Page 1 of 1

Mutator Help

PostPosted: Fri Jan 06, 06 11:52 pm
by MainMan
Ok I need some help with making a mutator. I've never made one before, but i think the one I need is pretty easy to make. I need it to delete all multitools (including ones on respawned players), and instead spawn another class (credit card in my case).

Thanks.

PostPosted: Sat Jan 07, 06 10:27 am
by Dae
Code: Select all
class SomeMutator extends Mutator config(Mutators);

function PostBeginPlay()
{
   local Multitool M;
   Level.Game.BaseMutator.AddMutator(Self);
   foreach AllActors(Class'Multitool',M)
  {   
        if ( M != None )
        {
           Spawn(Class'{ADD YOUR CLASS NAME HERE}',,,M.Location,M.Rotation);
           M.Destroy();
        }
   }
}

This code will replace all multitools which lie on the ground, but not those which are given to the player when he respawns. Items which are given to the player when he respawns are unfortunately declared in DeusExPlayer and they're not even variables. I have some ideas about how to replace them too without overriding player class, but none of them are good enough. Maybe you could think of something better.

After you've done your mutator, add it to ServerPackages and ServerActors in DeusEx.ini, like this:
Code: Select all
ServerPackages=PackageName
ServerActors=PackageName.MutatorClass

PostPosted: Sat Jan 07, 06 10:40 am
by MainMan
what about the weapon selector mutator, that can get rid of all multitools, even on the player.

EDIT: How about if you put your code in Function Tick(Float Deltatime)?

PostPosted: Sat Jan 07, 06 11:00 am
by Dae
We don't have a source of mPack1.u unfortunately :(

And Tick isn't the best way, because
1. it may lag
2. there will be some time when a player will be able to drop multitool out

PostPosted: Sat Jan 07, 06 12:02 pm
by ~ô¿ô~Nobody~
you don't need to add it to serverpackages.. since the mutator just works on the server anyways :wink:


btw... what about decompiling mpack1?



EDIT: why that difficult with that tick function

just use function ModifyPlayer(Pawn Other)
of the mutator.. it always gets called after a player respawns
so.. you can right remove the multitool after respawning

PostPosted: Sat Jan 07, 06 12:07 pm
by MainMan
where do i need to add it then? in the map itself?

PostPosted: Sat Jan 07, 06 12:15 pm
by ~ô¿ô~Nobody~
the mutator needs to be placed in the map and needs to be registred in the mutator list..
auto spawning the mutator is done by
Code: Select all
ServerActors=PackageName.MutatorClass

..how dae already said
just serverpackages aren't required

PostPosted: Sat Jan 07, 06 12:21 pm
by MainMan
~[A]Nobody~ wrote:needs to be registred in the mutator list

How do I do this?

EDIT: nevermind it worked.

Here's the code I used, in case anyone else needs to use it:
Code: Select all
class MMRPGSpawn extends Mutator config(Mutators);

function PostBeginPlay()
{
   Level.Game.BaseMutator.AddMutator(Self);
}

function ModifyPlayer(Pawn Other)
{
   local Multitool M;
   local MMRPGCreditcard C;
   local DeusExPlayer Player;

   if (Other.IsA('DeusExPlayer'))
   {
      Player = DeusExPlayer(Other);
      foreach AllActors(Class'Multitool',M)
      {   
         if ( M.Owner == Player )
         {
            C = Spawn(Class'MMRPGCreditCard',,,M.Location,M.Rotation);
            M.Destroy();
            C.Frob(Player,none);
            C.bInObjectBelt = True;
            if(C.Owner != Player)
               C.Destroy();
              }
      }
   }
}

PostPosted: Sat Jan 07, 06 1:55 pm
by Dae
Thanks MainMan (for the code) and Nobody (for helping MainMan). :gj: