mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 21:40:05 +00:00
Grouped mobs adjustment
This commit is contained in:
parent
f1d04cec01
commit
dab536cb6a
@ -456,16 +456,18 @@ void MobManager::deadStep(Mob *mob, time_t currTime) {
|
|||||||
Mob* leaderMob = Mobs[mob->groupLeader];
|
Mob* leaderMob = Mobs[mob->groupLeader];
|
||||||
mob->appearanceData.iX = leaderMob->appearanceData.iX + mob->offsetX;
|
mob->appearanceData.iX = leaderMob->appearanceData.iX + mob->offsetX;
|
||||||
mob->appearanceData.iY = leaderMob->appearanceData.iY + mob->offsetY;
|
mob->appearanceData.iY = leaderMob->appearanceData.iY + mob->offsetY;
|
||||||
|
mob->appearanceData.iZ = leaderMob->appearanceData.iZ;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "[WARN] deadStep: mob cannot find it's leader!" << std::endl;
|
std::cout << "[WARN] deadStep: mob cannot find it's leader!" << std::endl;
|
||||||
mob->appearanceData.iX = mob->spawnX;
|
mob->appearanceData.iX = mob->spawnX;
|
||||||
mob->appearanceData.iY = mob->spawnY;
|
mob->appearanceData.iY = mob->spawnY;
|
||||||
|
mob->appearanceData.iZ = mob->spawnZ;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mob->appearanceData.iX = mob->spawnX;
|
mob->appearanceData.iX = mob->spawnX;
|
||||||
mob->appearanceData.iY = mob->spawnY;
|
mob->appearanceData.iY = mob->spawnY;
|
||||||
|
mob->appearanceData.iZ = mob->spawnZ;
|
||||||
}
|
}
|
||||||
mob->appearanceData.iZ = mob->spawnZ;
|
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_NPC_NEW, pkt);
|
INITSTRUCT(sP_FE2CL_NPC_NEW, pkt);
|
||||||
|
|
||||||
@ -566,8 +568,8 @@ void MobManager::combatStep(Mob *mob, time_t currTime) {
|
|||||||
int targetX = mob->target->plr->x;
|
int targetX = mob->target->plr->x;
|
||||||
int targetY = mob->target->plr->y;
|
int targetY = mob->target->plr->y;
|
||||||
if (mob->groupLeader != 0) {
|
if (mob->groupLeader != 0) {
|
||||||
targetX += mob->offsetX*distance/(mob->sightRange+1);
|
targetX += mob->offsetX*distance/(mob->idleRange + 1);
|
||||||
targetY += mob->offsetY*distance/(mob->sightRange+1);
|
targetY += mob->offsetY*distance/(mob->idleRange + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto targ = lerp(mob->appearanceData.iX, mob->appearanceData.iY, targetX, targetY, std::min(distance-(int)mob->data["m_iAtkRange"]+1, speed*2/5));
|
auto targ = lerp(mob->appearanceData.iX, mob->appearanceData.iY, targetX, targetY, std::min(distance-(int)mob->data["m_iAtkRange"]+1, speed*2/5));
|
||||||
@ -625,17 +627,17 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) {
|
|||||||
if (mob->staticPath)
|
if (mob->staticPath)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
if (mob->groupLeader != 0 && mob->groupLeader != mob->appearanceData.iNPC_ID) // don't roam by yourself without group leader
|
||||||
return;
|
return;
|
||||||
incNextMovement(mob, currTime);
|
|
||||||
/*
|
/*
|
||||||
* mob->nextMovement is also updated whenever the path queue is traversed in
|
* mob->nextMovement is also updated whenever the path queue is traversed in
|
||||||
* TransportManager::stepNPCPathing() (which ticks at a higher frequency than nextMovement),
|
* TransportManager::stepNPCPathing() (which ticks at a higher frequency than nextMovement),
|
||||||
* so we don't have to check if there's already entries in the queue since we know there won't be.
|
* so we don't have to check if there's already entries in the queue since we know there won't be.
|
||||||
*/
|
*/
|
||||||
|
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
||||||
if (mob->groupLeader != 0 && mob->groupLeader != mob->appearanceData.iNPC_ID) // don't roam by yourself without group leader
|
|
||||||
return;
|
return;
|
||||||
|
incNextMovement(mob, currTime);
|
||||||
|
|
||||||
int xStart = mob->spawnX - mob->idleRange/2;
|
int xStart = mob->spawnX - mob->idleRange/2;
|
||||||
int yStart = mob->spawnY - mob->idleRange/2;
|
int yStart = mob->spawnY - mob->idleRange/2;
|
||||||
@ -644,6 +646,10 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) {
|
|||||||
int farX, farY;
|
int farX, farY;
|
||||||
int distance; // for short walk detection
|
int distance; // for short walk detection
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't want the mob to just take one step and stop, so we make sure
|
||||||
|
* it has walked a half-decent distance.
|
||||||
|
*/
|
||||||
do {
|
do {
|
||||||
farX = xStart + rand() % mob->idleRange;
|
farX = xStart + rand() % mob->idleRange;
|
||||||
farY = yStart + rand() % mob->idleRange;
|
farY = yStart + rand() % mob->idleRange;
|
||||||
|
@ -76,6 +76,9 @@ struct Mob : public BaseNPC {
|
|||||||
roamY = spawnY = appearanceData.iY;
|
roamY = spawnY = appearanceData.iY;
|
||||||
roamZ = spawnZ = appearanceData.iZ;
|
roamZ = spawnZ = appearanceData.iZ;
|
||||||
|
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
|
||||||
appearanceData.iConditionBitFlag = 0;
|
appearanceData.iConditionBitFlag = 0;
|
||||||
|
|
||||||
// NOTE: there appear to be discrepancies in the dump
|
// NOTE: there appear to be discrepancies in the dump
|
||||||
|
@ -216,8 +216,8 @@ void TableData::init() {
|
|||||||
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
||||||
|
|
||||||
// handling groups
|
// handling groups
|
||||||
if (npc.find("iOffsetX") != npc.end() && MobManager::Mobs.find(nextId) != MobManager::Mobs.end()) {
|
if (npc.find("iOffsetX") != npc.end()) {
|
||||||
Mob* currNpc = MobManager::Mobs[nextId];
|
Mob* currNpc = (Mob*)tmp;
|
||||||
|
|
||||||
if (leaderMob == -1) {
|
if (leaderMob == -1) {
|
||||||
if (MobManager::Mobs.find(nextId-1) != MobManager::Mobs.end()) {
|
if (MobManager::Mobs.find(nextId-1) != MobManager::Mobs.end()) {
|
||||||
@ -231,7 +231,6 @@ void TableData::init() {
|
|||||||
} else {
|
} else {
|
||||||
if (MobManager::Mobs.find(leaderMob) != MobManager::Mobs.end()) {
|
if (MobManager::Mobs.find(leaderMob) != MobManager::Mobs.end()) {
|
||||||
Mob* leadNpc = MobManager::Mobs[leaderMob];
|
Mob* leadNpc = MobManager::Mobs[leaderMob];
|
||||||
leaderMob = leaderMob;
|
|
||||||
leadNpc->groupMember[leaderMobFollowers] = nextId;
|
leadNpc->groupMember[leaderMobFollowers] = nextId;
|
||||||
leaderMobFollowers++;
|
leaderMobFollowers++;
|
||||||
currNpc->groupLeader = leaderMob;
|
currNpc->groupLeader = leaderMob;
|
||||||
@ -240,7 +239,7 @@ void TableData::init() {
|
|||||||
|
|
||||||
currNpc->offsetX = (int)npc["iOffsetX"];
|
currNpc->offsetX = (int)npc["iOffsetX"];
|
||||||
currNpc->offsetY = npc.find("iOffsetY") == npc.end() ? 0 : (int)npc["iOffsetY"];
|
currNpc->offsetY = npc.find("iOffsetY") == npc.end() ? 0 : (int)npc["iOffsetY"];
|
||||||
std::cout << "[INFO] Added group NPC " << nextId << " to ID " << currNpc->groupLeader << std::endl;
|
std::cout << "[INFO] Added group NPC " << nextId << " to ID " << currNpc->groupLeader << std::endl; // TODO: get rid of this after testing
|
||||||
} else {
|
} else {
|
||||||
leaderMob = -1;
|
leaderMob = -1;
|
||||||
leaderMobFollowers = 0;
|
leaderMobFollowers = 0;
|
||||||
@ -674,7 +673,6 @@ void TableData::loadGruntwork(int32_t *nextId) {
|
|||||||
} else {
|
} else {
|
||||||
if (MobManager::Mobs.find(leaderMob) != MobManager::Mobs.end()) {
|
if (MobManager::Mobs.find(leaderMob) != MobManager::Mobs.end()) {
|
||||||
Mob* leadNpc = MobManager::Mobs[leaderMob];
|
Mob* leadNpc = MobManager::Mobs[leaderMob];
|
||||||
leaderMob = leaderMob;
|
|
||||||
leadNpc->groupMember[leaderMobFollowers] = id;
|
leadNpc->groupMember[leaderMobFollowers] = id;
|
||||||
leaderMobFollowers++;
|
leaderMobFollowers++;
|
||||||
currNpc->groupLeader = leaderMob;
|
currNpc->groupLeader = leaderMob;
|
||||||
|
Loading…
Reference in New Issue
Block a user