gameObjectScript - mtanksl/OpenTibia GitHub Wiki

Introduction

Behaviours can be attached during game object creation, using GameObjectScript.

Example

Let's attach a new Behaviour to all the monsters.

public class MonsterScript : GameObjectScript<Monster>
{
    public override void Start(Monster monster)
    {
        if (monster.Metadata.Voices != null)
        {
            Context.Server.GameObjectComponents.AddComponent(monster, new MonsterTalkBehaviour(monster.Metadata.Voices) );
        }
    }

    public override void Stop(Monster monster)
    {

    }
}

Edit the file \mtanksl.OpenTibia.GameData\data\gameobjectscripts\config.lua. If the monster's name is not found in the registration list, the empty name is used instead.

gameobjectscripts = {
    ...
    monsters = {
        { name = "", filename = "OpenTibia.Game.GameObjectScripts.MonsterScript" },
        ...
    },
    ...
}
⚠️ **GitHub.com Fallback** ⚠️