mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-04 23:38:28 +07:00
Created DamageHandler and implemented hit sounds
This commit is contained in:
@ -10,6 +10,7 @@ import com.artemis.annotations.Wire;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.Animation;
|
||||
import com.riiablo.codec.excel.Missiles;
|
||||
import com.riiablo.codec.excel.MonStats;
|
||||
@ -103,6 +104,10 @@ public abstract class AI implements Interactable.Interactor {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void hit() {
|
||||
Riiablo.audio.play(monsound + "_hit_1", true);
|
||||
}
|
||||
|
||||
public void kill() {}
|
||||
|
||||
protected Angle lookAt(int target) {
|
||||
|
22
core/src/com/riiablo/engine/client/DamageHandler.java
Normal file
22
core/src/com/riiablo/engine/client/DamageHandler.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.riiablo.engine.client;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
import net.mostlyoriginal.api.event.common.Subscribe;
|
||||
import net.mostlyoriginal.api.system.core.PassiveSystem;
|
||||
|
||||
import com.riiablo.engine.server.component.AIWrapper;
|
||||
import com.riiablo.engine.server.event.DamageEvent;
|
||||
import com.riiablo.logger.LogManager;
|
||||
import com.riiablo.logger.Logger;
|
||||
|
||||
public class DamageHandler extends PassiveSystem {
|
||||
private static final Logger log = LogManager.getLogger(DamageHandler.class);
|
||||
|
||||
protected ComponentMapper<AIWrapper> mAIWrapper;
|
||||
|
||||
@Subscribe
|
||||
public void onDamageEvent(DamageEvent event) {
|
||||
log.traceEntry("onDamageEvent(attacker: {}, victim: {}, damage: {})", event.attacker, event.victim, event.damage);
|
||||
mAIWrapper.get(event.victim).ai.hit();
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package com.riiablo.engine.client;
|
||||
import net.mostlyoriginal.api.event.common.Subscribe;
|
||||
import net.mostlyoriginal.api.system.core.PassiveSystem;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.excel.Skills;
|
||||
import com.riiablo.engine.server.event.SkillCastEvent;
|
||||
@ -20,6 +22,14 @@ public class SkillCastHandler extends PassiveSystem {
|
||||
public void onSkillCast(SkillCastEvent event) {
|
||||
}
|
||||
|
||||
private static final ObjectMap<String, String> HITCLASS = new ObjectMap<>();
|
||||
static {
|
||||
HITCLASS.put("1hss", "weapon_1hs_small_1");
|
||||
HITCLASS.put("1hsl", "weapon_1hs_large_1");
|
||||
HITCLASS.put("2hss", "weapon_2hs_small_1");
|
||||
HITCLASS.put("2hsl", "weapon_2hs_large_1");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void srvstfunc(SkillStartEvent event) {
|
||||
log.traceEntry("srvstfunc(entityId: {}, srvstfunc: {}, targetId: {}, targetVec: {})",
|
||||
@ -88,6 +98,7 @@ public class SkillCastHandler extends PassiveSystem {
|
||||
case 0:
|
||||
break;
|
||||
case 1: // attack
|
||||
Riiablo.audio.play("weapon_1hs_large_1", true); // TODO: hclass of swung weapon
|
||||
break;
|
||||
case 25: // shouts / novas
|
||||
break;
|
||||
|
@ -57,6 +57,7 @@ import com.riiablo.engine.client.CofResolver;
|
||||
import com.riiablo.engine.client.CofTransformHandler;
|
||||
import com.riiablo.engine.client.CofUnloader;
|
||||
import com.riiablo.engine.client.CursorMovementSystem;
|
||||
import com.riiablo.engine.client.DamageHandler;
|
||||
import com.riiablo.engine.client.DeathHandler;
|
||||
import com.riiablo.engine.client.DialogManager;
|
||||
import com.riiablo.engine.client.DirectionResolver;
|
||||
@ -578,6 +579,7 @@ public class GameScreen extends ScreenAdapter implements GameLoadingScreen.Loada
|
||||
.with(new SkillCastHandler()) // TODO: move to more appropriate spot in list
|
||||
.with(new OverlayManager()) // TODO: move to more appropriate spot in list
|
||||
.with(new OverlayStepper()) // TODO: move to more appropriate spot in list
|
||||
.with(new DamageHandler()) // TODO: move to more appropriate spot in list
|
||||
.with(new DeathHandler()) // TODO: move to more appropriate spot in list
|
||||
;
|
||||
if (socket == null) {
|
||||
|
Reference in New Issue
Block a user