-
Notifications
You must be signed in to change notification settings - Fork 10
gameObjectScript
mtanksl edited this page Jun 23, 2024
·
3 revisions
Behaviours can be attached during game object creation, using GameObjectScript
.
Let's attach a new Behaviour
to all the monsters.
public class MonsterScript : GameObjectScript<Monster>
{
public override void Start(Monster monster)
{
if (monster.Metadata.Sentences != null && monster.Metadata.Sentences.Length > 0)
{
Context.Server.GameObjectComponents.AddComponent(monster, new CreatureTalkBehaviour(TalkType.MonsterSay, monster.Metadata.Sentences) );
}
}
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" },
...
},
...
}