插件脚本 【练手】[20.1]朱紫新增特性编写【已弃坑】

ES泽洛

世末鸽者
管理员
元老
2022-08-04
227
14
287
2,116
23
安徽
www.esplus.club
没写完,不想写了,已经写了的也有不完善的地方,仅供参考。
其实应该也算不上开发用品,需要注意的是,当时朱紫还没正式发售,很多效果只有描述,而没有实际参考,所以我写的代码和官方的必然会有一定出入。
把内部名改成正式英文名大写了。
有需要的自取,记得给Credits,可以用,但禁止转载
我自己的零维E界是用不上的,因为是18.1。


代码:
[LINGERINGAROMA]
Name = 甩不掉的气味
Description = 被对手接触到后,甩不掉的 气味会沾上对手。
Ruby:
Battle::AbilityEffects::OnBeingHit.copy(:MUMMY, :LINGERINGAROMA)
代码:
[SEEDSOWER]
Name = 掉出种子
Description = 受到攻击时,会将脚下变成 青草场地。
Ruby:
Battle::AbilityEffects::OnBeingHit.add(:SEEDSOWER,
  proc { |ability, user, target, move, battle|
    next if battle.field.terrain == :Grassy
    battle.pbShowAbilitySplash(target)
    battle.pbStartTerrain(target, :Grassy)
    battle.pbHideAbilitySplash(target)
  }
)
代码:
[THERMALEXCHANGE]
Name = 热交换
Description = 受到火属性的招式攻击时, 攻击会提高,且不会陷入 灼伤状态。
Ruby:
Battle::AbilityEffects::OnBeingHit.add(:THERMALEXCHANGE,
  proc { |ability, user, target, move, battle|
    next if move.calcType != :FIRE
    target.pbRaiseStatStageByAbility(:ATTACK, 1, target)
  }
)
Battle::AbilityEffects::StatusImmunity.add(:THERMALEXCHANGE,
  proc { |ability, battler, status|
    next true if status == :BURN
  }
)
Battle::AbilityEffects::StatusCure.add(:THERMALEXCHANGE,
  proc { |ability, battler|
    next if battler.status != :BURN
    battler.battle.pbShowAbilitySplash(battler)
    battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH)
    if !Battle::Scene::USE_ABILITY_SPLASH
      battler.battle.pbDisplay(_INTL("{1}的{2}治愈了\n它的灼伤状态!", battler.pbThis, battler.abilityName))
    end
    battler.battle.pbHideAbilitySplash(battler)
  }
)
Battle::AbilityEffects::OnSwitchOut.add(:THERMALEXCHANGE,
  proc { |ability, battler, endOfBattle|
    next if battler.status != :BURN
    battler.status = :NONE
  }
)
代码:
[ANGERSHELL]
Name = 愤怒甲壳
Description = 因被对手的攻击而HP变为一半时, 会因愤怒降低防御和特防。 但攻击、特攻、速度会提高。
Ruby:
Battle::AbilityEffects::AfterMoveUseFromTarget.add(:ANGERSHELL,
  proc { |ability, target, user, move, switched_battlers, battle|
    next if !move.damagingMove?
    next if !target.droppedBelowHalfHP
    next if !target.pbCanLowerStatStage?(:DEFENSE, target) &&
            !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, target) &&
            !target.pbCanRaiseStatStage?(:ATTACK, target) &&
            !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, target) &&
            !target.pbCanRaiseStatStage?(:SPEED, target) &&
    battle.pbShowAbilitySplash(target)
    target.pbLowerStatStageByAbility(:DEFENSE, 1, target, false)
    target.pbLowerStatStageByAbility(:SPECIAL_DEFENSE, 1, target, false)
    target.pbRaiseStatStageByAbility(:ATTACK, 1, target, false)
    target.pbRaiseStatStageByAbility(:SPECIAL_ATTACK, 1, target, false)
    target.pbRaiseStatStageByAbility(:SPEED, 1, target, false)
    battle.pbHideAbilitySplash(target)
  }
)
代码:
[PURIFYINGSALT]
Name = 洁净之盐
Description = 因洁净的盐而不会陷入异常状态。 会让幽灵属性的招式伤害减半。
Ruby:
Battle::AbilityEffects::StatusImmunity.add(:PURIFYINGSALT,
  proc { |ability, battler, status|
    next true
  }
)
Battle::AbilityEffects::DamageCalcFromTarget.add(:PURIFYINGSALT,
  proc { |ability, user, target, move, mults, baseDmg, type|
    mults[:base_damage_multiplier] /= 2 if type == :GHOST
  }
)
代码:
[WELLBAKEDBODY]
Name = 焦香之躯
Description = 受到火属性的招式攻击时, 不会受到伤害,而是会大幅 提高防御。
Ruby:
Battle::AbilityEffects::MoveImmunity.add(:WELLBAKEDBODY,
  proc { |ability, user, target, move, type, battle, show_message|
    next target.pbMoveImmunityStatRaisingAbility(user, move, type,
       :FIRE, :DEFENSE, 2, show_message)
  }
)
代码:
[WINDRIDER]
Name = 乘风
Description = 受到了顺风或受到风的招式 攻击时,不会受到伤害,而 是会提高攻击。
Ruby:
Battle::AbilityEffects::MoveImmunity.add(:WINDRIDER,
  proc { |ability, user, target, move, type, battle, show_message|
    next false if !move.windMove?
    next target.pbRaiseStatStageByAbility(:ATTACK, 1, target)
  }
)
注意:此特性需要额外添加一些内容。
注意2:暂时还不能检测顺风。

1.在PBS文件夹的moves.txt中,给以下招式的Flags后面加上
,Wind ,如果没有Flags就加一个。
代码:
SILVERWIND        银色旋风
TWISTER            龙卷风
FAIRYWIND        妖精之风
HURRICANE        暴风
GUST            起风
TAILWIND        顺风
OMINOUSWIND        奇异之风
ICYWIND            冰冻之风
RAZORWIND        旋风刀
2.在Battle_Move页中,大概在134行下面,粘贴如下代码:
Ruby:
def windMove?;          return @flags.any? { |f| f[/^Wind$/i] };                end
代码:
[GUARDDOG]
Name = 看门犬
Description = 受到威吓时,攻击会提高。 让替换宝可梦的招式和道具无效。
注意:暂时还不能检测携带道具。
此特性需要在
Battle::Move::SwitchOutUserDamagingMove < Battle::Move中添加以下注释之间的代码

Ruby:
class Battle::Move::SwitchOutUserDamagingMove < Battle::Move
  def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
    return if user.fainted? || numHits == 0 || @battle.pbAllFainted?(user.idxOpposingSide)
    #=========================================
    targets.each do |b|
      if b.hasActiveAbility?(:GUARDDOG)
        @battle.pbShowAbilitySplash(b)
        @battle.pbDisplay(_INTL("{1}因为{2}的{3}\n而无法替换!",
                              user.pbThis, b.pbThis, b.abilityName))
        @battle.pbHideAbilitySplash(b)
        return
      end
    end
    #=========================================
    targetSwitched = true
    targets.each do |b|
      targetSwitched = false if !switchedBattlers.include?(b.index)
    end
    return if targetSwitched
    return if !@battle.pbCanChooseNonActive?(user.index)
    @battle.pbDisplay(_INTL("{1} went back to {2}!", user.pbThis,
                            @battle.pbGetOwnerName(user.index)))
    @battle.pbPursuit(user.index)
    return if user.fainted?
    newPkmn = @battle.pbGetReplacementPokemonIndex(user.index)   # Owner chooses
    return if newPkmn < 0
    @battle.pbRecallAndReplace(user.index, newPkmn)
    @battle.pbClearChoice(user.index)   # Replacement Pokémon does nothing this round
    @battle.moldBreaker = false
    @battle.pbOnBattlerEnteringBattle(user.index)
    switchedBattlers.push(user.index)
  end
end
此特性还需要修改威吓特性,全局搜索INTIMIDATE,整段替换成以下代码:
Ruby:
Battle::AbilityEffects::OnSwitchIn.add(:INTIMIDATE,
  proc { |ability, battler, battle, switch_in|
    battle.pbShowAbilitySplash(battler)
    battle.allOtherSideBattlers(battler.index).each do |b|
      next if !b.near?(battler)
      if b.hasActiveAbility?(:GUARDDOG)
        b.pbRaiseStatStageByAbility(:ATTACK, 1, b)
      else
        check_item = true
        if b.hasActiveAbility?(:CONTRARY)
          check_item = false if b.statStageAtMax?(:ATTACK)
        elsif b.statStageAtMin?(:ATTACK)
          check_item = false
        end
        check_ability = b.pbLowerAttackStatStageIntimidate(battler)
        b.pbAbilitiesOnIntimidated if check_ability
        b.pbItemOnIntimidatedCheck if check_item
      end
    end
    battle.pbHideAbilitySplash(battler)
  }
)
代码:
[ROCKYPAYLOAD]
Name = 搬岩
Description = 岩石属性的招式威力会提高。
Ruby:
Battle::AbilityEffects::DamageCalcFromUser.add(:ROCKYPAYLOAD,
  proc { |ability, user, target, move, mults, baseDmg, type|
    mults[:base_damage_multiplier] *= 1.5 if move.calcType == :ROCK
  }
)
代码:
[WINDPOWER]
Name = 风力发电
Description = 受到风的招式攻击时, 会变为充电状态。
Ruby:
Battle::AbilityEffects::MoveImmunity.add(:WINDPOWER,
  proc { |ability, user, target, move, type, battle, show_message|
    next false if !move.windMove?
    battle.pbShowAbilitySplash(target)
    target.effects[PBEffects::Charge] = 2
    battle.pbDisplay(_INTL("{1}正在充电!", target.pbThis))
    battle.pbHideAbilitySplash(target)
    next true
  }
)
注意:此特性需要额外添加一些内容。(若在乘风特性那里添加过了可跳过)
1.在PBS文件夹的moves.txt中,给以下招式的Flags后面加上
,Wind ,如果没有Flags就加一个。
代码:
SILVERWIND        银色旋风
TWISTER            龙卷风
FAIRYWIND        妖精之风
HURRICANE        暴风
GUST            起风
TAILWIND        顺风
OMINOUSWIND        奇异之风
ICYWIND            冰冻之风
RAZORWIND        旋风刀
2.在Battle_Move页中,大概在134行下面,粘贴如下代码:
Ruby:
def windMove?;          return @flags.any? { |f| f[/^Wind$/i] };                end
 
最后编辑:

ES泽洛

世末鸽者
管理员
元老
2022-08-04
227
14
287
2,116
23
安徽
www.esplus.club
代码:
[ZEROTOHERO]
Name = 全能变身
Description = 回到同行队伍后, 会变为全能形态。
Ruby:
Battle::AbilityEffects::OnSwitchOut.add(:ZEROTOHERO,
  proc { |ability, battler, endOfBattle|
    next if battler.form == 1
    next if endOfBattle
    battler.pbChangeForm(1, nil)
  }
)
注意:此特性需要额外添加一些内容。
变完身的海豚侠还需要变回平凡形态,所以要在FormHandlers页中,添加以下代码:
Ruby:
MultipleForms.register(:PALAFIN, {
  "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle|
    next 0 if pkmn.form > 0
  }
})
代码:
[COMMANDER]
Name = 发号施令
Description = 出场时,若我方当中有吃吼霸, 就会进入其口中,并从其口中 发出指令。
#没想法实现代码
代码:
[ELECTROMORPHOSIS]
Name = 电力转换
Description = 受到伤害时,会变为充电状态。
Ruby:
Battle::AbilityEffects::OnBeingHit.add(:ELECTROMORPHOSIS,
  proc { |ability, user, target, move, battle|
    battle.pbShowAbilitySplash(target)
    target.effects[PBEffects::Charge] = 2
    battle.pbDisplay(_INTL("{1}正在充电!", target.pbThis))
    battle.pbHideAbilitySplash(target)
  }
)
代码:
[PROTOSYNTHESIS]
Name = 古代活性
Description = 携带着驱动能量或天气为 晴朗时,数值最高的能力 会提高。
#请参考夸克充能
代码:
[QUARKDRIVE]
Name = 夸克充能
Description = 携带着驱动能量或在电气 场地上时,数值最高的能 力会提高。
Ruby:
#=============================================================
#[20.1]仅会由电气场地触发的夸克充能特性,
#要想携带驱动能量触发,请自己修改
#by ES泽洛
#=============================================================
#粘贴至PBEffects的122行附近
QuarkDrive                  = 117
#=============================================================
#粘贴至Battler_Initialize的278行附近
@effects[PBEffects::QuarkDrive]          = -1
#=============================================================
#粘贴至Battle_AbilityEffects的3188行附近
Battle::AbilityEffects::OnTerrainChange.add(:QUARKDRIVE,
    proc { |ability, battler, battle, ability_changed|
        stage_mul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
        stage_div = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
        real_nums = []
        #攻击
        atk           = battler.attack
        atk_stage     = battler.stages[:ATTACK] + 6
        real_atk      = (atk.to_f * stage_mul[atk_stage] / stage_div[atk_stage]).round
        real_nums.push(real_atk)
        #防御
        defense       = battler.defense
        defense_stage = battler.stages[:DEFENSE] + 6
        real_defense  = (defense.to_f * stage_mul[defense_stage] / stage_div[defense_stage]).round
        real_nums.push(real_defense)
        #速度
        speed         = battler.speed
        speed_stage   = battler.stages[:SPEED] + 6
        real_speed    = (speed.to_f * stage_mul[speed_stage] / stage_div[speed_stage]).round
        real_nums.push(real_speed)
        #特攻
        spatk         = battler.spatk
        spatk_stage   = battler.stages[:SPECIAL_ATTACK] + 6
        real_spatk    = (spatk.to_f * stage_mul[spatk_stage] / stage_div[spatk_stage]).round
        real_nums.push(real_spatk)
        #特防
        spdef         = battler.spdef
        spdef_stage   = battler.stages[:SPECIAL_DEFENSE] + 6
        real_spdef    = (spdef.to_f * stage_mul[spdef_stage] / stage_div[spdef_stage]).round
        real_nums.push(real_spdef)
 
        detail_name = ["攻击","防御","速度","特攻","特防"]
        if battle.field.terrain == :Electric
            index = 0
            for i in 0...real_nums.length
                index = i if real_nums[index] < real_nums[i]
            end
            case index
            when 0
                battler.attack  *= 1.3
            when 1
                battler.defense *= 1.3
            when 2
                battler.speed   *= 1.5
            when 3
                battler.spatk   *= 1.3
            when 4
                battler.spdef   *= 1.3
            end
            battle.pbShowAbilitySplash(battler)
            battle.pbDisplay(_INTL("{1}的{2}提高了!", battler.pbThis, detail_name[index]))
            battle.pbHideAbilitySplash(battler)
            battler.effects[PBEffects::QuarkDrive] = index
        else
            index = battler.effects[PBEffects::QuarkDrive]
            if index >= 0
                case index
                when 0
                    battler.attack  /= 1.3
                when 1
                    battler.defense /= 1.3
                when 2
                    battler.speed   /= 1.5
                when 3
                    battler.spatk   /= 1.3
                when 4
                    battler.spdef   /= 1.3
                end
                battle.pbShowAbilitySplash(battler)
                battle.pbDisplay(_INTL("{1}的{2}还原了!", battler.pbThis, detail_name[index]))
                battle.pbHideAbilitySplash(battler)
                battler.effects[PBEffects::QuarkDrive] = -1
            end
        end
    }
)
代码:
[GOODASGOLD]
Name = 黄金之躯
Description = 不会氧化的坚固黄金身躯 不会受到对手的变化招式 的影响。
Ruby:
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:GOODASGOLD,
  proc { |ability, mods, user, target, move, type|
    if move.statusMove? && user.opposes?(target)
      mods[:base_accuracy] = 0
    end
  }
)
代码:
[VESSELOFRUIN]
Name = 灾祸之鼎
Description = 以能呼唤灾厄的鼎的力量 降低除自己以外的宝可梦 的特攻。
Ruby:
Battle::AbilityEffects::OnSwitchIn.add(:VESSELOFRUIN,
  proc { |ability, battler, battle, switch_in|
    battle.pbShowAbilitySplash(battler)
    battle.allOtherSideBattlers(battler.index).each do |b|
      if b.hasActiveAbility?(:CONTRARY)
        if !b.statStageAtMax?(:SPECIAL_ATTACK)
          b.pbRaiseStatStageByAbility(:SPECIAL_ATTACK, 1, battler)
        end
      else
        if b.statStageAtMin?(:SPECIAL_ATTACK)
          b.pbLowerStatStageByAbility(:SPECIAL_ATTACK, 1, battler)
        end
      end
    end
    battle.pbHideAbilitySplash(battler)
  }
)
代码:
[SWORDOFRUIN]
Name = 灾祸之剑
Description = 以能呼唤灾厄的剑的力量 降低除自己以外的宝可梦 的防御。
Ruby:
Battle::AbilityEffects::OnSwitchIn.add(:SWORDOFRUIN,
  proc { |ability, battler, battle, switch_in|
    battle.pbShowAbilitySplash(battler)
    battle.allOtherSideBattlers(battler.index).each do |b|
      if b.hasActiveAbility?(:CONTRARY)
        if !b.statStageAtMax?(:DEFENSE)
          b.pbRaiseStatStageByAbility(:DEFENSE, 1, battler)
        end
      else
        if b.statStageAtMin?(:DEFENSE)
          b.pbLowerStatStageByAbility(:DEFENSE, 1, battler)
        end
      end
    end
    battle.pbHideAbilitySplash(battler)
  }
)
代码:
[TABLETSOFRUIN]
Name = 灾祸之简
Description = 以能呼唤灾厄的简的力量 降低除自己以外的宝可梦 的攻击。
Ruby:
Battle::AbilityEffects::OnSwitchIn.add(:TABLETSOFRUIN,
  proc { |ability, battler, battle, switch_in|
    battle.pbShowAbilitySplash(battler)
    battle.allOtherSideBattlers(battler.index).each do |b|
      if b.hasActiveAbility?(:CONTRARY)
        if !b.statStageAtMax?(:ATTACK)
          b.pbRaiseStatStageByAbility(:ATTACK, 1, battler)
        end
      else
        if b.statStageAtMin?(:ATTACK)
          b.pbLowerStatStageByAbility(:ATTACK, 1, battler)
        end
      end
    end
    battle.pbHideAbilitySplash(battler)
  }
)
代码:
[BEADSOFRUIN]
Name = 灾祸之玉
Description = 以能呼唤灾厄的勾玉的力量 降低除自己以外的宝可梦 的特防。
Ruby:
Battle::AbilityEffects::OnSwitchIn.add(:BEADSOFRUIN,
  proc { |ability, battler, battle, switch_in|
    battle.pbShowAbilitySplash(battler)
    battle.allOtherSideBattlers(battler.index).each do |b|
      if b.hasActiveAbility?(:CONTRARY)
        if !b.statStageAtMax?(:SPECIAL_DEFENSE)
          b.pbRaiseStatStageByAbility(:SPECIAL_DEFENSE, 1, battler)
        end
      else
        if b.statStageAtMin?(:SPECIAL_DEFENSE)
          b.pbLowerStatStageByAbility(:SPECIAL_DEFENSE, 1, battler)
        end
      end
    end
    battle.pbHideAbilitySplash(battler)
  }
)
 
最后编辑:

在线成员

论坛统计

主题
341
消息
1,562
会员
2,318
最新会员
哒咩哒哟

关于我们

  • 宝可梦以及其他相关名称是任天堂的商标,版权归宝可梦公司所有。宝可饭堂是一个同人游戏中文社区,不隶属于宝可梦公司。在宝可饭堂上的粉丝游戏亦未获得其授权,请支持正版游戏。
© 2022- pokefans.cn
点此延长宝可饭堂生命