Hercules icon indicating copy to clipboard operation
Hercules copied to clipboard

Centralize some config reading function and add support for constants in mob skill db

Open guilherme-gm opened this issue 2 years ago • 0 comments

Pull Request Prelude

Changes Proposed

The main objective of this PR is to allow the usage of constants and bitmask arrays in mob_skill_db.conf for fields that didn't support it yet.

This allows making configs a bit more readable and maybe less error prone as we have actual constants to use.

This change applies for the val* fields and Emotion, and now allows a config like: (Note: Yes, using val0 for NPC_EMOTION + Emotion doesn't make much sense, but serves as an example)

		NPC_EMOTION: {
			SkillState: "MSS_LOOT"
			SkillLevel: 1
			Rate: 2000
			Delay: 5000
			Cancelable: true
			SkillTarget: "MST_SELF"
			CastCondition: "MSC_ALWAYS"
			val0: "e_lv" //<-- Const instead of number
			val1: ["MD_CANMOVE", "MD_LOOTER"] //<-- Array with constants instead of bitmask number
			Emotion: "e_gg" //<-- Const instead of number
		}

As we already had functions to do that on itemdb (and also the same function for const in mob), I decided to centralize them in map.c (Thanks @4144 for the discussion :smile: ), this way we can use a single function and it doesn't look weird that monster is calling itemdb for no real reason.

Note: I was unsure whether I should make a script automatically update the files to use constants where possible. I am not sure if I know all the cases, but if you think it would be nice to have, I can work on a script that updates most common cases (such as slaves, emotion and mode changes)

Issues addressed: Closes #2768

guilherme-gm avatar Oct 12 '22 20:10 guilherme-gm