Fixed in client for shoot event. Weapon system now damages health on any target not only players.
This commit is contained in:
@@ -22,3 +22,4 @@ X=EditorToggleTransformSpace
|
|||||||
C=ConnectToServer
|
C=ConnectToServer
|
||||||
N=SwitchToServer
|
N=SwitchToServer
|
||||||
M=SwitchToClient
|
M=SwitchToClient
|
||||||
|
P=SwitchToPlayer
|
||||||
@@ -310,9 +310,9 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
|
|||||||
|
|
||||||
bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
|
bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
|
||||||
{
|
{
|
||||||
Packet packet(MessageType::OnInputCommand, m_SendPacketID);
|
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
|
||||||
packet.WritePrimitive(e.DamageAmount);
|
packet.WritePrimitive(e.DamageAmount);
|
||||||
packet.WritePrimitive(e.PlayerDamagedID);
|
packet.WritePrimitive(m_ClientIDToServerID.at(e.PlayerDamagedID));
|
||||||
send(packet);
|
send(packet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ HealthSystem::HealthSystem(World* m_World, EventBroker* eventBroker)
|
|||||||
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||||
{
|
{
|
||||||
//if entityID of health is 9 then the players ID is also 9 (player,health are connected to the same entity)
|
//if entityID of health is 9 then the players ID is also 9 (player,health are connected to the same entity)
|
||||||
ComponentWrapper player = m_World->GetComponent(component.EntityID, "Player");
|
|
||||||
double maxHealth = (double)component["MaxHealth"];
|
double maxHealth = (double)component["MaxHealth"];
|
||||||
|
|
||||||
//process the DeltaHealthVector and change the entitys health accordingly
|
//process the DeltaHealthVector and change the entitys health accordingly
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ void WeaponSystem::Update(double dt)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//if its a player, do PlayerDamage event
|
//if its a player, do PlayerDamage event
|
||||||
const bool hasPlayerComponent = m_World->HasComponent(pickDataFromShot.Entity, "Player");
|
const bool hasHealthComponent = m_World->HasComponent(pickDataFromShot.Entity, "Health");
|
||||||
if (hasPlayerComponent) {
|
if (hasHealthComponent) {
|
||||||
Events::PlayerDamage ePlayerDamage;
|
Events::PlayerDamage ePlayerDamage;
|
||||||
//TODO: damage based on weapontype/class?
|
//TODO: damage based on weapontype/class?
|
||||||
//TODO: multiple shots at the same time? (shotgunner)
|
//TODO: multiple shots at the same time? (shotgunner)
|
||||||
|
|||||||
Reference in New Issue
Block a user