Gen7Data/Scripts/Abilities/ChangeMoveType.as

31 lines
1.0 KiB
ActionScript

namespace Gen7 {
[Ability effect=ChangeMoveType]
class ChangeMoveType : PkmnScript {
string _fromType;
string _toType;
bool _changedLastAttack = false;
void OnInitialize(const narray<EffectParameter@>@ parameters) override {
_fromType = parameters[0].AsString();
_toType = parameters[1].AsString();
}
void ChangeAttackType(ExecutingMove@ move, Pokemon@ target, uint8 hit, uint8 &inout t) override {
auto lib = move.User.Battle.Library.StaticLibrary.TypeLibrary;
auto fromTypeId = lib.GetTypeId(_fromType);
if (fromTypeId == t){
t = lib.GetTypeId(_toType);
_changedLastAttack = true;
}
else{
_changedLastAttack = false;
}
}
void ModifyDamageModifier(ExecutingMove@, Pokemon@, uint8, float &inout damageMod) override {
if (_changedLastAttack){
damageMod *= 1.2f;
}
}
}
}