mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 15:24:44 +01:00
Implement healing props
This commit is contained in:
@@ -8,7 +8,9 @@ import emu.lunarcore.GameConstants;
|
|||||||
import emu.lunarcore.game.avatar.GameAvatar;
|
import emu.lunarcore.game.avatar.GameAvatar;
|
||||||
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
|
||||||
import emu.lunarcore.proto.LineupInfoOuterClass.LineupInfo;
|
import emu.lunarcore.proto.LineupInfoOuterClass.LineupInfo;
|
||||||
|
import emu.lunarcore.server.packet.send.PacketSyncLineupNotify;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Synchronized;
|
||||||
|
|
||||||
@Entity(useDiscriminator = false) @Getter
|
@Entity(useDiscriminator = false) @Getter
|
||||||
public class PlayerLineup {
|
public class PlayerLineup {
|
||||||
@@ -53,32 +55,26 @@ public class PlayerLineup {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
public List<Integer> getAvatars() {
|
||||||
|
return avatars;
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return avatars.size();
|
return getAvatars().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(GameAvatar avatar) {
|
public void heal(int heal) {
|
||||||
return getAvatars().contains(avatar.getAvatarId());
|
// Add hp to team
|
||||||
|
for (int avatarId : this.getAvatars()) {
|
||||||
|
GameAvatar avatar = this.getOwner().getAvatarById(avatarId);
|
||||||
|
if (avatar == null) continue;
|
||||||
|
|
||||||
|
avatar.setCurrentHp(Math.min(avatar.getCurrentHp() + heal, 10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAvatar(GameAvatar avatar) {
|
// Send packet
|
||||||
if (contains(avatar)) {
|
getOwner().sendPacket(new PacketSyncLineupNotify(this));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
getAvatars().add(avatar.getAvatarId());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean removeAvatar(int slot) {
|
|
||||||
if (size() <= 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
getAvatars().remove(slot);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LineupInfo toProto() {
|
public LineupInfo toProto() {
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public class EntityProp implements GameEntity {
|
|||||||
public void onRemove(Scene scene) {
|
public void onRemove(Scene scene) {
|
||||||
if (excel.isRecoverMp()) {
|
if (excel.isRecoverMp()) {
|
||||||
scene.getPlayer().getLineupManager().addMp(2);
|
scene.getPlayer().getLineupManager().addMp(2);
|
||||||
|
} else if (excel.isRecoverHp()) {
|
||||||
|
scene.getPlayer().getCurrentLineup().heal(2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user