I have four scenarios:
Actor (the player) receives damage from an enemy.
Actor receives damage from another actor.
Enemy receives damage from an actor (the player).
Enemy receives damage from another enemy.
How can I distinguish each scenario and run different code accordingly?
The following gives the error: "TypeError. Cannot read property isForOpponent of undefined"
Alternatively, if I can figure out how to do BattleManager._subject.isActor() but for the target instead (i.e. check if the target is actor or not) that'll be nice.
Actor (the player) receives damage from an enemy.
Actor receives damage from another actor.
Enemy receives damage from an actor (the player).
Enemy receives damage from another enemy.
How can I distinguish each scenario and run different code accordingly?
The following gives the error: "TypeError. Cannot read property isForOpponent of undefined"
Code:
if (BattleManager._subject.isActor()) {
if (BattleManager._subject.currentAction().isForOpponent()){
}else{
}
} else {
if (BattleManager._subject.currentAction().isForOpponent()){
}else{
}
}
Code:
I got the idea from a piece of code:
...
var action = user.currentAction();
if (action && action.isForOpponent()) {
...
So I thought it would have worked
Alternatively, if I can figure out how to do BattleManager._subject.isActor() but for the target instead (i.e. check if the target is actor or not) that'll be nice.