mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-01-17 00:06:00 -05:00
Merge pull request #205 from madsboddum/201
Healing, buffing and attack results displayed correctly in the combat log
This commit is contained in:
Submodule pswgcommon updated: dc734c6556...a467fa58c4
@@ -28,11 +28,16 @@
|
||||
package com.projectswg.holocore.services.gameplay.combat.command;
|
||||
|
||||
import com.projectswg.common.data.combat.AttackInfo;
|
||||
import com.projectswg.common.data.combat.CombatSpamType;
|
||||
import com.projectswg.common.data.combat.HitLocation;
|
||||
import com.projectswg.common.data.combat.TrailLocation;
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.data.encodables.oob.ProsePackage;
|
||||
import com.projectswg.common.data.encodables.oob.StringId;
|
||||
import com.projectswg.common.data.encodables.tangible.PvpStatus;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction.Defender;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatSpam;
|
||||
import com.projectswg.holocore.resources.support.data.server_info.loader.combat.FactionLoader;
|
||||
import com.projectswg.holocore.resources.support.global.commands.CombatCommand;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
|
||||
@@ -42,7 +47,6 @@ import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject
|
||||
|
||||
import static com.projectswg.holocore.services.gameplay.combat.command.CombatCommandCommon.addBuff;
|
||||
import static com.projectswg.holocore.services.gameplay.combat.command.CombatCommandCommon.createCombatAction;
|
||||
import static com.projectswg.holocore.services.gameplay.combat.command.CombatCommandCommon.createCombatSpam;
|
||||
|
||||
enum CombatCommandBuff implements CombatCommandHitType {
|
||||
INSTANCE;
|
||||
@@ -60,20 +64,20 @@ enum CombatCommandBuff implements CombatCommandHitType {
|
||||
}
|
||||
|
||||
boolean applyToSelf = isApplyToSelf(source, target);
|
||||
CreatureObject effectiveTarget = applyToSelf ? source : target;
|
||||
|
||||
String buffNameTarget = combatCommand.getBuffNameTarget();
|
||||
|
||||
addBuff(source, applyToSelf ? source : target, buffNameTarget);
|
||||
addBuff(source, effectiveTarget, buffNameTarget);
|
||||
|
||||
WeaponObject weapon = source.getEquippedWeapon();
|
||||
CombatAction combatAction = createCombatAction(source, weapon, TrailLocation.RIGHT_HAND, combatCommand);
|
||||
combatAction.addDefender(new Defender(source.getObjectId(), source.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0));
|
||||
|
||||
if (!buffNameTarget.isEmpty()) {
|
||||
combatAction.addDefender(new Defender(target.getObjectId(), target.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0));
|
||||
combatAction.addDefender(new Defender(target.getObjectId(), effectiveTarget.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0));
|
||||
}
|
||||
|
||||
source.sendObservers(combatAction, createCombatSpam(source, target, weapon, new AttackInfo(), combatCommand));
|
||||
source.sendObservers(combatAction, createCombatSpamPerform(source, effectiveTarget, combatCommand));
|
||||
}
|
||||
|
||||
private boolean isApplyToSelf(CreatureObject source, CreatureObject target) {
|
||||
@@ -115,4 +119,26 @@ enum CombatCommandBuff implements CombatCommandHitType {
|
||||
return false;
|
||||
}
|
||||
|
||||
static CombatSpam createCombatSpamPerform(CreatureObject source, CreatureObject target, CombatCommand command) {
|
||||
CombatSpam spam = new CombatSpam(source.getObjectId());
|
||||
|
||||
spam.setAttacker(source.getObjectId());
|
||||
spam.setAttackerPosition(source.getLocation().getPosition());
|
||||
spam.setDefender(target.getObjectId());
|
||||
spam.setDefenderPosition(target.getLocation().getPosition());
|
||||
spam.setInfo(new AttackInfo());
|
||||
spam.setDataType((byte) 2); // 2 means the combat log entry is a specified message
|
||||
|
||||
if (source.equals(target)) {
|
||||
OutOfBandPackage oobp = new OutOfBandPackage(new ProsePackage("StringId", new StringId("cbt_spam", "perform_notarget"), "TU", source.getObjectName(), "TO", new StringId("cmd_n", command.getName())));
|
||||
spam.setSpamMessage(oobp);
|
||||
} else {
|
||||
OutOfBandPackage oobp = new OutOfBandPackage(new ProsePackage("StringId", new StringId("cbt_spam", "perform_target"), "TU", source.getObjectName(), "TO", new StringId("cmd_n", command.getName()), "TT", target.getObjectName()));
|
||||
spam.setSpamMessage(oobp);
|
||||
}
|
||||
spam.setSpamType(CombatSpamType.BUFF);
|
||||
|
||||
return spam;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponType;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -79,7 +80,19 @@ public class CombatCommandCommon {
|
||||
combatSpam.setDefenderPosition(target.getLocation().getPosition());
|
||||
combatSpam.setInfo(info);
|
||||
combatSpam.setAttackName(new StringId("cmd_n", command.getName()));
|
||||
combatSpam.setSpamType(info.isSuccess() ? CombatSpamFilterType.SELF : CombatSpamFilterType.ALL);
|
||||
|
||||
if (info.isSuccess()) {
|
||||
if (info.isBlockResult()) {
|
||||
combatSpam.setSpamType(CombatSpamType.BLOCK);
|
||||
} else if (info.isEvadeResult()) {
|
||||
combatSpam.setSpamType(CombatSpamType.EVADE);
|
||||
} else {
|
||||
combatSpam.setSpamType(CombatSpamType.HIT);
|
||||
}
|
||||
} else {
|
||||
combatSpam.setSpamType(CombatSpamType.MISS);
|
||||
}
|
||||
|
||||
return combatSpam;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
package com.projectswg.holocore.services.gameplay.combat.command;
|
||||
|
||||
import com.projectswg.common.data.RGB;
|
||||
import com.projectswg.common.data.combat.AttackInfo;
|
||||
import com.projectswg.common.data.combat.HitLocation;
|
||||
import com.projectswg.common.data.combat.TrailLocation;
|
||||
import com.projectswg.common.data.combat.*;
|
||||
import com.projectswg.common.data.encodables.oob.OutOfBandPackage;
|
||||
import com.projectswg.common.data.encodables.oob.ProsePackage;
|
||||
import com.projectswg.common.data.encodables.oob.StringId;
|
||||
@@ -42,13 +40,13 @@ import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyT
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText.Scale;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction.Defender;
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatSpam;
|
||||
import com.projectswg.holocore.resources.support.global.commands.CombatCommand;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject;
|
||||
|
||||
import static com.projectswg.holocore.services.gameplay.combat.command.CombatCommandCommon.createCombatAction;
|
||||
import static com.projectswg.holocore.services.gameplay.combat.command.CombatCommandCommon.createCombatSpam;
|
||||
|
||||
enum CombatCommandHeal implements CombatCommandHitType {
|
||||
INSTANCE;
|
||||
@@ -138,6 +136,7 @@ enum CombatCommandHeal implements CombatCommandHitType {
|
||||
healed.modifyHealth(healAmount);
|
||||
difference = healed.getHealth() - currentHealth;
|
||||
attribName = "HEALTH";
|
||||
healed.sendObservers(createCombatSpam(healer, healed, healAmount));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -175,9 +174,23 @@ enum CombatCommandHeal implements CombatCommandHitType {
|
||||
}
|
||||
|
||||
|
||||
// TODO doesn't look like a heal in the combat log
|
||||
healed.sendObservers(combatAction, flyText, effect);
|
||||
}
|
||||
|
||||
private static CombatSpam createCombatSpam(CreatureObject healer, CreatureObject healed, int healAmount) {
|
||||
CombatSpam spam = new CombatSpam(healer.getObjectId());
|
||||
|
||||
healed.sendObservers(combatAction, flyText, effect, createCombatSpam(healer, healed, weapon, new AttackInfo(), combatCommand));
|
||||
spam.setAttacker(healer.getObjectId());
|
||||
spam.setAttackerPosition(healer.getLocation().getPosition());
|
||||
spam.setDefender(healed.getObjectId());
|
||||
spam.setDefenderPosition(healed.getLocation().getPosition());
|
||||
spam.setInfo(new AttackInfo());
|
||||
spam.setDataType((byte) 2); // 2 means the combat log entry is a specified message
|
||||
OutOfBandPackage oobp = new OutOfBandPackage(new ProsePackage("StringId", new StringId("healing", "perform_heal_damage_success"), "TT", healer.getObjectName(), "TO", healed.getObjectName(), "DI", healAmount));
|
||||
spam.setSpamMessage(oobp);
|
||||
spam.setSpamType(CombatSpamType.MEDICAL);
|
||||
|
||||
return spam;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user