[General] Rename mwmp::Attack vars in preparation for Actor support

pull/199/head
David Cernat 8 years ago
parent 2050d06b31
commit caf5428532

@ -629,7 +629,7 @@ namespace MWClass
mwmp::Main::get().getLocalPlayer()->attack.success = true;
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim);
if (dedicatedPlayer != nullptr)
mwmp::Main::get().getLocalPlayer()->attack.target = dedicatedPlayer->guid;
mwmp::Main::get().getLocalPlayer()->attack.targetGuid = dedicatedPlayer->guid;
}
/*
End of tes3mp addition
@ -930,8 +930,8 @@ namespace MWClass
{
mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack;
attack->damage = damage;
attack->attacker = mwmp::Main::get().getLocalPlayer()->guid;
attack->target = victimPlayer->guid;
attack->attackerGuid = mwmp::Main::get().getLocalPlayer()->guid;
attack->targetGuid = victimPlayer->guid;
attack->knockdown = getCreatureStats(ptr).getKnockedDown();
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();
attack.attacker = guid;
attack.attackerGuid = guid;
attack.type = Attack::MAGIC;
attack.pressed = true;
attack.refId = spell;
attack.spellId = spell;
}
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();
attack.success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, getPlayerPtr());
state = true;
attack.refId = spell;
attack.spellId = spell;
}
else
{
@ -1196,8 +1196,8 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state)
attack.type = type;
attack.knockdown = false;
attack.block = false;
attack.target = RakNet::RakNetGUID();
attack.attacker = guid;
attack.targetGuid = RakNet::RakNetGUID();
attack.attackerGuid = guid;
getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this);
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);
attackerStats.getSpells().setSelectedSpell(attack.refId);
attackerStats.getSpells().setSelectedSpell(attack.spellId);
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();
else if (Players::getPlayer(attack.target) != 0)
victim = Players::getPlayer(attack.target)->getPtr();
else if (Players::getPlayer(attack.targetGuid) != 0)
victim = Players::getPlayer(attack.targetGuid)->getPtr();
// Get the weapon used (if hand-to-hand, weapon = inv.end())
if (attackerStats.getDrawState() == MWMechanics::DrawState_Weapon)
@ -84,7 +84,7 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack)
}
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);
}
}

@ -8,8 +8,9 @@ namespace mwmp
class Attack
{
public:
RakNet::RakNetGUID target;
RakNet::RakNetGUID attacker;
RakNet::RakNetGUID targetGuid;
RakNet::RakNetGUID attackerGuid;
char type; // 0 - melee, 1 - magic, 2 - throwable
enum TYPE
{
@ -17,7 +18,8 @@ namespace mwmp
MAGIC,
THROWABLE
};
std::string refId; // id of spell (e.g. "fireball")
std::string spellId; // id of spell (e.g. "fireball")
char success;
char block;
float damage;

@ -16,9 +16,10 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->attack.attacker, send);
RW(player->attack.target, send);
RW(player->attack.refId, send);
RW(player->attack.attackerGuid, send);
RW(player->attack.targetGuid, send);
RW(player->attack.spellId, send);
RW(player->attack.type, send);
RW(player->attack.success, send);
RW(player->attack.damage, send);

Loading…
Cancel
Save