Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revscript MonsterType Spell Fixes #3903

Merged
merged 8 commits into from
Apr 7, 2023
Merged

Conversation

theshibbies
Copy link
Contributor

@theshibbies theshibbies commented Jan 20, 2022

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.

@EPuncker
Copy link
Contributor

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

@emil92b
Copy link
Contributor

emil92b commented Jan 21, 2022

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}

@theshibbies
Copy link
Contributor Author

theshibbies commented Jan 21, 2022

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:


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}},

@emil92b
Copy link
Contributor

emil92b commented Jan 21, 2022

#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".

@theshibbies
Copy link
Contributor Author

#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.

Copy link
Contributor

@soul4soul soul4soul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah #3499 has the best examples, for real tibia spells and conditions only these two formats would be used

This gives melee with a condition
{name = "melee", attack = 10, skill = 100, condition = { type = CONDITION_FIRE, minDamage = 50, maxDamage = 200, duration = 5000, interval = 1000}},

This is an attack that causes a condition only.
{name = "condition", chance = 1000, range = 1, condition = { type = CONDITION_ENERGY, minDamage = 10, maxDamage = 20, duration = 5000, interval = 1000}},

Looking at the source code of the converter it looks correct but I'll actually test it when I get a chance.

data/monster/lua/#example.lua Show resolved Hide resolved
soul4soul
soul4soul previously approved these changes Jan 22, 2022
@soul4soul
Copy link
Contributor

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

ranisalt
ranisalt previously approved these changes Mar 22, 2022
Copy link
Member

@ranisalt ranisalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased against master

spell:setConditionDrunkenness(ability.drunkenness)
end
end
if ability.drunkenness then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@EPuncker EPuncker merged commit 2f4e76e into otland:master Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants