- Joined
- Mar 28, 2012
- Messages
- 410
- Reaction score
- 61
- First Language
- English
- Primarily Uses
Im trying to make an enemy who casts a random state on themselves and the mechanic of this battle is the players don't know which state the enemy has.
I would like to make a state that combines Runic and Lightning Rod but for enemies. So that the enemy will automatically absorb the players next spell and does so secretly, then the state is removed.
This is the code I have for the state that is Runic absorb
This is the code I have for the "foe aura"
I would like to make a state that combines Runic and Lightning Rod but for enemies. So that the enemy will automatically absorb the players next spell and does so secretly, then the state is removed.
This is the code I have for the state that is Runic absorb
Code:
<Foe Aura: 113>
<Custom React Effect>
// Check to see if the skill is a magical skill and deals positive HP damage.
if (this.isSkill() && this.isHpEffect() && value > 0) {
// Change the amount of damage received to 0.
value = 0;
// Check to see if the action is a skill.
if (DataManager.isSkill(this.item())) {
// If the action is a skill, get the MP cost of the skill.
var mp = user.skillMpCost(this.item());
// Recover the MP.
target.gainMp(mp);
}
// Play an animation for the Runic effect.
target.startAnimation(58);
}
</Custom React Effect>
<Custom Turn End Effect>
user.removeState(109);
</Custom Turn End Effect>
This is the code I have for the "foe aura"
Code:
<Custom Action Start Effect>
// Get the current action.
var action = user.currentAction();
// Check if the action exists and targets an opponent.
if (action && action.isForOpponent()) {
// Get the Lightning Rod origin state ID.
var lightningRod = 109;
// Get the action's elements.
var pool = [];
// Get the opponent's unit's alive members.
var group = user.opponentsUnit().aliveMembers();
// Loop through each one.
for (var i = 0; i < group.length; ++i) {
// Get the currently looped member.
var member = group[i];
// Check if the member exists and is a Lightning Rod origin.
if (member && member.isStateAffected(lightningRod)) {
// Add that member to the pool.
pool.push(member);
}
}
// Check if the pool's size is larger than 0.
if (pool.length > 0) {
// Get a random Lightning Rod origin from the pool.
var rod = pool[Math.floor(Math.random()* pool.length)]
// Set the action's target to the Lightning Rod origin.
action.setTarget(rod.index());
}
}
}
</Custom Action Start Effect>
