From 21c3951f6d2554b59c3f29f02a6fd6b615366070 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Sun, 21 Jan 2024 17:58:19 +0100 Subject: [PATCH] feat(Npc): add news APIs --- include/zenkit-capi/vobs/Misc.h | 46 +++++++++++ src/vobs/Misc.cc | 141 ++++++++++++++++++++++++++++++++ vendor/ZenKit | 2 +- 3 files changed, 188 insertions(+), 1 deletion(-) diff --git a/include/zenkit-capi/vobs/Misc.h b/include/zenkit-capi/vobs/Misc.h index 7ebb973..8610cd0 100644 --- a/include/zenkit-capi/vobs/Misc.h +++ b/include/zenkit-capi/vobs/Misc.h @@ -21,6 +21,7 @@ using ZkTouchDamage = ZkSharedHandle; using ZkEarthquake = ZkSharedHandle; using ZkNpcTalent = ZkSharedHandle; using ZkNpcSlot = zenkit::VNpc::Slot; +using ZkNpcNews = zenkit::VNpc::News; #else typedef struct ZkInternal_Animate ZkAnimate; typedef struct ZkInternal_Item ZkItem; @@ -33,6 +34,7 @@ typedef struct ZkInternal_TouchDamager ZkTouchDamage; typedef struct ZkInternal_Earthquake ZkEarthquake; typedef struct ZkInternal_NpcTalent ZkNpcTalent; typedef struct ZkInternal_NpcSlot ZkNpcSlot; +typedef struct ZkInternal_NpcNews ZkNpcNews; #endif typedef enum { @@ -57,6 +59,24 @@ typedef enum { ZkTouchCollisionType_POINT = 2, } ZkTouchCollisionType; +typedef enum { + ZkNpcNewsId_MURDER = 200, + ZkNpcNewsId_ATTACK = 195, + ZkNpcNewsId_THEFT = 190, + ZkNpcNewsId_DEFEAT = 185, + ZkNpcNewsId_NERVE = 180, + ZkNpcNewsId_INTERFERE = 175, + ZkNpcNewsId_HAS_DEFEATED = 170, +} ZkNpcNewsId; + +typedef enum { + ZkNpcNewsSpread_DONT_SPREAD = 0, + ZkNpcNewsSpread_FRIENDLY_TOWARDS_VICTIM = 1, + ZkNpcNewsSpread_FRIENDLY_TOWARDS_WITNESS = 2, + ZkNpcNewsSpread_FRIENDLY_TOWARDS_OFFENDER = 3, + ZkNpcNewsSpread_SAME_GUILD_VICTIM = 4, +} ZkNpcNewsSpread; + ZKC_API ZkAnimate* ZkAnimate_load(ZkRead* buf, ZkGameVersion version); ZKC_API ZkAnimate* ZkAnimate_loadPath(ZkString path, ZkGameVersion version); ZKC_API void ZkAnimate_del(ZkAnimate* slf); @@ -294,6 +314,12 @@ ZKC_API void ZkNpc_clearSlots(ZkNpc* slf); ZKC_API void ZkNpc_removeSlot(ZkNpc* slf, ZkSize i); ZKC_API ZkNpcSlot* ZkNpc_addSlot(ZkNpc* slf); +ZKC_API ZkSize ZkNpc_getNewsCount(ZkNpc const* slf); +ZKC_API ZkNpcNews* ZkNpc_getNews(ZkNpc const* slf, ZkSize i); +ZKC_API void ZkNpc_clearNews(ZkNpc* slf); +ZKC_API void ZkNpc_removeNews(ZkNpc* slf, ZkSize i); +ZKC_API ZkNpcNews* ZkNpc_addNews(ZkNpc* slf); + ZKC_API int ZkNpc_getProtection(ZkNpc const* slf, ZkSize i); ZKC_API void ZkNpc_setProtection(ZkNpc* slf, ZkSize i, int v); @@ -329,3 +355,23 @@ ZKC_API void ZkNpcSlot_setUsed(ZkNpcSlot* slf, ZkBool used); ZKC_API void ZkNpcSlot_setName(ZkNpcSlot* slf, ZkString name); ZKC_API void ZkNpcSlot_setItem(ZkNpcSlot* slf, ZkItem* item); ZKC_API void ZkNpcSlot_setInInventory(ZkNpcSlot* slf, ZkBool inInventory); + +ZKC_API ZkBool ZkNpcNews_getTold(ZkNpcNews const* slf); +ZKC_API float ZkNpcNews_getSpreadTime(ZkNpcNews const* slf); +ZKC_API ZkNpcNewsSpread ZkNpcNews_getSpreadType(ZkNpcNews const* slf); +ZKC_API ZkNpcNewsId ZkNpcNews_getNewsId(ZkNpcNews const* slf); +ZKC_API ZkBool ZkNpcNews_getGossip(ZkNpcNews const* slf); +ZKC_API ZkBool ZkNpcNews_getGuildVictim(ZkNpcNews const* slf); +ZKC_API ZkString ZkNpcNews_getWitnessName(ZkNpcNews const* slf); +ZKC_API ZkString ZkNpcNews_getOffenderName(ZkNpcNews const* slf); +ZKC_API ZkString ZkNpcNews_getVictimName(ZkNpcNews const* slf); + +ZKC_API void ZkNpcNews_setTold(ZkNpcNews* slf, ZkBool told); +ZKC_API void ZkNpcNews_setSpreadTime(ZkNpcNews* slf, float spreadTime); +ZKC_API void ZkNpcNews_setSpreadType(ZkNpcNews* slf, ZkNpcNewsSpread spreadType); +ZKC_API void ZkNpcNews_setNewsId(ZkNpcNews* slf, ZkNpcNewsId newsId); +ZKC_API void ZkNpcNews_setGossip(ZkNpcNews* slf, ZkBool gossip); +ZKC_API void ZkNpcNews_setGuildVictim(ZkNpcNews* slf, ZkBool guildVictim); +ZKC_API void ZkNpcNews_setWitnessName(ZkNpcNews* slf, ZkString witnessName); +ZKC_API void ZkNpcNews_setOffenderName(ZkNpcNews* slf, ZkString offenderName); +ZKC_API void ZkNpcNews_setVictimName(ZkNpcNews* slf, ZkString victimName); diff --git a/src/vobs/Misc.cc b/src/vobs/Misc.cc index dad370d..bf99b46 100644 --- a/src/vobs/Misc.cc +++ b/src/vobs/Misc.cc @@ -1237,6 +1237,39 @@ ZkNpcSlot* ZkNpc_addSlot(ZkNpc* slf) { return SLF->slots.back().get(); } +ZkSize ZkNpc_getNewsCount(ZkNpc const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return SLF->news.size(); +} + +ZkNpcNews* ZkNpc_getNews(ZkNpc const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(SLF->news, i); + return SLF->news[i].get(); +} + +void ZkNpc_clearNews(ZkNpc* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + SLF->news.clear(); +} + +void ZkNpc_removeNews(ZkNpc* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + ZKC_CHECK_LENV(SLF->news, i); + SLF->news.erase(SLF->news.begin() + static_cast(i)); +} + +ZkNpcNews* ZkNpc_addNews(ZkNpc* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + SLF->news.push_back(std::make_unique()); + return SLF->news.back().get(); +} + int ZkNpc_getProtection(ZkNpc const* slf, ZkSize i) { ZKC_TRACE_FN(); ZKC_CHECK_NULL(slf); @@ -1419,3 +1452,111 @@ void ZkNpcSlot_setInInventory(ZkNpcSlot* slf, ZkBool inInventory) { ZKC_CHECK_NULLV(slf); slf->in_inventory = inInventory; } + +ZkBool ZkNpcNews_getTold(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->told; +} + +float ZkNpcNews_getSpreadTime(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->spread_time; +} + +ZkNpcNewsSpread ZkNpcNews_getSpreadType(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return static_cast(slf->spread_type); +} + +ZkNpcNewsId ZkNpcNews_getNewsId(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return static_cast(slf->news_id); +} + +ZkBool ZkNpcNews_getGossip(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->gossip; +} + +ZkBool ZkNpcNews_getGuildVictim(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->guild_victim; +} + +ZkString ZkNpcNews_getWitnessName(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->witness_name.c_str(); +} + +ZkString ZkNpcNews_getOffenderName(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->offender_name.c_str(); +} + +ZkString ZkNpcNews_getVictimName(ZkNpcNews const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->victim_name.c_str(); +} + +void ZkNpcNews_setTold(ZkNpcNews* slf, ZkBool told) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->told = told; +} + +void ZkNpcNews_setSpreadTime(ZkNpcNews* slf, float spreadTime) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->spread_time = spreadTime; +} + +void ZkNpcNews_setSpreadType(ZkNpcNews* slf, ZkNpcNewsSpread spreadType) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->spread_type = static_cast(spreadType); +} + +void ZkNpcNews_setNewsId(ZkNpcNews* slf, ZkNpcNewsId newsId) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->news_id = static_cast(newsId); +} + +void ZkNpcNews_setGossip(ZkNpcNews* slf, ZkBool gossip) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->gossip = gossip; +} + +void ZkNpcNews_setGuildVictim(ZkNpcNews* slf, ZkBool guildVictim) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->guild_victim = guildVictim; +} + +void ZkNpcNews_setWitnessName(ZkNpcNews* slf, ZkString witnessName) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->witness_name = witnessName; +} + +void ZkNpcNews_setOffenderName(ZkNpcNews* slf, ZkString offenderName) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->offender_name = offenderName; +} + +void ZkNpcNews_setVictimName(ZkNpcNews* slf, ZkString victimName) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf); + slf->victim_name = victimName; +} diff --git a/vendor/ZenKit b/vendor/ZenKit index 1589353..42efd41 160000 --- a/vendor/ZenKit +++ b/vendor/ZenKit @@ -1 +1 @@ -Subproject commit 158935353a6677c0c6878e653b59815e40dbef91 +Subproject commit 42efd418d172b19766330af1cf709aa27a18fb6a