mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-26 06:50:06 +00:00
Implement rudimentary NPC scripting framework and Lord Fuse boss fight
This commit is contained in:
parent
3359ca0c3e
commit
d25e7ca4fc
@ -404,6 +404,11 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
// delay the despawn animation
|
// delay the despawn animation
|
||||||
mob->despawned = false;
|
mob->despawned = false;
|
||||||
|
|
||||||
|
// fire any triggered events
|
||||||
|
for (NPCEvent& event : NPCManager::NPCEvents)
|
||||||
|
if (event.trigger == ON_KILLED && event.npcType == mob->appearanceData.iNPCType)
|
||||||
|
event.handler(sock, mob);
|
||||||
|
|
||||||
auto it = TransportManager::NPCQueues.find(mob->appearanceData.iNPC_ID);
|
auto it = TransportManager::NPCQueues.find(mob->appearanceData.iNPC_ID);
|
||||||
if (it == TransportManager::NPCQueues.end() || it->second.empty())
|
if (it == TransportManager::NPCQueues.end() || it->second.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -816,3 +816,57 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) {
|
|||||||
egg->appearanceData.iHP = 0;
|
egg->appearanceData.iHP = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region NPCEvents
|
||||||
|
|
||||||
|
// summon right arm and stage 2 body
|
||||||
|
static void lordFuseStageTwo(CNSocket *sock, BaseNPC *npc) {
|
||||||
|
Mob *oldbody = (Mob*)npc; // adaptium, stun
|
||||||
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
std::cout << "Lord Fuse stage two" << std::endl;
|
||||||
|
|
||||||
|
// Fuse doesn't move; spawnX, etc. is shorter to write than *appearanceData*
|
||||||
|
// Blastons, Heal
|
||||||
|
Mob *newbody = (Mob*)NPCManager::summonNPC(oldbody->spawnX, oldbody->spawnY, oldbody->spawnZ, plr->instanceID, 2467);
|
||||||
|
|
||||||
|
newbody->appearanceData.iAngle = oldbody->appearanceData.iAngle;
|
||||||
|
NPCManager::updateNPCPosition(newbody->appearanceData.iNPC_ID, newbody->spawnX, newbody->spawnY, newbody->spawnZ,
|
||||||
|
plr->instanceID, oldbody->appearanceData.iAngle);
|
||||||
|
|
||||||
|
// right arm, Adaptium, Stun
|
||||||
|
Mob *arm = (Mob*)NPCManager::summonNPC(oldbody->spawnX - 600, oldbody->spawnY, oldbody->spawnZ, plr->instanceID, 2469);
|
||||||
|
|
||||||
|
arm->appearanceData.iAngle = oldbody->appearanceData.iAngle;
|
||||||
|
NPCManager::updateNPCPosition(arm->appearanceData.iNPC_ID, arm->spawnX, arm->spawnY, arm->spawnZ,
|
||||||
|
plr->instanceID, oldbody->appearanceData.iAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// summon left arm and stage 3 body
|
||||||
|
static void lordFuseStageThree(CNSocket *sock, BaseNPC *npc) {
|
||||||
|
Mob *oldbody = (Mob*)npc;
|
||||||
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
std::cout << "Lord Fuse stage three" << std::endl;
|
||||||
|
|
||||||
|
// Cosmic, Damage Point
|
||||||
|
Mob *newbody = (Mob*)NPCManager::summonNPC(oldbody->spawnX, oldbody->spawnY, oldbody->spawnZ, plr->instanceID, 2468);
|
||||||
|
|
||||||
|
newbody->appearanceData.iAngle = oldbody->appearanceData.iAngle;
|
||||||
|
NPCManager::updateNPCPosition(newbody->appearanceData.iNPC_ID, newbody->spawnX, newbody->spawnY, newbody->spawnZ,
|
||||||
|
plr->instanceID, oldbody->appearanceData.iAngle);
|
||||||
|
|
||||||
|
// Blastons, Heal
|
||||||
|
Mob *arm = (Mob*)NPCManager::summonNPC(oldbody->spawnX + 600, oldbody->spawnY, oldbody->spawnZ, plr->instanceID, 2470);
|
||||||
|
|
||||||
|
arm->appearanceData.iAngle = oldbody->appearanceData.iAngle;
|
||||||
|
NPCManager::updateNPCPosition(arm->appearanceData.iNPC_ID, arm->spawnX, arm->spawnY, arm->spawnZ,
|
||||||
|
plr->instanceID, oldbody->appearanceData.iAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<NPCEvent> NPCManager::NPCEvents = {
|
||||||
|
NPCEvent(2466, ON_KILLED, lordFuseStageTwo),
|
||||||
|
NPCEvent(2467, ON_KILLED, lordFuseStageThree),
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma endregion NPCEvents
|
||||||
|
@ -12,6 +12,22 @@
|
|||||||
|
|
||||||
#define RESURRECT_HEIGHT 400
|
#define RESURRECT_HEIGHT 400
|
||||||
|
|
||||||
|
// placeholder; there's only one trigger type right now
|
||||||
|
enum Trigger {
|
||||||
|
ON_KILLED
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void (*NPCEventHandler)(CNSocket*, BaseNPC*);
|
||||||
|
|
||||||
|
struct NPCEvent {
|
||||||
|
int32_t npcType;
|
||||||
|
int trigger;
|
||||||
|
NPCEventHandler handler;
|
||||||
|
|
||||||
|
NPCEvent(int32_t t, int tr, NPCEventHandler hndlr)
|
||||||
|
: npcType(t), trigger(tr), handler(hndlr) {}
|
||||||
|
};
|
||||||
|
|
||||||
// this should really be called vec3 or something...
|
// this should really be called vec3 or something...
|
||||||
struct WarpLocation {
|
struct WarpLocation {
|
||||||
int x, y, z, instanceID, isInstance, limitTaskID, npcID;
|
int x, y, z, instanceID, isInstance, limitTaskID, npcID;
|
||||||
@ -40,6 +56,7 @@ namespace NPCManager {
|
|||||||
extern std::map<int32_t, BaseNPC*> NPCs;
|
extern std::map<int32_t, BaseNPC*> NPCs;
|
||||||
extern std::map<int32_t, WarpLocation> Warps;
|
extern std::map<int32_t, WarpLocation> Warps;
|
||||||
extern std::vector<WarpLocation> RespawnPoints;
|
extern std::vector<WarpLocation> RespawnPoints;
|
||||||
|
extern std::vector<NPCEvent> NPCEvents;
|
||||||
extern std::unordered_map<int, Egg*> Eggs;
|
extern std::unordered_map<int, Egg*> Eggs;
|
||||||
extern std::map<std::pair<CNSocket*, int32_t>, time_t> EggBuffs;
|
extern std::map<std::pair<CNSocket*, int32_t>, time_t> EggBuffs;
|
||||||
extern std::unordered_map<int, EggType> EggTypes;
|
extern std::unordered_map<int, EggType> EggTypes;
|
||||||
|
Loading…
Reference in New Issue
Block a user