Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

First, include a mutations.xml in your mod that defines a new mutation.

Code Block
languagexml
titleMutatiosn.xml sample, adding a simple mod
linenumberstrue
collapsetrue
<?xml version="1.0" encoding="utf-8" ?>
<mutations>
  <category Name="Physical">
    <mutation Name="Udder" Cost="1" MaxSelected="1" Class="FreeholdTutorial_Udder" Exclusions="" Code="ea"></mutation>
 </category>
</mutations>

Then add a new .cs file in your mod that implements the class. Here's a skeletal implementation of the entry above. It must be in the XRL.World.Parts.Mutation namespace and must ultimately descend from BaseMutation. (Though not necessarily directly, if you have a very complex mod)

Code Block
languagec#
titleSkeletal mutation example.
linenumberstrue
collapsetrue
using System;
using System.Collections.Generic;
using System.Text;

using XRL.Rules;
using XRL.Messages;
using ConsoleLib.Console;

namespace XRL.World.Parts.Mutation
{
    [Serializable]
    class FreeholdTutorial_Udder : BaseMutation
    {
        public FreeholdTutorial_Udder()
        {
            Name = "FreeholdTutorial_Udder";
            DisplayName = "Udder";
        }

        public override void Register(GameObject Object)
        {
        }
        
        public override string GetDescription()
        {
            return "";
        }

        public override string GetLevelText(int Level)
        {
            string Ret = "You have udders.\n";
            return Ret;
        }

        public override bool BeforeRender(Event E)
        {
            if (ParentObject.IsPlayer())
            {
                if (ParentObject.pPhysics != null && ParentObject.pPhysics.CurrentCell != null)
                {
                    ParentObject.pPhysics.CurrentCell.ParentZone.AddLight(ParentObject.pPhysics.CurrentCell.X, ParentObject.pPhysics.CurrentCell.Y, Level, LightLevel.Darkvision);
                }
            }
            return true;
        }

        public override bool FireEvent(Event E)
        {
            return base.FireEvent(E);
        }

        public override bool ChangeLevel(int NewLevel)
        {
            return true;
        }

        public override bool Mutate(GameObject GO, int Level)
        {
            return true;
        }

        public override bool Unmutate(GameObject GO)
        {
            return true;
        }
    }
}

 

Here's a full example of the Flaming Hands mutation from the game's source code.

...