|
Hyper.nl Unreal Services The forum of Hyper.nl Unreal Services and the semi-offical resource for Winged Unicorn's Unreal mods
|
View previous topic :: View next topic |
Author |
Message |
TheEmperorStalwartUK
Joined: 11 Feb 2004 Posts: 261
|
Posted: Mon Aug 02, 2004 2:56 pm Post subject: Mutator Coding Help Needed |
|
|
I'm coding my first mutator for Unreal, I've coded the player/bot classes and both of them work as they should (They are decapitated properly), but i'm having a few problems with the mutator; I intend for the mutator to replace the regular Player classes with the Fixed ones (In the same package as the mutator, the problem is that I don't really know how to do it.
Here's what i've coded so far:
Code: | //=============================================================================
// SkaarjPlayerFixMutator.
//-----------------------------------------------------------------------------
// Changes the default SkaarjPlayer and SkaarjPlayerBot classes to the
// SkaarjPlayerFix versions.
//-----------------------------------------------------------------------------
// By TheEmperorStalwartUK.
//=============================================================================
class SkaarjPlayerFixMutator expands Mutator;
function bool CheckReplacment(actor Other, out byte bSuperRelevant)
{
// Replace SkaarjPlayers with SkaarjPlayerFix players.
if (Other.IsA('SkaarjPlayer'))
{
ReplaceWith(Other,"SkaarjPlayerFix.SkaarjPlayerFix");
return true;
}
// Replace SkaarjPlayerBots with SkaarjPlayerFixBots.
if (Other.IsA('SkaarjPlayerBot'))
{
ReplaceWith(Other,"SkaarjPlayerFix.SkaarjPlayerFixBot");
return true;
}
// Replace MCoopSkaarjPlayers with SkaarjPlayerFixPlayers.
if (Other.IsA('MCoopSkaarjPlayer'))
{
ReplaceWith(Other,"SkaarjPlayerFix.SkaarjPlayerFix");
return true;
}
} |
_________________ StalwartUK |
|
Back to top |
|
|
Zombie
Joined: 27 Jan 2004 Posts: 295
|
Posted: Mon Aug 02, 2004 9:12 pm Post subject: |
|
|
First of all, when you totaly replace any actor class in CheckReplacement you should always return false so that the old class is destroyed. Otherwise you may end up with doubles everywhere the class spawns as the least of your worries. When you return true the class fed into CheckReplacement is spared from destruction. You should always have return true at the very end of the function outside of any expressions so that all the actors in the level aren't destroyed. Also, notice that you are using IsA('') to find the proper class to replace. If the replacement class itself is a child class extending from the parent defined in IsA('') you can end up with a recursive loop. Reason why this can happen is because even the new spawned replacement actors will be fed into CheckReplacment because of what all actors inherite in PreBeginPlay() to check their relevence. Doing "if ( Other.Class == Class'ThisClass' )" is one way to avoid those types of loops.
Another thing, since you are also trying to replace a player class you will have to modify the event Login from the gametype in order to redefine what SkaarjPlayer class is used for players. Since the mutator functions ModifyPlayer or ModifyLogin? weren't added into the Unreal games until UT you won't be able to do it from a mutator unless you built from MCoop2, UTeamFix9D, or EnhancedDM. Since MCoop2 has excellent support for Login mutators that's one place I'd start with replacing a player class. MCoopMutator2.u has classes called CoopLoginMutator and DMLoginMutator which is what you would modify from. Otherwise if you didn't build from them you'd need to start a new gametype to change the event Login.
Keep in mind that the regular Unreal gametypes don't force a player class at Login so somebody can manualy define when player class is used if the server is setup with it.
-Zombie |
|
Back to top |
|
|
~DH-CrackeR~
Joined: 01 Jul 2004 Posts: 7
|
Posted: Tue Aug 03, 2004 1:39 am Post subject: |
|
|
ahhh, well INF does that trick let me paste an example of respawning player classes
function playerpawn Login
(
string Portal,
string Options,
out string Error,
class<playerpawn> SpawnClass
)
{
local PlayerPawn newPlayer;
if (SpawnClass == class'MaleOne' || SpawnClass == class'MaleTwo' || SpawnClass == class'MaleThree' || SpawnClass == class'FemaleOne' || SpawnClass == class'FemaleTwo')
{
if (SpawnClass == class'MaleOne')
SpawnClass = class'INFIL_MalePlayer';
if (SpawnClass == class'MaleTwo')
SpawnClass = class'INFIL_MalePlayer2';
if (SpawnClass == class'MaleThree')
SpawnClass = class'INFIL_MalePlayer3';
if (SpawnClass == class'FemaleOne')
SpawnClass = class'INFIL_FemalePlayer1';
if (SpawnClass == class'FemaleTwo')
SpawnClass = class'INFIL_FemalePlayer';
}
else SpawnClass = class'INFIL_MalePlayer';
newPlayer = Super.Login(Portal, Options, Error, SpawnClass);
if ( newPlayer == None)
return None;
ChangeTeam(newPlayer, 2); // switch to spectator team
return newPlayer;
}
I dunno this might not be what you are trying to do, but maybe it will help eh?
need any more scripts like that lemme know _________________
|
|
Back to top |
|
|
K죣èr_§kā&#
Joined: 10 Jul 2004 Posts: 164
|
Posted: Mon Nov 15, 2004 11:53 pm Post subject: |
|
|
I have a problem too.I dont know how to make a mutator that replaces weapons,items,decorations etc.Can you help me out?I'm working on a new gametype with my friend sWAGMAn,and he would like me to make a mutator.
*Btw,does anyone want to join Team M.O.D?It stands for Makers Of Demise,and we really need members.Just go to my website to sign up. _________________ K죣èr_§kaarj
-|-Mess with me and you get the clàw§-|-
www.freewebs.com/killerskaarjslair |
|
Back to top |
|
|
Hyper
Joined: 24 Jan 2004 Posts: 1227 Location: Middelburg, The Netherlands
|
Posted: Tue Nov 16, 2004 1:41 am Post subject: |
|
|
I don't know anything about coding, but I DO know that there are several replacement mutators out there already. You might want to try WMutate from }TCP{Wolf or DZMapMutator from Zombie. _________________ Alter your reality...forever.
Hyper.nl Unreal Services
unreal://hypercoop.tk |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|