mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
[General] Rename mwmp::Attack vars in preparation for Actor support
This commit is contained in:
parent
2050d06b31
commit
caf5428532
5 changed files with 22 additions and 19 deletions
|
@ -629,7 +629,7 @@ namespace MWClass
|
||||||
mwmp::Main::get().getLocalPlayer()->attack.success = true;
|
mwmp::Main::get().getLocalPlayer()->attack.success = true;
|
||||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim);
|
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim);
|
||||||
if (dedicatedPlayer != nullptr)
|
if (dedicatedPlayer != nullptr)
|
||||||
mwmp::Main::get().getLocalPlayer()->attack.target = dedicatedPlayer->guid;
|
mwmp::Main::get().getLocalPlayer()->attack.targetGuid = dedicatedPlayer->guid;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
|
@ -930,8 +930,8 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack;
|
mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack;
|
||||||
attack->damage = damage;
|
attack->damage = damage;
|
||||||
attack->attacker = mwmp::Main::get().getLocalPlayer()->guid;
|
attack->attackerGuid = mwmp::Main::get().getLocalPlayer()->guid;
|
||||||
attack->target = victimPlayer->guid;
|
attack->targetGuid = victimPlayer->guid;
|
||||||
attack->knockdown = getCreatureStats(ptr).getKnockedDown();
|
attack->knockdown = getCreatureStats(ptr).getKnockedDown();
|
||||||
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types
|
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,10 +532,10 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
|
||||||
{
|
{
|
||||||
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
||||||
|
|
||||||
attack.attacker = guid;
|
attack.attackerGuid = guid;
|
||||||
attack.type = Attack::MAGIC;
|
attack.type = Attack::MAGIC;
|
||||||
attack.pressed = true;
|
attack.pressed = true;
|
||||||
attack.refId = spell;
|
attack.spellId = spell;
|
||||||
}
|
}
|
||||||
else if (state == MWMechanics::DrawState_Weapon)
|
else if (state == MWMechanics::DrawState_Weapon)
|
||||||
{
|
{
|
||||||
|
@ -1185,7 +1185,7 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state)
|
||||||
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
||||||
attack.success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, getPlayerPtr());
|
attack.success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, getPlayerPtr());
|
||||||
state = true;
|
state = true;
|
||||||
attack.refId = spell;
|
attack.spellId = spell;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1196,8 +1196,8 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state)
|
||||||
attack.type = type;
|
attack.type = type;
|
||||||
attack.knockdown = false;
|
attack.knockdown = false;
|
||||||
attack.block = false;
|
attack.block = false;
|
||||||
attack.target = RakNet::RakNetGUID();
|
attack.targetGuid = RakNet::RakNetGUID();
|
||||||
attack.attacker = guid;
|
attack.attackerGuid = guid;
|
||||||
|
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
|
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send();
|
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send();
|
||||||
|
|
|
@ -44,14 +44,14 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack)
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::CreatureStats &attackerStats = attacker.getClass().getNpcStats(attacker);
|
MWMechanics::CreatureStats &attackerStats = attacker.getClass().getNpcStats(attacker);
|
||||||
attackerStats.getSpells().setSelectedSpell(attack.refId);
|
attackerStats.getSpells().setSelectedSpell(attack.spellId);
|
||||||
|
|
||||||
MWWorld::Ptr victim;
|
MWWorld::Ptr victim;
|
||||||
|
|
||||||
if (attack.target == mwmp::Main::get().getLocalPlayer()->guid)
|
if (attack.targetGuid == mwmp::Main::get().getLocalPlayer()->guid)
|
||||||
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
else if (Players::getPlayer(attack.target) != 0)
|
else if (Players::getPlayer(attack.targetGuid) != 0)
|
||||||
victim = Players::getPlayer(attack.target)->getPtr();
|
victim = Players::getPlayer(attack.targetGuid)->getPtr();
|
||||||
|
|
||||||
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
||||||
if (attackerStats.getDrawState() == MWMechanics::DrawState_Weapon)
|
if (attackerStats.getDrawState() == MWMechanics::DrawState_Weapon)
|
||||||
|
@ -84,7 +84,7 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.refId.c_str());
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.spellId.c_str());
|
||||||
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success);
|
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,9 @@ namespace mwmp
|
||||||
class Attack
|
class Attack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RakNet::RakNetGUID target;
|
RakNet::RakNetGUID targetGuid;
|
||||||
RakNet::RakNetGUID attacker;
|
RakNet::RakNetGUID attackerGuid;
|
||||||
|
|
||||||
char type; // 0 - melee, 1 - magic, 2 - throwable
|
char type; // 0 - melee, 1 - magic, 2 - throwable
|
||||||
enum TYPE
|
enum TYPE
|
||||||
{
|
{
|
||||||
|
@ -17,7 +18,8 @@ namespace mwmp
|
||||||
MAGIC,
|
MAGIC,
|
||||||
THROWABLE
|
THROWABLE
|
||||||
};
|
};
|
||||||
std::string refId; // id of spell (e.g. "fireball")
|
|
||||||
|
std::string spellId; // id of spell (e.g. "fireball")
|
||||||
char success;
|
char success;
|
||||||
char block;
|
char block;
|
||||||
float damage;
|
float damage;
|
||||||
|
|
|
@ -16,9 +16,10 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(player->attack.attacker, send);
|
RW(player->attack.attackerGuid, send);
|
||||||
RW(player->attack.target, send);
|
RW(player->attack.targetGuid, send);
|
||||||
RW(player->attack.refId, send);
|
|
||||||
|
RW(player->attack.spellId, send);
|
||||||
RW(player->attack.type, send);
|
RW(player->attack.type, send);
|
||||||
RW(player->attack.success, send);
|
RW(player->attack.success, send);
|
||||||
RW(player->attack.damage, send);
|
RW(player->attack.damage, send);
|
||||||
|
|
Loading…
Reference in a new issue