soul4soul / ot-monster-converter Goto Github PK
View Code? Open in Web Editor NEWC# .NET 5 program for converting OpenTibia (OT) monsters between commonly used formats
C# .NET 5 program for converting OpenTibia (OT) monsters between commonly used formats
When converting the monsters, the "type" variable of the attack is being created only with "COMBAT_FIRE" and not "COMBAT_FIREDAMAGE"
Another observation is that the attack "melee" is being converted without "type" variable (in this case "COMBAT_PHYSICALDAMAGE")
PS: great tool. It was a great help. Congratulations.
<summons maxSummons="2">
<summon name="Poison Spider" interval="2000" chance="10" max="2" />
</summons>
The ability to convert to server or client ids is coded to work for monster loot only. However, some creature illusion spells cast by monster change the target into an item. In such case the item is specified by item id, more over some formats like TibiaWiki use the item name instead of the item id.
Overall the parser is okay, it's able to parse 1664 of the 1666 monsters listed on tibia wiki. Still, there are multiple issues with the deserializer logic that needs to be fixed. Here are all the known issues using the template parser with tibiawiki. Ideally the deserializer would be able to support any wiki media template. It'd be smart to look at the code wikimedia uses themselves for reference.
Reported on otland at https://otland.net/threads/ot-monster-converter.277546/post-2669922
stacks that are over 100 need to be split into multiple stacks.
When developing the converter I hit the wiki thousands of times a day. Each run of the program is over 2000 network requests. These requests are slow, waste bandwidth, and appear to cause throttling. One technique I use between runs is using a hard coded list of monsters to avoid all the network requests. A better solution would be to locally cache the wiki pages next to the executable to make them easy to manage and clear.
Expectations:
The improvement is a nice to have, it mainly helps developers. For end users, that use TW as an input source there is no reason to run the tool more then once a day, even once a week is enough in most cases as the data on the wiki is updated slowly.
Add support for revscriptsys input. I have received two requests from people wishing to convert from the revscriptsys lua format back to XML.
An example is bonebeast which converts all spells to physical element.
See #7 for additional information about spells in lua scripts.
These pages should be moved to generic tibiawiki pages instead of living under my user profile
Remember to update source code to point to new url
condition is not being properly converted
[Error - Monsters::deserializeSpell] - bonebeast - Condition is not set for: condition
> bonebeast.lua [loaded]
> bug.lua [loaded]
> butterflyblue.lua [loaded]
> butterflypurple.lua [loaded]
> butterflyred.lua [loaded]
> butterflyyellow.lua [loaded]
> carniphila.lua [loaded]
> caverat.lua [loaded]
> centipede.lua [loaded]
> chicken.lua [loaded]
[Error - Monsters::deserializeSpell] - cobra - Condition is not set for: condition
> cobra.lua [loaded]
> crab.lua [loaded]
> crocodile.lua [loaded]
> cryptshambler.lua [loaded]
> cyclops.lua [loaded]
> darkmonk.lua [loaded]
> deathslicer.lua [loaded]
> deer.lua [loaded]
> demodras.lua [loaded]
> demon.lua [loaded]
> demonskeleton.lua [loaded]
> dharalion.lua [loaded]
> dog.lua [loaded]
> dragon.lua [loaded]
> dragonlord.lua [loaded]
> dwarf.lua [loaded]
> dwarfgeomancer.lua [loaded]
> dwarfguard.lua [loaded]
> dwarfsoldier.lua [loaded]
> dworcfleshhunter.lua [loaded]
[Error - Monsters::deserializeSpell] - dworcvenomsniper - Condition is not set for: condition
> dworcvenomsniper.lua [loaded]
> dworcvoodoomaster.lua [loaded]
[Error - Monsters::deserializeSpell] - efreet - Condition is not set for: condition
> efreet.lua [loaded]
> elderbeholder.lua [loaded]
> elephant.lua [loaded]
> elf.lua [loaded]
> elfarcanist.lua [loaded]
> elfscout.lua [loaded]
> evileye.lua [loaded]
> fernfang.lua [loaded]
[Error - Monsters::deserializeSpell] - ferumbras - Condition is not set for: condition
[Error - Monsters::deserializeSpell] - ferumbras - Condition is not set for: condition
[Error - Monsters::deserializeSpell] - ferumbras - Condition is not set for: condition
> ferumbras.lua [loaded]
> firedevil.lua [loaded]
> fireelemental.lua [loaded]
> flamethrower.lua [loaded]
> flamingo.lua [loaded]
> frosttroll.lua [loaded]
> gamemaster.lua [loaded]
> gargoyle.lua [loaded]
> gazer.lua [loaded]
> ghost.lua [loaded]
> ghoul.lua [loaded]
> giantspider.lua [loaded]
> goblin.lua [loaded]
[Error - Monsters::deserializeSpell] - greendjinn - Condition is not set for: condition
> greendjinn.lua [loaded]
> grorlam.lua [loaded]
> halloweenhare.lua [loaded]
> hero.lua [loaded]
[Error - Monsters::deserializeSpell] - hornedfox - Condition is not set for: condition
> hornedfox.lua [loaded]
> human.lua [loaded]
> hunter.lua [loaded]
> hyaena.lua [loaded]
> hydra.lua [loaded]
> illusion.lua [loaded]
[Error - Monsters::deserializeSpell] - infernatil - Condition is not set for: condition
> infernatil.lua [loaded]
> kongra.lua [loaded]
> larva.lua [loaded]
[Error - Monsters::deserializeSpell] - lich - Condition is not set for: condition
> lich.lua [loaded]
> lion.lua [loaded]
> lizardsentinel.lua [loaded]
[Error - Monsters::deserializeSpell] - lizardsnakecharmer - Condition is not set for: condition
> lizardsnakecharmer.lua [loaded]
> lizardtemplar.lua [loaded]
> magicthrower.lua [loaded]
[Error - Monsters::deserializeSpell] - marid - Condition is not set for: condition
> marid.lua [loaded]
> merlkin.lua [loaded]
I've got a file with all monsters that are present in bestiary and their respective looktypes up to version 12.30
and I'm wondering if it would be useful to your project somehow to get monster looktype by name 😃
This is low priority as of today this information can only be parsed from TibiaWiki.
Only otservbr uses this information and the variation of RevScriptSys format they use is not supported at this time.
https://github.com/opentibiabr/canary has used this tool in the past, it was used to aid in convertering the creatures in their repo from XML to revscriptsys. They used a fork of the v2.0~ release which had many issues. Since then the program has under gone extensive changes which would make rebasing difficult.
Support for this format can be added with minimal effort since it's a derivative of the tfs revscriptsys format.
Tech implementation:
Not sure how I want to handle it yet, so far all converters have been in separate binaries. Due to the similarity with tfs revscriptsys format I'm thinking of adding it to the same binary. The current class can be changed to an abstract base class, which tfs and otserverbr classes can inherit. The base class can accept an enum to indicate TFS or otserv and have conditional checks as necessary. Instead of passing a enum to the baseclass the giant function to output the lua file can be split up into sub functions for general info, attacks, defensives, loot, immunities, etc.. and the inherited classes can override those when there are differences.
At the following code TFS XML defense spells are not parsed.
ot-monster-converter/OTMonsterConverter/Converter/TfsXmlConverter.cs
Lines 407 to 412 in e3a106c
Within the conditional something along the lines of monster.Attacks = XmlSpellsToGeneric(tfsMonster.defenses.defense);
needs to be added. XmlSpellsToGeneric
might need updates to support defense spells such as healing.
After fixing this its possible tfs revscriptsys might need changes for writing out these new spells.
If you try to convert a XML monster that have loot inside a bag, those are not converted to the new format.
Example of how it should be:
monster.loot = {
{id = "gold coin", chance = 60000, maxCount = 100},
{id = 1987, chance = 60000, -- bag
child = {
{id = "platinum coin", chance = 60000, maxCount = 100},
{id = "crystal coin", chance = 60000, maxCount = 100}
}
}
}
Example of how it is right now:
monster.loot = {
{id = 7393, chance = 600},
{id = 7382, chance = 575},
{id = 2472, chance = 575},
{id = 2418, chance = 1900},
{id = 2514, chance = 975},
{id = 2520, chance = 1225},
{id = 2470, chance = 900},
{id = 2393, chance = 2125},
{id = 2179, chance = 1575},
{id = 5954, chance = 1050},
{id = 2151, chance = 3625},
{id = 2396, chance = 1050},
{id = 2795, chance = 11425, maxCount = 6},
{id = 2462, chance = 1600},
{id = 2176, chance = 3225},
{id = 2165, chance = 1850},
{id = 1987, chance = 100000} --bag
}
Example of XML file:
<loot>
<item id="7393" chance="600" /><!-- demon trophy -->
<item id="7382" chance="575" /><!-- demonrage sword -->
<item id="2472" chance="575" /><!-- magic plate armor -->
<item id="2418" chance="1900" /><!-- golden sickle -->
<item id="2514" chance="975" /><!-- mastermind shield -->
<item id="2520" chance="1225" /><!-- demon shield -->
<item id="2470" chance="900" /><!-- golden legs -->
<item id="2393" chance="2125" /><!-- giant sword -->
<item id="2179" chance="1575" /><!-- gold ring -->
<item id="5954" chance="1050" /><!-- demon horn -->
<item id="2151" chance="3625" /><!-- talon -->
<item id="2396" chance="1050" /><!-- ice rapier -->
<item id="2795" countmax="6" chance="11425" /><!-- fire mushroom -->
<item id="2462" chance="1600" /><!-- devil helmet -->
<item id="2176" chance="3225" /><!-- orb -->
<item id="2165" chance="1850" /><!-- stealth ring -->
<item id="1987" chance="100000"><!-- bag -->
<item id="2164" chance="725" /><!-- might ring -->
<item id="2171" chance="1150" /><!-- platinum amulet -->
<item id="2432" chance="4325" /><!-- fire axe -->
<item id="1982" chance="1725" /><!-- purple tome -->
<item id="7368" countmax="5" chance="3375" /><!-- assassin star -->
<item id="2387" chance="18750" /><!-- double axe -->
<item id="7591" chance="700" /> <!-- great health potion -->
<item id="2214" chance="925" /><!-- ring of healing -->
<item id="2149" chance="9925" /><!-- small emerald -->
<item id="8473" countmax="3" chance="11550" /> <!-- ultimate health potion -->
<item id="2152" chance="66300" /><!-- platinum coin -->
<item id="7590" countmax="3" chance="8825" /> <!-- great mana potion -->
<item id="2148" countmax="100" chance="40800" /><!-- gold coin -->
<item id="2148" countmax="100" chance="40800" /><!-- gold coin -->
</item>
</loot>
Figure out what this value means, can it be used to figure out the creatures blood type or look type?
Hi as title says.
i have converted cipsoft monster to lua with this tool and they are working pretty cool
i wonder if you will or would release a tool to convert npcs from cipsoft to lua tried with this tool if its possible and at the momment it's not :( would be great if it could convert npcs to tfs revscripts or similar
and thank you in advance for this great tool
regards
With the PR for cip monster format open, there is now an issue of differentiating between server and client item ids. Hard coding a mapping into the monster converter is not favorable, I don't want to maintain it and it is error prone. So far no mapping have been hard coded into the program.
OTB format is a used by the entire OT community as a means of mapping between server and client item ids. The converter should support OTB format as a means to define a mapping between the item ids.
OTB files will not be shipped with this program. It's the user's responsibility to provide the OTB file to use with the converter.
Goals:
items.otb
next to the executableOptional:
items.otb
file can be provided on command line or via GUIKeepSouceIds -> KeepSourceIds
Often times information is missing from creature files. A new monster is created with some default values to fill in the gaps and make the conversion work better especially when moving between formats of different systems where values don't match exactly for example TibiaWiki to TFS. TibiaWiki has no concept of StaticAttack
so a default value is needed.
Instead of hard coding these values they should be made available as input so they can be set by the user. See monsters.cs for the current hard coded values
The TibiaWiki output is hand generated string output that matches wiki media template format. A more efficient way would be to create a generic serializer. Having a serializer would make #48 less of a chore.
A few monsters aren't coming with nameDescription="" filled, so what about filling it with name but lowercase, or same as name if boss=true
edit, same for race, what about making it blood for everyone until we have proper info at wiki?
Like Midnight Asura and Dawnfire Asura, I don't know why and most likely there are more
The monster converter has no concept of loot that is part of the reward chest. This feature is not yet in TFS otland/forgottenserver#1162 however its beginning to be included in TibiaWiki. For example on TibiaWiki Loot_Statistics:Ancient_Lion_Knight distinguishes between regular loot and reward chest loot. Because of this change in TibiaWiki Ancient_Lion_Knight loot is no longer parsed properly other monsters maybe be effected too.
Related to the reward chest is the cooperative loot system.
Otservbr doesn't have a tier system but loot items can be identified as unique drops.
Partial list of creatures using this system on TW:
TibiaWiki is great, most items include an itemid. The itemids should be fetched and stored along with the item name when building the loot list. The implementation should continue to be as respectful as possible to tibiawiki resources. Making a request for every item page would be very slow and would require over 6000 requests. Instead we should make a new page on the wiki which includes all items and lists their names and itemids in a single table. The DPL_Table template has a parameter to cache the table.
WIP DPL_Table
{{DPL Table|
| headers= !Name!!Id!!pickupable!
| table_class = wikitable sortable
| table_style = text-align:center;
| caption_style = text-align:center;
| tablerow = [[%TITLE%]]¦¦%%,%%
| no_results = There are no results.
| categories = Objects
| notcategorymatch= Deprecated¦Lists
| order_method = title
| sortcol = 0
| not_category = *
| uses_template = Template:Infobox Object
| includes= {Infobox Object}:itemid:pickupable
}}
so i have a few questions regarding some spells that didn't seem to work
using the CipMon > TfsRev for 1.5
currently it will make you invisible instead of monster / item
{name = "outfit", interval = 2000, chance = 17, monster = "rabbit", duration = 20000, range = 7, target = true, effect = CONST_ME_MAGIC_BLUE}
was it intentional that "min" should be higher than "max" or an error?
also i'm not sure how it should be working for paralyze/haste values, do i need to double the values or do you know the formula, coz it feels very weak right now using them on higher version than original 7.7
{name = "speed", interval = 2000, chance = 13, speed = {min = -100, max = -80}, duration = 25000, range = 7, target = true, shootEffect = CONST_ANI_POISON, effect = CONST_ME_POISONAREA},
i know this converter warned that it wasn't supporting it yet, but do you knw any other workaround?
{name = "drunk", interval = 2000, chance = 20, drunkenness = 60, duration = 30000, range = 7, target = true, shootEffect = CONST_ANI_ENERGY, effect = CONST_ME_TELEPORT},
also good job on the converter besides this i haven't had any issues, much appreciated!
For reference this was implemented at otland/forgottenserver#2826. Possible implementation thoughts. In the Spell
class replace SpeedChange
with MinSpeedChnage
and MaxChange
. In parsing of creatures always set both the min and max values.
This is a low priority as the feature is new in TFS and has a very low level of use as of today.
Add output of abilities and specifically include scene templates. The scene template would be helpful in contributing back to TibiaWiki
The scenario is that tgs monster could be converted to the tibiawiki format. Those files could be inspected and the ability and scene templates can be added back to TibiaWiki to improve the wiki for the entire community.
Support needs to be added for nested loot. Not all formats support nested loot. When converting from a format with nested loot to a format which doesn't support nested loot the loot will be changed to a flat loot format.
Formats which support nested loot: TFS XML, TFS revscript sys,
Formats which DONT support nested loot: TibiaWiki
Formats whose support is unknown: tibia 7.7 format, pyOT
This is a low priority issue as cipbia removed nested loot and its no longer commonly found in OT servers.
Not a big deal, just for consistence with the current files. Lets make loot attribute "countmax" after "chance" instead of before it
just to keep a little of consistency with tfs files
an optional thing:
<?xml version="1.0" encoding="UTF-8"?>
the one above
There are two type of scripts that can be added to monsters.
The script is a script attribute that can be added to the root monster node. See this PR for it's usage https://github.com/opentibiabr/otservbr-global/pull/1624
The second is the script element that can be added to monsters. The node can contain multiple instances of a name
element. See scarab.xml for an example.
TibiaWiki added a flag to indicate attacktype which is the attack stance of a creature melee, distance, or none. We can update the parse for tibiawiki to use this flag instead of guessing based on information in the behavior field. Reference diff https://tibia.fandom.com/wiki/Template:Infobox_Creature?diff=prev&oldid=909680
Update tibiawiki parse to parser to support single values and ranges for the "runon" value
imo dont adapt to TFS, it should adapt to your converter! for example use cipsoft chance values for everything, that means base speed, loot, spells etc. makes more sense to change the formula in tfs based on the correct values instead.
monsters have some of their "outfit" and "invisible" spells converted to attacks rather than defense and vice versa
haste/paralyze speed spells should use "base" and "variation"
demon/illusion name for register
missing space in some summon names
voice should not convert "interval" and "chance" instead use a formula in tfs, also minotaur mage "#W" should be yell = true
flamethrower, magicthrower, plaguethrower, shredderthrower should have item lookTypeEx = 0
monsters that are convincable is missing summonCost value
monster melee condition auto attacks
target strategy values (closest, weakest, strongest, random)
monster training https://otland.net/threads/7-7-realots-7-7-cipsoft-files-virgin.244562/page-57#post-2685321
Some creatures spells are too complex for the TFS XML spell system. In order to support complex spells TFS XML monsters supports calling spells written in lua. This is accomplished by adding a spell element with the attribute name "script" and a attribute file which is a path to a lua file. OT monster converter skips parsing these spells.
Adding generic support for these spells would be more difficult then the spells which use the XML spell system. What would be feasible is to parse the information and use it when converting to another TFS monster format that could use lua spells. This would means the spells would be parsed and written in a TFS XML to TFS revscriptsys conversion. The spells would be dropped when converting to non TFS formats.
current order of elements:
- flags
- immunities
- elements
- attacks
- defense
- voice
- summon
- loot
trying to make it more tfs alike (to make updating current tfs-master monsters easier):
- flags
- attacks
- defense
- elements
- immunities
- summon
- voice
- loot
Today, to run this project on Linux one must fork the code, remove the WPF UI classes, change the target from net5.0-windows
to net5.0
, and finally compile.
Compiling on Linux should be made easier by conditional including the files to compile based on the runtime environment available on the system. A blog post from MS mentions the ability here. A sample project can be found here.
Lich output example:
<summons maxSummons="4">
<voice name="Bonebeast" interval="2000" chance="15" max="1" />
</summons>
its confusing to have two max summons with different values (4 and 1)
| spawntype = Regular, Unique, Unblockable
Formats that require updates to support this flag
some sort of pink spark right after the map effect
and the "CONFETTI" effects are actually fireworks 😛
btw this is what I intend to add to master tfs when protocol 12 get in:
https://github.com/otland/forgottenserver/pull/3744/files#diff-d59c4f2b28dd8c6d0ff82b05e0188d97a98401483ad487dfd67d665a01506f39R116-R166
The logic for attacks which cause elemental damages is not working. Below is the only research that went into fixing the problem. This example was take from a Lich poison beam attack which causes poison condition.
This was initially used but fails to load.
{name ="poisoncondition", interval = 2000, chance = 10, length = 7, spread = 3, effect = CONST_ME_HITBYPOISON, target = false}
This is used now but doesn't make much sense since the condition to cause is not included. At least the fail to load problem went away.
{name ="condition", interval = 2000, chance = 10, length = 7, spread = 3, effect = CONST_ME_HITBYPOISON, target = false}
cipbia monsters from 7.7 have been readily available on the web for sometime. OT monster converter could support converting from this format to common OT formats. There is not much reason to add support for writing out to this format as it has nearly no use in the community.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.