mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
[Client] Add and use mwmp::PlayerList::isDedicatedPlayer()
This commit is contained in:
parent
b1a394cd02
commit
07c2d4251e
6 changed files with 26 additions and 20 deletions
|
@ -627,9 +627,9 @@ namespace MWClass
|
|||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->attack.success = true;
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::PlayerList::getPlayer(victim);
|
||||
if (dedicatedPlayer != nullptr)
|
||||
mwmp::Main::get().getLocalPlayer()->attack.target.guid = dedicatedPlayer->guid;
|
||||
|
||||
if (mwmp::PlayerList::isDedicatedPlayer(victim))
|
||||
mwmp::Main::get().getLocalPlayer()->attack.target.guid = mwmp::PlayerList::getPlayer(victim)->guid;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
@ -804,13 +804,7 @@ namespace MWClass
|
|||
If the attacker is a DedicatedPlayer with a successful knockdown, apply the knockdown;
|
||||
otherwise, use default probability roll
|
||||
*/
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::PlayerList::getPlayer(attacker);
|
||||
bool isDedicated = dedicatedPlayer != nullptr;
|
||||
bool isDedicatedKnockdown = false;
|
||||
if (isDedicated)
|
||||
isDedicatedKnockdown = dedicatedPlayer->attack.knockdown;
|
||||
|
||||
if (isDedicatedKnockdown)
|
||||
if (mwmp::PlayerList::isDedicatedPlayer(attacker) && mwmp::PlayerList::getPlayer(attacker)->attack.knockdown)
|
||||
stats.setKnockedDown(true);
|
||||
else if (ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99())
|
||||
/*
|
||||
|
@ -925,13 +919,15 @@ namespace MWClass
|
|||
If the victim was the LocalPlayer, check whether packets should be sent about
|
||||
their new dynamic stats and position
|
||||
*/
|
||||
mwmp::DedicatedPlayer *victimPlayer = mwmp::PlayerList::getPlayer(ptr);
|
||||
if (attacker == MWMechanics::getPlayer() && victimPlayer != nullptr)
|
||||
if (attacker == MWMechanics::getPlayer() && mwmp::PlayerList::isDedicatedPlayer(ptr))
|
||||
{
|
||||
mwmp::DedicatedPlayer *victimPlayer = mwmp::PlayerList::getPlayer(ptr);
|
||||
|
||||
mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack;
|
||||
attack->damage = damage;
|
||||
attack->target.guid = victimPlayer->guid;
|
||||
attack->knockdown = getCreatureStats(ptr).getKnockedDown();
|
||||
|
||||
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types
|
||||
}
|
||||
|
||||
|
|
|
@ -1132,9 +1132,8 @@ namespace MWMechanics
|
|||
|
||||
If this actor is a DedicatedPlayer, update their mAttackingOrSpell
|
||||
*/
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::PlayerList::getPlayer(iter->first);
|
||||
if (dedicatedPlayer != NULL)
|
||||
dedicatedPlayer->updateActor(iter->second);
|
||||
if (mwmp::PlayerList::isDedicatedPlayer(iter->first))
|
||||
mwmp::PlayerList::getPlayer(iter->first)->updateActor(iter->second);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -123,13 +123,13 @@ namespace MWMechanics
|
|||
Only calculate block chance for blockers who are not DedicatedPlayers
|
||||
and update block state for LocalPlayer
|
||||
*/
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::PlayerList::getPlayer(blocker);
|
||||
bool isDedicated = dedicatedPlayer != NULL;
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->attack.block = false;
|
||||
|
||||
bool isDedicated = mwmp::PlayerList::isDedicatedPlayer(blocker);
|
||||
|
||||
if ((!isDedicated && Misc::Rng::roll0to99() < x) ||
|
||||
(isDedicated && dedicatedPlayer->attack.block == 1))
|
||||
(isDedicated && mwmp::PlayerList::getPlayer(blocker)->attack.block == true))
|
||||
{
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->attack.block = true;
|
||||
|
|
|
@ -849,14 +849,15 @@ namespace MWMechanics
|
|||
can be accounted for like it is in OpenMW's corresponding code
|
||||
*/
|
||||
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::PlayerList::getPlayer(mCaster);
|
||||
bool isDedicated = dedicatedPlayer != NULL;
|
||||
|
||||
bool isDedicated = mwmp::PlayerList::isDedicatedPlayer(mCaster);
|
||||
|
||||
if (isDedicated)
|
||||
dedicatedPlayer->attack.pressed = false;
|
||||
|
||||
// Check success
|
||||
if ((!isDedicated && !mwmp::Main::get().getLocalPlayer()->attack.success) ||
|
||||
(isDedicated && dedicatedPlayer->attack.success == 0))
|
||||
(isDedicated && dedicatedPlayer->attack.success == false))
|
||||
{
|
||||
if (mCaster == getPlayer())
|
||||
{
|
||||
|
|
|
@ -233,6 +233,14 @@ DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
if (getPlayer(ptr))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DedicatedPlayer::move(float dt)
|
||||
{
|
||||
if (state != 2) return;
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace mwmp
|
|||
static DedicatedPlayer *getPlayer(RakNet::RakNetGUID guid);
|
||||
static DedicatedPlayer *getPlayer(const MWWorld::Ptr &ptr);
|
||||
|
||||
static bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
|
||||
|
||||
private:
|
||||
|
||||
static std::map<RakNet::RakNetGUID, DedicatedPlayer *> players;
|
||||
|
|
Loading…
Reference in a new issue