1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 04:45:34 +00:00

[General] Include effect and spell ID for summons in ObjectSpawn packets

This commit is contained in:
David Cernat 2019-12-01 13:31:11 +02:00
parent 610e0558c8
commit d78bdefc01
5 changed files with 29 additions and 6 deletions

View file

@ -111,8 +111,10 @@ namespace MWMechanics
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
MWMechanics::CreatureStats *actorCreatureStats = &mActor.getClass().getCreatureStats(mActor);
float duration = actorCreatureStats->getActiveSpells().getEffectDuration(it->first, it->second);
objectList->addObjectSpawn(placed, mActor, duration);
int effectId = it->first;
std::string spellId = it->second;
float duration = actorCreatureStats->getActiveSpells().getEffectDuration(effectId, it->second);
objectList->addObjectSpawn(placed, mActor, spellId, effectId, duration);
objectList->sendObjectSpawn();
}

View file

@ -449,8 +449,22 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
}
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
std::vector<ESM::ActiveEffect> activeEffects;
ESM::ActiveEffect activeEffect;
activeEffect.mDuration = baseObject.summonDuration;
activeEffect.mEffectId = baseObject.summonEffectId;
activeEffects.push_back(activeEffect);
LOG_APPEND(TimedLog::LOG_INFO, "- adding spell from ObjectList with id %s and effect %i",
baseObject.summonSpellId.c_str(), baseObject.summonEffectId);
masterCreatureStats.getActiveSpells().addSpell(baseObject.summonSpellId, false, activeEffects, "", masterCreatureStats.getActorId());
LOG_APPEND(TimedLog::LOG_INFO, "- setting summoned creature actor ID for %i-%i to %i",
newPtr.getCellRef().getRefNum(), newPtr.getCellRef().getMpNum(), creatureActorId);
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
}
}
@ -989,7 +1003,7 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr)
addObject(baseObject);
}
void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, float duration)
void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, std::string spellId, int effectId, float duration)
{
cell = *ptr.getCell()->getCell();
@ -998,6 +1012,8 @@ void ObjectList::addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& mas
baseObject.refNum = ptr.getCellRef().getRefNum().mIndex;
baseObject.mpNum = 0;
baseObject.isSummon = true;
baseObject.summonSpellId = spellId;
baseObject.summonEffectId = effectId;
baseObject.summonDuration = duration;
baseObject.master = MechanicsHelper::getTarget(master);

View file

@ -53,7 +53,7 @@ namespace mwmp
void addObjectActivate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& activatingActor);
void addObjectPlace(const MWWorld::Ptr& ptr, bool droppedByPlayer = false);
void addObjectSpawn(const MWWorld::Ptr& ptr);
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, float spawnDuration);
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, std::string spellId, int effectId, float duration);
void addObjectDelete(const MWWorld::Ptr& ptr);
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
void addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed);

View file

@ -65,6 +65,8 @@ namespace mwmp
Target activatingActor;
bool isSummon;
int summonEffectId;
std::string summonSpellId;
float summonDuration;
Target master;

View file

@ -13,12 +13,15 @@ void PacketObjectSpawn::Object(BaseObject &baseObject, bool send)
{
ObjectPacket::Object(baseObject, send);
RW(baseObject.position, send);
RW(baseObject.summonDuration, send);
RW(baseObject.isSummon, send);
if (baseObject.isSummon)
{
RW(baseObject.summonEffectId, send);
RW(baseObject.summonSpellId, send, true);
RW(baseObject.summonDuration, send);
RW(baseObject.master.isPlayer, send);
if (baseObject.master.isPlayer)