Skip to content

Commit

Permalink
[12683] Implement CreatureLinking Flag DESPAWN_ON_DESPAWN
Browse files Browse the repository at this point in the history
Thanks to grz3s for testing and feedback.
  • Loading branch information
Schmoozerd committed Jul 18, 2014
1 parent af0c505 commit e37d292
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void Creature::RemoveCorpse()
if (AI())
AI()->CorpseRemoved(respawnDelay);

if (m_isCreatureLinkingTrigger)
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DESPAWN, this);

// script can set time (in seconds) explicit, override the original
if (respawnDelay)
m_respawnTime = time(NULL) + respawnDelay;
Expand Down
8 changes: 8 additions & 0 deletions src/game/CreatureLinkingMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ enum EventMask
EVENT_MASK_ON_DIE = FLAG_DESPAWN_ON_DEATH | FLAG_SELFKILL_ON_DEATH | FLAG_RESPAWN_ON_DEATH | FLAG_FOLLOW,
EVENT_MASK_ON_RESPAWN = FLAG_RESPAWN_ON_RESPAWN | FLAG_DESPAWN_ON_RESPAWN | FLAG_FOLLOW,
EVENT_MASK_TRIGGER_TO = FLAG_TO_AGGRO_ON_AGGRO | FLAG_TO_RESPAWN_ON_EVADE | FLAG_FOLLOW,
EVENT_MASK_ON_DESPAWN = FLAG_DESPAWN_ON_DESPAWN,
};

// This functions checks if the NPC has linked NPCs for dynamic action
Expand Down Expand Up @@ -414,6 +415,7 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp
case LINKING_EVENT_EVADE: eventFlagFilter = EVENT_MASK_ON_EVADE; reverseEventFlagFilter = FLAG_TO_RESPAWN_ON_EVADE; break;
case LINKING_EVENT_DIE: eventFlagFilter = EVENT_MASK_ON_DIE; reverseEventFlagFilter = 0; break;
case LINKING_EVENT_RESPAWN: eventFlagFilter = EVENT_MASK_ON_RESPAWN; reverseEventFlagFilter = FLAG_FOLLOW; break;
case LINKING_EVENT_DESPAWN: eventFlagFilter = EVENT_MASK_ON_DESPAWN; reverseEventFlagFilter = 0; break;
}

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Jul 27, 2014

Author Member

exactly ;)

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Jul 28, 2014

Author Member

well, this part of code could be written differently in quite some ways.

This is one way that is relatively clear in my opinion.

This comment has been minimized.

Copy link
@evil-at-wow

evil-at-wow Jul 28, 2014

Contributor

I have the feeling that @sanctum32 missed the minor difference between RESPAWN and DESPAWN.


// Process Slaves (by entry)
Expand Down Expand Up @@ -471,6 +473,7 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp
SetFollowing(pSource, pMaster);
break;
case LINKING_EVENT_DIE: // Nothing linked for this case
case LINKING_EVENT_DESPAWN: // Nothing linked for this case
break;
}
}
Expand Down Expand Up @@ -550,6 +553,11 @@ void CreatureLinkingHolder::ProcessSlave(CreatureLinkingEvent eventType, Creatur
if (flag & FLAG_FOLLOW && pSlave->isAlive() && !pSlave->isInCombat())
SetFollowing(pSlave, pSource);

break;
case LINKING_EVENT_DESPAWN:
if (flag & FLAG_DESPAWN_ON_DESPAWN && !pSlave->IsDespawned())
pSlave->ForcedDespawn();

break;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/game/CreatureLinkingMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum CreatureLinkingEvent
LINKING_EVENT_EVADE = 1,
LINKING_EVENT_DIE = 2,
LINKING_EVENT_RESPAWN = 3,
LINKING_EVENT_DESPAWN = 4,
};

// enum describing possible flags action flags for NPCs linked to other NPCs
Expand All @@ -71,12 +72,13 @@ enum CreatureLinkingFlags

// Dynamic behaviour, out of combat
FLAG_FOLLOW = 0x0200,
FLAG_DESPAWN_ON_DESPAWN = 0x2000,

// Passive behaviour
FLAG_CANT_SPAWN_IF_BOSS_DEAD = 0x0400,
FLAG_CANT_SPAWN_IF_BOSS_ALIVE = 0x0800,

LINKING_FLAG_INVALID = 0x2000, // TODO adjust when other flags are implemented
LINKING_FLAG_INVALID = 0x4000, // TODO adjust when other flags are implemented
};

// Structure holding the information for an entry
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12682"
#define REVISION_NR "12683"
#endif // __REVISION_NR_H__

1 comment on commit e37d292

@Grz3s
Copy link
Member

@Grz3s Grz3s commented on e37d292 Jul 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

Please sign in to comment.