• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Canary Help with monster new attribute

Eduardo Mattos

New Member
Joined
Apr 25, 2016
Messages
2
Reaction score
1
Hello guys,

I'm implementing a new feature on a Canary server and i have some questions (i'm kinda new to ot's sources development), i'm trying to add a new attribute to monsters called warFaction, i configured it in creatures in the sources (because players will also have this warFaction attribute), i already made getFaction and setFaction work fine in lua files but the problem is that i dont know how to make a monster have this warFaction by default (write it in the monster_name.lua file and the monster spawns with the warFaction set), i'll write below the code i would like to use to make it more clear to understand:


Lua:
local mType = Game.createMonsterType("Faction Tester")
local monster = {}

monster.description = "a faction tester"
monster.experience = 6000
monster.outfit = {
    lookType = 35,
    lookHead = 0,
    lookBody = 0,
    lookLegs = 0,
    lookFeet = 0,
    lookAddons = 0,
    lookMount = 0,
}

monster.warFaction = 2 -- this line here is what i need to know how i make it work in the sorces so that monsters can spawn with the faction already set

If someone can help me to understand how this code would translate in the sources i would appreciate it, thank you!
 
Solution
You could either set it by just calling the function mType:setWarFaction(x) (or whatever you named the function) or you go to data/scripts/lib/register_monster_type.lua (assuming canary didn't change the directory) and add your functions in there to have it working like you want to do in your example
You could either set it by just calling the function mType:setWarFaction(x) (or whatever you named the function) or you go to data/scripts/lib/register_monster_type.lua (assuming canary didn't change the directory) and add your functions in there to have it working like you want to do in your example
 
Solution
Thank you @Evil Hero, i was able to do it in the file you said plus another one on sources, i followed the example of other properties that already existed:

  • data\scripts\lib\register_monster_type.lua
  • src\lua\functions\creatures\monster\monster_type_functions.hpp

Now when i set the property in the lua file the sources are able to read it
 
Back
Top