From f04df9feda2ce7f53c845fef0f08e3a2155e8b20 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Apr 2023 19:51:38 +0700 Subject: [PATCH] root.monsterSkillParameter --- .../kotlin/ru/dbotthepony/kstarbound/Starbound.kt | 13 +++++++++++++ .../defs/monster/MonsterSkillDefinition.kt | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterSkillDefinition.kt diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 533fd9c1..454dda7f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -33,6 +33,7 @@ import ru.dbotthepony.kstarbound.defs.item.impl.ItemPrototype import ru.dbotthepony.kstarbound.defs.item.impl.LegsArmorItemPrototype import ru.dbotthepony.kstarbound.defs.item.impl.LiquidItemPrototype import ru.dbotthepony.kstarbound.defs.item.impl.MaterialItemPrototype +import ru.dbotthepony.kstarbound.defs.monster.MonsterSkillDefinition import ru.dbotthepony.kstarbound.defs.npc.NpcTypeDefinition import ru.dbotthepony.kstarbound.defs.npc.TenantDefinition import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition @@ -148,6 +149,9 @@ class Starbound : ISBFileLocator { private val _treasurePools = ObjectRegistry("treasure pools", TreasurePoolDefinition::name) val treasurePools = _treasurePools.view + private val _monsterSkills = ObjectRegistry("monster skills", MonsterSkillDefinition::name) + val monsterSkills = _monsterSkills.view + val gson: Gson = with(GsonBuilder()) { serializeNulls() setDateFormat(DateFormat.LONG) @@ -724,6 +728,14 @@ class Starbound : ISBFileLocator { 1 } + state.setTableFunction("monsterSkillParameter", this) { args -> + val name = args.getString() + val param = args.getString() + // parity: если скила не существует, то оригинальный движок просто возвращает nil + args.push(monsterSkills[name]?.value?.config?.get(param)) + 1 + } + state.pop() state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua") @@ -918,6 +930,7 @@ class Starbound : ISBFileLocator { loadStage(callback, _npcTypes, ext2files["npctype"] ?: listOf()) loadStage(callback, _projectiles, ext2files["projectile"] ?: listOf()) loadStage(callback, _tenants, ext2files["tenant"] ?: listOf()) + loadStage(callback, _monsterSkills, ext2files["monsterskill"] ?: listOf()) pathStack.block("/") { //playerDefinition = gson.fromJson(locate("/player.config").reader(), PlayerDefinition::class.java) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterSkillDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterSkillDefinition.kt new file mode 100644 index 00000000..3c9b01d0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterSkillDefinition.kt @@ -0,0 +1,15 @@ +package ru.dbotthepony.kstarbound.defs.monster + +import com.google.common.collect.ImmutableMap +import com.google.gson.JsonElement +import ru.dbotthepony.kstarbound.defs.image.ImageReference +import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory + +@JsonFactory +data class MonsterSkillDefinition( + val name: String, + val label: String? = null, + val image: ImageReference? = null, + val config: ImmutableMap = ImmutableMap.of(), + val animationParameters: ImmutableMap = ImmutableMap.of(), +)