forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Revscript MonsterType Spell Fixes

Open theshibbies opened this issue 3 years ago • 6 comments

Pull Request Prelude

Protocol version Any

Changes Proposed

Spells aren't handled correctly in register_monster_type.lua, Not exactly sure if this is the fully correct way to handle these, but at least I am bringing the issue to everyones attention.

Issues addressed: Within revscript monstertype lua files, spells named "condition" wouldn't be registered and would cause errors. Spells named "drunk" would create condition twice, once at line 281 and again at line 331, which would cause all sorts of crashes. You can reproduce these errors by adding a monster lua file and adding these types of spells below.

{name ="condition", interval = 2000, chance = 30, type = CONDITION_POISON, startDamage = 0, tick = 4000, minDamage = -440, maxDamage = -520, radius = 5, target = false, effect = CONST_ME_POISONAREA}

{name ="drunk", interval = 2000, chance = 10, drunkenness = 25, duration = 5000, range = 7, shootEffect = CONST_ANI_ENERGY}

The easiest way is to convert the current monster xml files into revscript using this tool: https://otland.net/threads/ot-monster-converter.277546/

Note: You may need to create multiple files containing drunk spells in order to make the crash happen, not sure why though. Sometimes it crashes, sometimes it doesn't, the more files the easier it is to replicate.

theshibbies avatar Jan 20 '22 16:01 theshibbies

great! I would like to hear @soul4soul input on this as well

EPuncker avatar Jan 20 '22 17:01 EPuncker

https://github.com/otland/forgottenserver/blob/master/data/scripts/lib/register_monster_type.lua#L337-L354 {name ="condition", interval = x, chance = x, condition = { type = x , startDamage = x, minDamage = x, maxDamage = x, duration = x, interval = x}

emil92b avatar Jan 21 '22 06:01 emil92b

https://github.com/otland/forgottenserver/blob/master/data/scripts/lib/register_monster_type.lua#L337-L354 {name ="condition", interval = x, chance = x, condition = { type = x , startDamage = x, minDamage = x, maxDamage = x, duration = x, interval = x}

Pretty sure you'll still get an error from here: https://github.com/otland/forgottenserver/blob/b73ac8c77bd81471eef587f9d0e7c3b83256895c/data/scripts/lib/register_monster_type.lua#L281 I believe that section is more target to melee attacks that include a condition along with it. Like this: {name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -100, condition = {type = CONDITION_POISON, startDamage = 3, interval = 4000}},

theshibbies avatar Jan 21 '22 06:01 theshibbies

https://github.com/otland/forgottenserver/pull/3499 Allow conditions to be used with all predefine creature abilities. Conditions can be used with "melee", "combat", "speed", "condition", "outfit", "invisible", "*field", etc.. Conditions won't work with named spells such as "energy strike".

emil92b avatar Jan 21 '22 06:01 emil92b

#3499 Allow conditions to be used with all predefine creature abilities. Conditions can be used with "melee", "combat", "speed", "condition", "outfit", "invisible", "*field", etc.. Conditions won't work with named spells such as "energy strike".

Alright, great. I guess @soul4soul will have to check into adapting his system for this format. I reverted the changes for that part. However, the drunk spells are still an issue.

theshibbies avatar Jan 21 '22 08:01 theshibbies

This could use a rebase and add back the outfits spells and it would be good to go.

soul4soul avatar Mar 18 '22 15:03 soul4soul