Skip to content

Commit

Permalink
feat(Npc): add news APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Jan 21, 2024
1 parent 2bf1ecd commit 21c3951
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 1 deletion.
46 changes: 46 additions & 0 deletions include/zenkit-capi/vobs/Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using ZkTouchDamage = ZkSharedHandle<zenkit::VTouchDamage>;
using ZkEarthquake = ZkSharedHandle<zenkit::VEarthquake>;
using ZkNpcTalent = ZkSharedHandle<zenkit::VNpc::Talent>;
using ZkNpcSlot = zenkit::VNpc::Slot;
using ZkNpcNews = zenkit::VNpc::News;
#else
typedef struct ZkInternal_Animate ZkAnimate;
typedef struct ZkInternal_Item ZkItem;
Expand All @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
141 changes: 141 additions & 0 deletions src/vobs/Misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<long>(i));
}

ZkNpcNews* ZkNpc_addNews(ZkNpc* slf) {
ZKC_TRACE_FN();
ZKC_CHECK_NULL(slf);
SLF->news.push_back(std::make_unique<ZkNpcNews>());
return SLF->news.back().get();
}

int ZkNpc_getProtection(ZkNpc const* slf, ZkSize i) {
ZKC_TRACE_FN();
ZKC_CHECK_NULL(slf);
Expand Down Expand Up @@ -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<ZkNpcNewsSpread>(slf->spread_type);
}

ZkNpcNewsId ZkNpcNews_getNewsId(ZkNpcNews const* slf) {
ZKC_TRACE_FN();
ZKC_CHECK_NULL(slf);
return static_cast<ZkNpcNewsId>(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<zenkit::VNpc::NewsSpread>(spreadType);
}

void ZkNpcNews_setNewsId(ZkNpcNews* slf, ZkNpcNewsId newsId) {
ZKC_TRACE_FN();
ZKC_CHECK_NULLV(slf);
slf->news_id = static_cast<zenkit::VNpc::NewsId>(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;
}
2 changes: 1 addition & 1 deletion vendor/ZenKit

0 comments on commit 21c3951

Please sign in to comment.