mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Minor fixes for previous commit
This commit is contained in:
609
Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb
Normal file
609
Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb
Normal file
@@ -0,0 +1,609 @@
|
||||
module MultipleForms
|
||||
@@formSpecies = SpeciesHandlerHash.new
|
||||
|
||||
def self.copy(sym,*syms)
|
||||
@@formSpecies.copy(sym,*syms)
|
||||
end
|
||||
|
||||
def self.register(sym,hash)
|
||||
@@formSpecies.add(sym,hash)
|
||||
end
|
||||
|
||||
def self.registerIf(cond,hash)
|
||||
@@formSpecies.addIf(cond,hash)
|
||||
end
|
||||
|
||||
def self.hasFunction?(pkmn,func)
|
||||
spec = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
sp = @@formSpecies[spec]
|
||||
return sp && sp[func]
|
||||
end
|
||||
|
||||
def self.getFunction(pkmn,func)
|
||||
spec = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
sp = @@formSpecies[spec]
|
||||
return (sp && sp[func]) ? sp[func] : nil
|
||||
end
|
||||
|
||||
def self.call(func,pkmn,*args)
|
||||
sp = @@formSpecies[pkmn.species]
|
||||
return nil if !sp || !sp[func]
|
||||
return sp[func].call(pkmn,*args)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def drawSpot(bitmap,spotpattern,x,y,red,green,blue)
|
||||
height = spotpattern.length
|
||||
width = spotpattern[0].length
|
||||
for yy in 0...height
|
||||
spot = spotpattern[yy]
|
||||
for xx in 0...width
|
||||
if spot[xx]==1
|
||||
xOrg = (x+xx)<<1
|
||||
yOrg = (y+yy)<<1
|
||||
color = bitmap.get_pixel(xOrg,yOrg)
|
||||
r = color.red+red
|
||||
g = color.green+green
|
||||
b = color.blue+blue
|
||||
color.red = [[r,0].max,255].min
|
||||
color.green = [[g,0].max,255].min
|
||||
color.blue = [[b,0].max,255].min
|
||||
bitmap.set_pixel(xOrg,yOrg,color)
|
||||
bitmap.set_pixel(xOrg+1,yOrg,color)
|
||||
bitmap.set_pixel(xOrg,yOrg+1,color)
|
||||
bitmap.set_pixel(xOrg+1,yOrg+1,color)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbSpindaSpots(pkmn,bitmap)
|
||||
spot1 = [
|
||||
[0,0,1,1,1,1,0,0],
|
||||
[0,1,1,1,1,1,1,0],
|
||||
[1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1],
|
||||
[0,1,1,1,1,1,1,0],
|
||||
[0,0,1,1,1,1,0,0]
|
||||
]
|
||||
spot2 = [
|
||||
[0,0,1,1,1,0,0],
|
||||
[0,1,1,1,1,1,0],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[0,1,1,1,1,1,0],
|
||||
[0,0,1,1,1,0,0]
|
||||
]
|
||||
spot3 = [
|
||||
[0,0,0,0,0,1,1,1,1,0,0,0,0],
|
||||
[0,0,0,1,1,1,1,1,1,1,0,0,0],
|
||||
[0,0,1,1,1,1,1,1,1,1,1,0,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,0,1,1,1,1,1,1,1,1,1,0,0],
|
||||
[0,0,0,1,1,1,1,1,1,1,0,0,0],
|
||||
[0,0,0,0,0,1,1,1,0,0,0,0,0]
|
||||
]
|
||||
spot4 = [
|
||||
[0,0,0,0,1,1,1,0,0,0,0,0],
|
||||
[0,0,1,1,1,1,1,1,1,0,0,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,0,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,0,1,1,1,1,1,1,1,1,0,0],
|
||||
[0,0,0,0,1,1,1,1,1,0,0,0]
|
||||
]
|
||||
id = pkmn.personalID
|
||||
h = (id>>28)&15
|
||||
g = (id>>24)&15
|
||||
f = (id>>20)&15
|
||||
e = (id>>16)&15
|
||||
d = (id>>12)&15
|
||||
c = (id>>8)&15
|
||||
b = (id>>4)&15
|
||||
a = (id)&15
|
||||
if pkmn.shiny?
|
||||
drawSpot(bitmap,spot1,b+33,a+25,-75,-10,-150)
|
||||
drawSpot(bitmap,spot2,d+21,c+24,-75,-10,-150)
|
||||
drawSpot(bitmap,spot3,f+39,e+7,-75,-10,-150)
|
||||
drawSpot(bitmap,spot4,h+15,g+6,-75,-10,-150)
|
||||
else
|
||||
drawSpot(bitmap,spot1,b+33,a+25,0,-115,-75)
|
||||
drawSpot(bitmap,spot2,d+21,c+24,0,-115,-75)
|
||||
drawSpot(bitmap,spot3,f+39,e+7,0,-115,-75)
|
||||
drawSpot(bitmap,spot4,h+15,g+6,0,-115,-75)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Regular form differences
|
||||
#===============================================================================
|
||||
|
||||
MultipleForms.register(:UNOWN,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next rand(28)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:SPINDA,{
|
||||
"alterBitmap" => proc { |pkmn,bitmap|
|
||||
pbSpindaSpots(pkmn,bitmap)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:CASTFORM,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:GROUDON,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:REDORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:KYOGRE,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:BLUEORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:BURMY,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
case pbGetEnvironment
|
||||
when :Rock, :Sand, :Cave
|
||||
next 1 # Sandy Cloak
|
||||
when :None
|
||||
next 2 # Trash Cloak
|
||||
else
|
||||
next 0 # Plant Cloak
|
||||
end
|
||||
},
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next if !endBattle || !usedInBattle
|
||||
case battle.environment
|
||||
when :Rock, :Sand, :Cave
|
||||
next 1 # Sandy Cloak
|
||||
when :None
|
||||
next 2 # Trash Cloak
|
||||
else
|
||||
next 0 # Plant Cloak
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:WORMADAM,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
case pbGetEnvironment
|
||||
when :Rock, :Sand, :Cave
|
||||
next 1 # Sandy Cloak
|
||||
when :None
|
||||
next 2 # Trash Cloak
|
||||
else
|
||||
next 0 # Plant Cloak
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:CHERRIM,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:ROTOM,{
|
||||
"onSetForm" => proc { |pkmn, form, oldForm|
|
||||
form_moves = [
|
||||
:OVERHEAT, # Heat, Microwave
|
||||
:HYDROPUMP, # Wash, Washing Machine
|
||||
:BLIZZARD, # Frost, Refrigerator
|
||||
:AIRSLASH, # Fan
|
||||
:LEAFSTORM # Mow, Lawnmower
|
||||
]
|
||||
move_index = -1
|
||||
pkmn.moves.each_with_index do |move, i|
|
||||
next if !form_moves.any? { |m| move == m }
|
||||
move_index = i
|
||||
break
|
||||
end
|
||||
if form == 0
|
||||
# Turned back into the base form; forget form-specific moves
|
||||
if move_index >= 0
|
||||
move_name = pkmn.moves[move_index].name
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
|
||||
pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Turned into an alternate form; try learning that form's unique move
|
||||
new_move_id = form_moves[form - 1]
|
||||
if move_index >= 0
|
||||
# Knows another form's unique move; replace it
|
||||
old_move_name = pkmn.moves[move_index].name
|
||||
if GameData::Move.exists?(new_move_id)
|
||||
pkmn.moves[move_index].id = new_move_id
|
||||
new_move_name = pkmn.moves[move_index].name
|
||||
pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1"))
|
||||
pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1", pkmn.name, old_move_name))
|
||||
pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]", pkmn.name, new_move_name))
|
||||
else
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, old_move_name))
|
||||
pkmn.learn_move(:THUNDERSHOCK) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Just try to learn this form's unique move
|
||||
pbLearnMove(pkmn, new_move_id, true)
|
||||
end
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:GIRATINA,{
|
||||
"getForm" => proc { |pkmn|
|
||||
maps = [49,50,51,72,73] # Map IDs for Origin Forme
|
||||
if pkmn.hasItem?(:GRISEOUSORB) || ($game_map && maps.include?($game_map.map_id))
|
||||
next 1
|
||||
end
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:SHAYMIN,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next 0 if pkmn.fainted? || pkmn.status == :FROZEN || PBDayNight.isNight?
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:ARCEUS,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next nil if !pkmn.hasAbility?(:MULTITYPE)
|
||||
typeArray = {
|
||||
1 => [:FISTPLATE, :FIGHTINIUMZ],
|
||||
2 => [:SKYPLATE, :FLYINIUMZ],
|
||||
3 => [:TOXICPLATE, :POISONIUMZ],
|
||||
4 => [:EARTHPLATE, :GROUNDIUMZ],
|
||||
5 => [:STONEPLATE, :ROCKIUMZ],
|
||||
6 => [:INSECTPLATE, :BUGINIUMZ],
|
||||
7 => [:SPOOKYPLATE, :GHOSTIUMZ],
|
||||
8 => [:IRONPLATE, :STEELIUMZ],
|
||||
10 => [:FLAMEPLATE, :FIRIUMZ],
|
||||
11 => [:SPLASHPLATE, :WATERIUMZ],
|
||||
12 => [:MEADOWPLATE, :GRASSIUMZ],
|
||||
13 => [:ZAPPLATE, :ELECTRIUMZ],
|
||||
14 => [:MINDPLATE, :PSYCHIUMZ],
|
||||
15 => [:ICICLEPLATE, :ICIUMZ],
|
||||
16 => [:DRACOPLATE, :DRAGONIUMZ],
|
||||
17 => [:DREADPLATE, :DARKINIUMZ],
|
||||
18 => [:PIXIEPLATE, :FAIRIUMZ]
|
||||
}
|
||||
ret = 0
|
||||
typeArray.each do |f, items|
|
||||
for item in items
|
||||
next if !pkmn.hasItem?(item)
|
||||
ret = f
|
||||
break
|
||||
end
|
||||
break if ret > 0
|
||||
end
|
||||
next ret
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:BASCULIN,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next rand(2)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:DARMANITAN,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:DEERLING,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next pbGetSeason
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:DEERLING,:SAWSBUCK)
|
||||
|
||||
MultipleForms.register(:KYUREM,{
|
||||
"getFormOnEnteringBattle" => proc { |pkmn,wild|
|
||||
next pkmn.form+2 if pkmn.form==1 || pkmn.form==2
|
||||
},
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next pkmn.form-2 if pkmn.form>=3 # Fused forms stop glowing
|
||||
},
|
||||
"onSetForm" => proc { |pkmn, form, oldForm|
|
||||
case form
|
||||
when 0 # Normal
|
||||
pkmn.moves.each do |move|
|
||||
if [:ICEBURN, :FREEZESHOCK].include?(move.id)
|
||||
move.id = :GLACIATE if GameData::Move.exists?(:GLACIATE)
|
||||
end
|
||||
if [:FUSIONFLARE, :FUSIONBOLT].include?(move.id)
|
||||
move.id = :SCARYFACE if GameData::Move.exists?(:SCARYFACE)
|
||||
end
|
||||
end
|
||||
when 1 # White
|
||||
pkmn.moves.each do |move|
|
||||
move.id = :ICEBURN if move == :GLACIATE && GameData::Move.exists?(:ICEBURN)
|
||||
move.id = :FUSIONFLARE if move == :SCARYFACE && GameData::Move.exists?(:FUSIONFLARE)
|
||||
end
|
||||
when 2 # Black
|
||||
pkmn.moves.each do |move|
|
||||
move.id = :FREEZESHOCK if move == :GLACIATE && GameData::Move.exists?(:FREEZESHOCK)
|
||||
move.id = :FUSIONBOLT if move == :SCARYFACE && GameData::Move.exists?(:FUSIONBOLT)
|
||||
end
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:KELDEO,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasMove?(:SECRETSWORD) # Resolute Form
|
||||
next 0 # Ordinary Form
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:MELOETTA,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:GENESECT,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next 1 if pkmn.hasItem?(:SHOCKDRIVE)
|
||||
next 2 if pkmn.hasItem?(:BURNDRIVE)
|
||||
next 3 if pkmn.hasItem?(:CHILLDRIVE)
|
||||
next 4 if pkmn.hasItem?(:DOUSEDRIVE)
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:GRENINJA,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 1 if pkmn.form == 2 && (pkmn.fainted? || endBattle)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:SCATTERBUG,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next $Trainer.secret_ID % 18
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:SCATTERBUG,:SPEWPA,:VIVILLON)
|
||||
|
||||
MultipleForms.register(:FLABEBE,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next rand(5)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:FLABEBE,:FLOETTE,:FLORGES)
|
||||
|
||||
MultipleForms.register(:FURFROU,{
|
||||
"getForm" => proc { |pkmn|
|
||||
if !pkmn.time_form_set ||
|
||||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 5 # 5 days
|
||||
next 0
|
||||
end
|
||||
},
|
||||
"onSetForm" => proc { |pkmn,form,oldForm|
|
||||
pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:ESPURR,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next pkmn.gender
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:ESPURR,:MEOWSTIC)
|
||||
|
||||
MultipleForms.register(:AEGISLASH,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:PUMPKABOO,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
r = rand(100)
|
||||
if r<5; next 3 # Super Size (5%)
|
||||
elsif r<20; next 2 # Large (15%)
|
||||
elsif r<65; next 1 # Average (45%)
|
||||
end
|
||||
next 0 # Small (35%)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:PUMPKABOO,:GOURGEIST)
|
||||
|
||||
MultipleForms.register(:XERNEAS,{
|
||||
"getFormOnEnteringBattle" => proc { |pkmn,wild|
|
||||
next 1
|
||||
},
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:ZYGARDE,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next pkmn.form-2 if pkmn.form>=2 && (pkmn.fainted? || endBattle)
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:HOOPA,{
|
||||
"getForm" => proc { |pkmn|
|
||||
if !pkmn.time_form_set ||
|
||||
pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 3 # 3 days
|
||||
next 0
|
||||
end
|
||||
},
|
||||
"onSetForm" => proc { |pkmn,form,oldForm|
|
||||
pkmn.time_form_set = (form>0) ? pbGetTimeNow.to_i : nil
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:ORICORIO,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next rand(4) # 0=red, 1=yellow, 2=pink, 3=purple
|
||||
},
|
||||
})
|
||||
|
||||
MultipleForms.register(:ROCKRUFF,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next if pkmn.form_simple >= 2 # Own Tempo Rockruff cannot become another form
|
||||
next 1 if PBDayNight.isNight?
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:LYCANROC,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next 2 if PBDayNight.isEvening? # Dusk
|
||||
next 1 if PBDayNight.isNight? # Midnight
|
||||
next 0 # Midday
|
||||
},
|
||||
})
|
||||
|
||||
MultipleForms.register(:WISHIWASHI,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:SILVALLY,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next nil if !pkmn.hasAbility?(:RKSSYSTEM)
|
||||
typeArray = {
|
||||
1 => [:FIGHTINGMEMORY],
|
||||
2 => [:FLYINGMEMORY],
|
||||
3 => [:POISONMEMORY],
|
||||
4 => [:GROUNDMEMORY],
|
||||
5 => [:ROCKMEMORY],
|
||||
6 => [:BUGMEMORY],
|
||||
7 => [:GHOSTMEMORY],
|
||||
8 => [:STEELMEMORY],
|
||||
10 => [:FIREMEMORY],
|
||||
11 => [:WATERMEMORY],
|
||||
12 => [:GRASSMEMORY],
|
||||
13 => [:ELECTRICMEMORY],
|
||||
14 => [:PSYCHICMEMORY],
|
||||
15 => [:ICEMEMORY],
|
||||
16 => [:DRAGONMEMORY],
|
||||
17 => [:DARKMEMORY],
|
||||
18 => [:FAIRYMEMORY]
|
||||
}
|
||||
ret = 0
|
||||
typeArray.each do |f, items|
|
||||
for item in items
|
||||
next if !pkmn.hasItem?(item)
|
||||
ret = f
|
||||
break
|
||||
end
|
||||
break if ret>0
|
||||
end
|
||||
next ret
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:MINIOR,{
|
||||
"getFormOnCreation" => proc { |pkmn|
|
||||
next 7+rand(7) # Meteor forms are 0-6, Core forms are 7-13
|
||||
},
|
||||
"getFormOnEnteringBattle" => proc { |pkmn,wild|
|
||||
next pkmn.form-7 if pkmn.form>=7 && wild # Wild Minior always appear in Meteor form
|
||||
},
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next pkmn.form+7 if pkmn.form<7
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:MIMIKYU,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
next 0 if pkmn.fainted? || endBattle
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:NECROZMA,{
|
||||
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
|
||||
# Fused forms are 1 and 2, Ultra form is 3 or 4 depending on which fusion
|
||||
next pkmn.form-2 if pkmn.form>=3 && (pkmn.fainted? || endBattle)
|
||||
},
|
||||
"onSetForm" => proc { |pkmn, form, oldForm|
|
||||
next if form > 2 || oldForm > 2 # Ultra form changes don't affect moveset
|
||||
form_moves = [
|
||||
:SUNSTEELSTRIKE, # Dusk Mane (with Solgaleo) (form 1)
|
||||
:MOONGEISTBEAM # Dawn Wings (with Lunala) (form 2)
|
||||
]
|
||||
if form == 0
|
||||
# Turned back into the base form; forget form-specific moves
|
||||
move_index = -1
|
||||
pkmn.moves.each_with_index do |move, i|
|
||||
next if !form_moves.any? { |m| move == m }
|
||||
move_index = i
|
||||
break
|
||||
end
|
||||
if move_index >= 0
|
||||
move_name = pkmn.moves[move_index].name
|
||||
pkmn.forget_move_at_index(move_index)
|
||||
pbMessage(_INTL("{1} forgot {2}...", pkmn.name, move_name))
|
||||
pkmn.learn_move(:CONFUSION) if pkmn.numMoves == 0
|
||||
end
|
||||
else
|
||||
# Turned into an alternate form; try learning that form's unique move
|
||||
new_move_id = form_moves[form - 1]
|
||||
pbLearnMove(pkmn, new_move_id, true)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
#===============================================================================
|
||||
# Alolan forms
|
||||
#===============================================================================
|
||||
|
||||
# These species don't have visually different Alolan forms, but they need to
|
||||
# evolve into different forms depending on the location where they evolved.
|
||||
MultipleForms.register(:PIKACHU, {
|
||||
"getForm" => proc { |pkmn|
|
||||
next if pkmn.form_simple >= 2
|
||||
if $game_map
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next 1 if map_metadata && map_metadata.town_map_position &&
|
||||
map_metadata.town_map_position[0] == 1 # Tiall region
|
||||
end
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.copy(:PIKACHU, :EXEGGCUTE, :CUBONE)
|
||||
@@ -0,0 +1,526 @@
|
||||
=begin
|
||||
All types except Shadow have Shadow as a weakness.
|
||||
Shadow has Shadow as a resistance.
|
||||
On a side note, the Shadow moves in Colosseum will not be affected by Weaknesses
|
||||
or Resistances, while in XD the Shadow-type is Super-Effective against all other
|
||||
types.
|
||||
2/5 - display nature
|
||||
|
||||
XD - Shadow Rush -- 55, 100 - Deals damage.
|
||||
Colosseum - Shadow Rush -- 90, 100
|
||||
If this attack is successful, user loses half of HP lost by opponent due to this
|
||||
attack (recoil). If user is in Hyper Mode, this attack has a good chance for a
|
||||
critical hit.
|
||||
=end
|
||||
|
||||
#===============================================================================
|
||||
# Purify a Shadow Pokémon.
|
||||
#===============================================================================
|
||||
def pbPurify(pkmn, scene)
|
||||
return if !pkmn.shadowPokemon? || pkmn.heart_gauge != 0
|
||||
pkmn.shadow = false
|
||||
pkmn.giveRibbon(:NATIONAL)
|
||||
scene.pbDisplay(_INTL("{1} opened the door to its heart!", pkmn.name))
|
||||
old_moves = []
|
||||
pkmn.moves.each { |m| old_moves.push(m.id) }
|
||||
pkmn.update_shadow_moves
|
||||
pkmn.moves.each_with_index do |m, i|
|
||||
next if m.id == old_moves[i]
|
||||
scene.pbDisplay(_INTL("{1} regained the move {2}!", pkmn.name, m.name))
|
||||
end
|
||||
pkmn.record_first_moves
|
||||
if pkmn.saved_ev
|
||||
pkmn.add_evs(pkmn.saved_ev)
|
||||
pkmn.saved_ev = nil
|
||||
end
|
||||
if pkmn.saved_exp
|
||||
newexp = pkmn.growth_rate.add_exp(pkmn.exp, pkmn.saved_exp || 0)
|
||||
pkmn.saved_exp = nil
|
||||
newlevel = pkmn.growth_rate.level_from_exp(newexp)
|
||||
curlevel = pkmn.level
|
||||
if newexp != pkmn.exp
|
||||
scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!", pkmn.name, newexp - pkmn.exp))
|
||||
end
|
||||
if newlevel == curlevel
|
||||
pkmn.exp = newexp
|
||||
pkmn.calc_stats
|
||||
else
|
||||
pbChangeLevel(pkmn, newlevel, scene) # for convenience
|
||||
pkmn.exp = newexp
|
||||
end
|
||||
end
|
||||
if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pkmn.speciesName))
|
||||
newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pkmn.speciesName),
|
||||
0, Pokemon::MAX_NAME_SIZE, "", pkmn)
|
||||
pkmn.name = newname
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Relic Stone scene.
|
||||
#===============================================================================
|
||||
class RelicStoneScene
|
||||
def pbPurify
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbDisplay(msg,brief=false)
|
||||
UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbStartScene(pokemon)
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@pokemon = pokemon
|
||||
addBackgroundPlane(@sprites,"bg","relicstonebg",@viewport)
|
||||
@sprites["msgwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
@sprites["msgwindow"].viewport = @viewport
|
||||
@sprites["msgwindow"].x = 0
|
||||
@sprites["msgwindow"].y = Graphics.height-96
|
||||
@sprites["msgwindow"].width = Graphics.width
|
||||
@sprites["msgwindow"].height = 96
|
||||
@sprites["msgwindow"].text = ""
|
||||
@sprites["msgwindow"].visible = true
|
||||
pbDeactivateWindows(@sprites)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class RelicStoneScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbDisplay(x)
|
||||
@scene.pbDisplay(x)
|
||||
end
|
||||
|
||||
def pbConfirm(x)
|
||||
@scene.pbConfirm(x)
|
||||
end
|
||||
|
||||
def pbUpdate; end
|
||||
|
||||
def pbRefresh; end
|
||||
|
||||
def pbStartScreen(pokemon)
|
||||
@scene.pbStartScene(pokemon)
|
||||
@scene.pbPurify
|
||||
pbPurify(pokemon,self)
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbRelicStoneScreen(pkmn)
|
||||
retval = true
|
||||
pbFadeOutIn {
|
||||
scene = RelicStoneScene.new
|
||||
screen = RelicStoneScreen.new(scene)
|
||||
retval = screen.pbStartScreen(pkmn)
|
||||
}
|
||||
return retval
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbRelicStone
|
||||
if !$Trainer.party.any? { |pkmn| pkmn.purifiable? }
|
||||
pbMessage(_INTL("You have no Pokémon that can be purified."))
|
||||
return
|
||||
end
|
||||
pbMessage(_INTL("There's a Pokémon that may open the door to its heart!"))
|
||||
# Choose a purifiable Pokemon
|
||||
pbChoosePokemon(1, 2,proc { |pkmn|
|
||||
pkmn.able? && pkmn.shadowPokemon? && pkmn.heart_gauge == 0
|
||||
})
|
||||
if $game_variables[1] >= 0
|
||||
pbRelicStoneScreen($Trainer.party[$game_variables[1]])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Shadow Pokémon in battle.
|
||||
#===============================================================================
|
||||
class PokeBattle_Battle
|
||||
alias __shadow__pbCanUseItemOnPokemon? pbCanUseItemOnPokemon?
|
||||
|
||||
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true)
|
||||
ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages)
|
||||
if ret && pkmn.hyper_mode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
|
||||
scene.pbDisplay(_INTL("This item can't be used on that Pokémon."))
|
||||
return false
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class PokeBattle_Battler
|
||||
alias __shadow__pbInitPokemon pbInitPokemon
|
||||
|
||||
def pbInitPokemon(*arg)
|
||||
if self.pokemonIndex>0 && inHyperMode?
|
||||
# Called out of Hyper Mode
|
||||
self.pokemon.hyper_mode = false
|
||||
self.pokemon.adjustHeart(-50)
|
||||
end
|
||||
__shadow__pbInitPokemon(*arg)
|
||||
# Called into battle
|
||||
if shadowPokemon?
|
||||
if GameData::Type.exists?(:SHADOW)
|
||||
self.type1 = :SHADOW
|
||||
self.type2 = :SHADOW
|
||||
end
|
||||
self.pokemon.adjustHeart(-30) if pbOwnedByPlayer?
|
||||
end
|
||||
end
|
||||
|
||||
def shadowPokemon?
|
||||
p = self.pokemon
|
||||
return p && p.shadowPokemon?
|
||||
end
|
||||
alias isShadow? shadowPokemon?
|
||||
|
||||
def inHyperMode?
|
||||
return false if fainted?
|
||||
p = self.pokemon
|
||||
return p && p.hyper_mode
|
||||
end
|
||||
|
||||
def pbHyperMode
|
||||
return if fainted? || !shadowPokemon? || inHyperMode?
|
||||
p = self.pokemon
|
||||
if @battle.pbRandom(p.heart_gauge) <= Pokemon::HEART_GAUGE_SIZE / 4
|
||||
p.hyper_mode = true
|
||||
@battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!",self.pbThis))
|
||||
end
|
||||
end
|
||||
|
||||
def pbHyperModeObedience(move)
|
||||
return true if !inHyperMode?
|
||||
return true if !move || move.type == :SHADOW
|
||||
return rand(100)<20
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Shadow item effects.
|
||||
#===============================================================================
|
||||
def pbRaiseHappinessAndReduceHeart(pkmn, scene, heart_amount)
|
||||
if !pkmn.shadowPokemon? || (pkmn.happiness == 255 && pkmn.heart_gauge == 0)
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
return false
|
||||
end
|
||||
if pkmn.happiness == 255
|
||||
stage = pkmn.heart_gauge
|
||||
pkmn.adjustHeart(-heart_amount)
|
||||
scene.pbDisplay(_INTL("{1} adores you!\nThe door to its heart opened a little.", pkmn.name))
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge != stage
|
||||
elsif pkmn.heart_gauge == 0
|
||||
pkmn.changeHappiness("vitamin")
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.", pkmn.name))
|
||||
else
|
||||
stage = pkmn.heart_gauge
|
||||
pkmn.changeHappiness("vitamin")
|
||||
pkmn.adjustHeart(-heart_amount)
|
||||
scene.pbDisplay(_INTL("{1} turned friendly.\nThe door to its heart opened a little.", pkmn.name))
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge != stage
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:JOYSCENT,proc { |item,pokemon,scene|
|
||||
pbRaiseHappinessAndReduceHeart(pokemon,scene,500)
|
||||
})
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:EXCITESCENT,proc { |item,pokemon,scene|
|
||||
pbRaiseHappinessAndReduceHeart(pokemon,scene,1000)
|
||||
})
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:VIVIDSCENT,proc { |item,pokemon,scene|
|
||||
pbRaiseHappinessAndReduceHeart(pokemon,scene,2000)
|
||||
})
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:TIMEFLUTE,proc { |item,pokemon,scene|
|
||||
if !pokemon.shadowPokemon? || pokemon.heart_gauge == 0
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
next false
|
||||
end
|
||||
pokemon.heart_gauge = 0
|
||||
pokemon.check_ready_to_purify
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::CanUseInBattle.add(:JOYSCENT,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages|
|
||||
if !battler || !battler.shadowPokemon? || !battler.inHyperMode?
|
||||
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
|
||||
next false
|
||||
end
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT)
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-100)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-200)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hyper_mode = false
|
||||
battler.pokemon.adjustHeart(-300)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# No additional effect. (Shadow Blast, Shadow Blitz, Shadow Break, Shadow Rave,
|
||||
# Shadow Rush, Shadow Wave)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_126 < PokeBattle_Move_000
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Paralyzes the target. (Shadow Bolt)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_127 < PokeBattle_Move_007
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Burns the target. (Shadow Fire)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_128 < PokeBattle_Move_00A
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Freezes the target. (Shadow Chill)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_129 < PokeBattle_Move_00C
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Confuses the target. (Shadow Panic)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12A < PokeBattle_Move_013
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Decreases the target's Defense by 2 stages. (Shadow Down)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12B < PokeBattle_Move_04C
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Decreases the target's evasion by 2 stages. (Shadow Mist)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12C < PokeBattle_TargetStatDownMove
|
||||
def initialize(battle,move)
|
||||
super
|
||||
@statDown = [:EVASION,2]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Power is doubled if the target is using Dive. (Shadow Storm)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12D < PokeBattle_Move_075
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Two turn attack. On first turn, halves the HP of all active Pokémon.
|
||||
# Skips second turn (if successful). (Shadow Half)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12E < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
failed = true
|
||||
@battle.eachBattler do |b|
|
||||
next if b.hp==1
|
||||
failed = false
|
||||
break
|
||||
end
|
||||
if failed
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def pbEffectGeneral(user)
|
||||
@battle.eachBattler do |b|
|
||||
next if b.hp==1
|
||||
b.pbReduceHP(i.hp/2,false)
|
||||
end
|
||||
@battle.pbDisplay(_INTL("Each Pokémon's HP was halved!"))
|
||||
@battle.eachBattler { |b| b.pbItemHPHealCheck }
|
||||
user.effects[PBEffects::HyperBeam] = 2
|
||||
user.currentMove = @id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Target can no longer switch out or flee, as long as the user remains active.
|
||||
# (Shadow Hold)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_12F < PokeBattle_Move_0EF
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# User takes recoil damage equal to 1/2 of its current HP. (Shadow End)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_130 < PokeBattle_RecoilMove
|
||||
def pbRecoilDamage(user,target)
|
||||
return (target.damageState.totalHPLost/2.0).round
|
||||
end
|
||||
|
||||
def pbEffectAfterAllHits(user,target)
|
||||
return if user.fainted? || target.damageState.unaffected
|
||||
# NOTE: This move's recoil is not prevented by Rock Head/Magic Guard.
|
||||
amt = pbRecoilDamage(user,target)
|
||||
amt = 1 if amt<1
|
||||
user.pbReduceHP(amt,false)
|
||||
@battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis))
|
||||
user.pbItemHPHealCheck
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Starts shadow weather. (Shadow Sky)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_131 < PokeBattle_WeatherMove
|
||||
def initialize(battle,move)
|
||||
super
|
||||
@weatherType = :ShadowSky
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Ends the effects of Light Screen, Reflect and Safeguard on both sides.
|
||||
# (Shadow Shed)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_132 < PokeBattle_Move
|
||||
def pbEffectGeneral(user)
|
||||
for i in @battle.sides
|
||||
i.effects[PBEffects::AuroraVeil] = 0
|
||||
i.effects[PBEffects::Reflect] = 0
|
||||
i.effects[PBEffects::LightScreen] = 0
|
||||
i.effects[PBEffects::Safeguard] = 0
|
||||
end
|
||||
@battle.pbDisplay(_INTL("It broke all barriers!"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonTemp
|
||||
attr_accessor :heart_gauges
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Record current heart gauges of Pokémon in party, to see if they drop to zero
|
||||
# during battle and need to say they're ready to be purified afterwards
|
||||
Events.onStartBattle += proc { |_sender|
|
||||
$PokemonTemp.heart_gauges = []
|
||||
$Trainer.party.each_with_index do |pkmn, i|
|
||||
$PokemonTemp.heart_gauges[i] = pkmn.heart_gauge
|
||||
end
|
||||
}
|
||||
|
||||
Events.onEndBattle += proc { |_sender,_e|
|
||||
$PokemonTemp.heart_gauges.each_with_index do |value, i|
|
||||
pkmn = $Trainer.party[i]
|
||||
next if !pkmn || !value || value == 0
|
||||
pkmn.check_ready_to_purify if pkmn.heart_gauge == 0
|
||||
end
|
||||
}
|
||||
|
||||
Events.onStepTaken += proc {
|
||||
for pkmn in $Trainer.able_party
|
||||
next if pkmn.heart_gauge == 0
|
||||
stage = pkmn.heartStage
|
||||
pkmn.adjustHeart(-1)
|
||||
case pkmn.heartStage
|
||||
when 0
|
||||
pkmn.check_ready_to_purify
|
||||
when stage
|
||||
else
|
||||
pkmn.update_shadow_moves
|
||||
end
|
||||
end
|
||||
if ($PokemonGlobal.purifyChamber rescue nil)
|
||||
$PokemonGlobal.purifyChamber.update
|
||||
end
|
||||
for i in 0...2
|
||||
pkmn = $PokemonGlobal.daycare[i][0]
|
||||
next if !pkmn
|
||||
stage = pkmn.heartStage
|
||||
pkmn.adjustHeart(-1)
|
||||
pkmn.update_shadow_moves if pkmn.heartStage != stage
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
#===============================================================================
|
||||
# Pokémon sprite (used out of battle)
|
||||
#===============================================================================
|
||||
class PokemonSprite < SpriteWrapper
|
||||
def initialize(viewport=nil)
|
||||
super(viewport)
|
||||
@_iconbitmap = nil
|
||||
end
|
||||
|
||||
def dispose
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap = nil
|
||||
self.bitmap = nil if !self.disposed?
|
||||
super
|
||||
end
|
||||
|
||||
def clearBitmap
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap = nil
|
||||
self.bitmap = nil
|
||||
end
|
||||
|
||||
def setOffset(offset=PictureOrigin::Center)
|
||||
@offset = offset
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def changeOrigin
|
||||
return if !self.bitmap
|
||||
@offset = PictureOrigin::Center if !@offset
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
|
||||
self.ox = 0
|
||||
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
|
||||
self.ox = self.bitmap.width/2
|
||||
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
|
||||
self.ox = self.bitmap.width
|
||||
end
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
|
||||
self.oy = 0
|
||||
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
|
||||
self.oy = self.bitmap.height/2
|
||||
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
|
||||
self.oy = self.bitmap.height
|
||||
end
|
||||
end
|
||||
|
||||
def setPokemonBitmap(pokemon,back=false)
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back) : nil
|
||||
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
|
||||
self.color = Color.new(0,0,0,0)
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def setPokemonBitmapSpecies(pokemon,species,back=false)
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back, species) : nil
|
||||
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def setSpeciesBitmap(species, gender = 0, form = 0, shiny = false, shadow = false, back = false, egg = false)
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap = GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)
|
||||
self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
if @_iconbitmap
|
||||
@_iconbitmap.update
|
||||
self.bitmap = @_iconbitmap.bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Pokémon icon (for defined Pokémon)
|
||||
#===============================================================================
|
||||
class PokemonIconSprite < SpriteWrapper
|
||||
attr_accessor :selected
|
||||
attr_accessor :active
|
||||
attr_reader :pokemon
|
||||
|
||||
def initialize(pokemon,viewport=nil)
|
||||
super(viewport)
|
||||
@selected = false
|
||||
@active = false
|
||||
@numFrames = 0
|
||||
@currentFrame = 0
|
||||
@counter = 0
|
||||
self.pokemon = pokemon
|
||||
@logical_x = 0 # Actual x coordinate
|
||||
@logical_y = 0 # Actual y coordinate
|
||||
@adjusted_x = 0 # Offset due to "jumping" animation in party screen
|
||||
@adjusted_y = 0 # Offset due to "jumping" animation in party screen
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animBitmap.dispose if @animBitmap
|
||||
super
|
||||
end
|
||||
|
||||
def x; return @logical_x; end
|
||||
def y; return @logical_y; end
|
||||
|
||||
def x=(value)
|
||||
@logical_x = value
|
||||
super(@logical_x+@adjusted_x)
|
||||
end
|
||||
|
||||
def y=(value)
|
||||
@logical_y = value
|
||||
super(@logical_y+@adjusted_y)
|
||||
end
|
||||
|
||||
def pokemon=(value)
|
||||
@pokemon = value
|
||||
@animBitmap.dispose if @animBitmap
|
||||
@animBitmap = nil
|
||||
if !@pokemon
|
||||
self.bitmap = nil
|
||||
@currentFrame = 0
|
||||
@counter = 0
|
||||
return
|
||||
end
|
||||
@animBitmap = AnimatedBitmap.new(GameData::Species.icon_filename_from_pokemon(value))
|
||||
self.bitmap = @animBitmap.bitmap
|
||||
self.src_rect.width = @animBitmap.height
|
||||
self.src_rect.height = @animBitmap.height
|
||||
@numFrames = @animBitmap.width/@animBitmap.height
|
||||
@currentFrame = 0 if @currentFrame>=@numFrames
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def setOffset(offset=PictureOrigin::Center)
|
||||
@offset = offset
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def changeOrigin
|
||||
return if !self.bitmap
|
||||
@offset = PictureOrigin::TopLeft if !@offset
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
|
||||
self.ox = 0
|
||||
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
|
||||
self.ox = self.src_rect.width/2
|
||||
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
|
||||
self.ox = self.src_rect.width
|
||||
end
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
|
||||
self.oy = 0
|
||||
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
|
||||
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed
|
||||
# in the middle of the lower three quarters of the image.
|
||||
self.oy = self.src_rect.height*5/8
|
||||
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
|
||||
self.oy = self.src_rect.height
|
||||
end
|
||||
end
|
||||
|
||||
# How long to show each frame of the icon for
|
||||
def counterLimit
|
||||
return 0 if @pokemon.fainted? # Fainted - no animation
|
||||
# ret is initially the time a whole animation cycle lasts. It is divided by
|
||||
# the number of frames in that cycle at the end.
|
||||
ret = Graphics.frame_rate/4 # Green HP - 0.25 seconds
|
||||
if @pokemon.hp<=@pokemon.totalhp/4; ret *= 4 # Red HP - 1 second
|
||||
elsif @pokemon.hp<=@pokemon.totalhp/2; ret *= 2 # Yellow HP - 0.5 seconds
|
||||
end
|
||||
ret /= @numFrames
|
||||
ret = 1 if ret<1
|
||||
return ret
|
||||
end
|
||||
|
||||
def update
|
||||
return if !@animBitmap
|
||||
super
|
||||
@animBitmap.update
|
||||
self.bitmap = @animBitmap.bitmap
|
||||
# Update animation
|
||||
cl = self.counterLimit
|
||||
if cl==0
|
||||
@currentFrame = 0
|
||||
else
|
||||
@counter += 1
|
||||
if @counter>=cl
|
||||
@currentFrame = (@currentFrame+1)%@numFrames
|
||||
@counter = 0
|
||||
end
|
||||
end
|
||||
self.src_rect.x = self.src_rect.width*@currentFrame
|
||||
# Update "jumping" animation (used in party screen)
|
||||
if @selected
|
||||
@adjusted_x = 4
|
||||
@adjusted_y = (@currentFrame>=@numFrames/2) ? -2 : 6
|
||||
else
|
||||
@adjusted_x = 0
|
||||
@adjusted_y = 0
|
||||
end
|
||||
self.x = self.x
|
||||
self.y = self.y
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Pokémon icon (for species)
|
||||
#===============================================================================
|
||||
class PokemonSpeciesIconSprite < SpriteWrapper
|
||||
attr_reader :species
|
||||
attr_reader :gender
|
||||
attr_reader :form
|
||||
attr_reader :shiny
|
||||
|
||||
def initialize(species,viewport=nil)
|
||||
super(viewport)
|
||||
@species = species
|
||||
@gender = 0
|
||||
@form = 0
|
||||
@shiny = 0
|
||||
@numFrames = 0
|
||||
@currentFrame = 0
|
||||
@counter = 0
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animBitmap.dispose if @animBitmap
|
||||
super
|
||||
end
|
||||
|
||||
def species=(value)
|
||||
@species = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def gender=(value)
|
||||
@gender = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def form=(value)
|
||||
@form = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def shiny=(value)
|
||||
@shiny = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def pbSetParams(species,gender,form,shiny=false)
|
||||
@species = species
|
||||
@gender = gender
|
||||
@form = form
|
||||
@shiny = shiny
|
||||
refresh
|
||||
end
|
||||
|
||||
def setOffset(offset=PictureOrigin::Center)
|
||||
@offset = offset
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def changeOrigin
|
||||
return if !self.bitmap
|
||||
@offset = PictureOrigin::TopLeft if !@offset
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft
|
||||
self.ox = 0
|
||||
when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom
|
||||
self.ox = self.src_rect.width/2
|
||||
when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight
|
||||
self.ox = self.src_rect.width
|
||||
end
|
||||
case @offset
|
||||
when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight
|
||||
self.oy = 0
|
||||
when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right
|
||||
# NOTE: This assumes the top quarter of the icon is blank, so oy is placed
|
||||
# in the middle of the lower three quarters of the image.
|
||||
self.oy = self.src_rect.height*5/8
|
||||
when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight
|
||||
self.oy = self.src_rect.height
|
||||
end
|
||||
end
|
||||
|
||||
# How long to show each frame of the icon for
|
||||
def counterLimit
|
||||
# ret is initially the time a whole animation cycle lasts. It is divided by
|
||||
# the number of frames in that cycle at the end.
|
||||
ret = Graphics.frame_rate/4 # 0.25 seconds
|
||||
ret /= @numFrames
|
||||
ret = 1 if ret<1
|
||||
return ret
|
||||
end
|
||||
|
||||
def refresh
|
||||
@animBitmap.dispose if @animBitmap
|
||||
@animBitmap = nil
|
||||
bitmapFileName = GameData::Species.icon_filename(@species, @form, @gender, @shiny)
|
||||
return if !bitmapFileName
|
||||
@animBitmap = AnimatedBitmap.new(bitmapFileName)
|
||||
self.bitmap = @animBitmap.bitmap
|
||||
self.src_rect.width = @animBitmap.height
|
||||
self.src_rect.height = @animBitmap.height
|
||||
@numFrames = @animBitmap.width / @animBitmap.height
|
||||
@currentFrame = 0 if @currentFrame>=@numFrames
|
||||
changeOrigin
|
||||
end
|
||||
|
||||
def update
|
||||
return if !@animBitmap
|
||||
super
|
||||
@animBitmap.update
|
||||
self.bitmap = @animBitmap.bitmap
|
||||
# Update animation
|
||||
@counter += 1
|
||||
if @counter>=self.counterLimit
|
||||
@currentFrame = (@currentFrame+1)%@numFrames
|
||||
@counter = 0
|
||||
end
|
||||
self.src_rect.x = self.src_rect.width*@currentFrame
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,403 @@
|
||||
class PokemonBox
|
||||
attr_reader :pokemon
|
||||
attr_accessor :name
|
||||
attr_accessor :background
|
||||
|
||||
BOX_WIDTH = 6
|
||||
BOX_HEIGHT = 5
|
||||
BOX_SIZE = BOX_WIDTH * BOX_HEIGHT
|
||||
|
||||
def initialize(name, maxPokemon = BOX_SIZE)
|
||||
@pokemon = []
|
||||
@name = name
|
||||
@background = 0
|
||||
for i in 0...maxPokemon
|
||||
@pokemon[i] = nil
|
||||
end
|
||||
end
|
||||
|
||||
def length
|
||||
return @pokemon.length
|
||||
end
|
||||
|
||||
def nitems
|
||||
ret = 0
|
||||
@pokemon.each { |pkmn| ret += 1 if !pkmn.nil? }
|
||||
return ret
|
||||
end
|
||||
|
||||
def full?
|
||||
return nitems == self.length
|
||||
end
|
||||
|
||||
def empty?
|
||||
return nitems == 0
|
||||
end
|
||||
|
||||
def [](i)
|
||||
return @pokemon[i]
|
||||
end
|
||||
|
||||
def []=(i,value)
|
||||
@pokemon[i] = value
|
||||
end
|
||||
|
||||
def each
|
||||
@pokemon.each { |item| yield item }
|
||||
end
|
||||
|
||||
def clear
|
||||
@pokemon.clear
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class PokemonStorage
|
||||
attr_reader :boxes
|
||||
attr_accessor :currentBox
|
||||
attr_writer :unlockedWallpapers
|
||||
BASICWALLPAPERQTY = 16
|
||||
|
||||
def initialize(maxBoxes = Settings::NUM_STORAGE_BOXES, maxPokemon = PokemonBox::BOX_SIZE)
|
||||
@boxes = []
|
||||
for i in 0...maxBoxes
|
||||
@boxes[i] = PokemonBox.new(_INTL("Box {1}",i+1),maxPokemon)
|
||||
@boxes[i].background = i % BASICWALLPAPERQTY
|
||||
end
|
||||
@currentBox = 0
|
||||
@boxmode = -1
|
||||
@unlockedWallpapers = []
|
||||
for i in 0...allWallpapers.length
|
||||
@unlockedWallpapers[i] = false
|
||||
end
|
||||
end
|
||||
|
||||
def allWallpapers
|
||||
return [
|
||||
# Basic wallpapers
|
||||
_INTL("Forest"),_INTL("City"),_INTL("Desert"),_INTL("Savanna"),
|
||||
_INTL("Crag"),_INTL("Volcano"),_INTL("Snow"),_INTL("Cave"),
|
||||
_INTL("Beach"),_INTL("Seafloor"),_INTL("River"),_INTL("Sky"),
|
||||
_INTL("Poké Center"),_INTL("Machine"),_INTL("Checks"),_INTL("Simple"),
|
||||
# Special wallpapers
|
||||
_INTL("Space"),_INTL("Backyard"),_INTL("Nostalgic 1"),_INTL("Torchic"),
|
||||
_INTL("Trio 1"),_INTL("PikaPika 1"),_INTL("Legend 1"),_INTL("Team Galactic 1"),
|
||||
_INTL("Distortion"),_INTL("Contest"),_INTL("Nostalgic 2"),_INTL("Croagunk"),
|
||||
_INTL("Trio 2"),_INTL("PikaPika 2"),_INTL("Legend 2"),_INTL("Team Galactic 2"),
|
||||
_INTL("Heart"),_INTL("Soul"),_INTL("Big Brother"),_INTL("Pokéathlon"),
|
||||
_INTL("Trio 3"),_INTL("Spiky Pika"),_INTL("Kimono Girl"),_INTL("Revival")
|
||||
]
|
||||
end
|
||||
|
||||
def unlockedWallpapers
|
||||
@unlockedWallpapers = [] if !@unlockedWallpapers
|
||||
return @unlockedWallpapers
|
||||
end
|
||||
|
||||
def isAvailableWallpaper?(i)
|
||||
@unlockedWallpapers = [] if !@unlockedWallpapers
|
||||
return true if i<BASICWALLPAPERQTY
|
||||
return true if @unlockedWallpapers[i]
|
||||
return false
|
||||
end
|
||||
|
||||
def availableWallpapers
|
||||
ret = [[],[]] # Names, IDs
|
||||
papers = allWallpapers
|
||||
@unlockedWallpapers = [] if !@unlockedWallpapers
|
||||
for i in 0...papers.length
|
||||
next if !isAvailableWallpaper?(i)
|
||||
ret[0].push(papers[i]); ret[1].push(i)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def party
|
||||
$Trainer.party
|
||||
end
|
||||
|
||||
def party=(_value)
|
||||
raise ArgumentError.new("Not supported")
|
||||
end
|
||||
|
||||
def party_full?
|
||||
return $Trainer.party_full?
|
||||
end
|
||||
|
||||
def maxBoxes
|
||||
return @boxes.length
|
||||
end
|
||||
|
||||
def maxPokemon(box)
|
||||
return 0 if box >= self.maxBoxes
|
||||
return (box < 0) ? Settings::MAX_PARTY_SIZE : self[box].length
|
||||
end
|
||||
|
||||
def full?
|
||||
for i in 0...self.maxBoxes
|
||||
return false if !@boxes[i].full?
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbFirstFreePos(box)
|
||||
if box==-1
|
||||
ret = self.party.length
|
||||
return (ret >= Settings::MAX_PARTY_SIZE) ? -1 : ret
|
||||
end
|
||||
for i in 0...maxPokemon(box)
|
||||
return i if !self[box,i]
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
def [](x,y=nil)
|
||||
if y==nil
|
||||
return (x==-1) ? self.party : @boxes[x]
|
||||
else
|
||||
for i in @boxes
|
||||
raise "Box is a Pokémon, not a box" if i.is_a?(Pokemon)
|
||||
end
|
||||
return (x==-1) ? self.party[y] : @boxes[x][y]
|
||||
end
|
||||
end
|
||||
|
||||
def []=(x,y,value)
|
||||
if x==-1
|
||||
self.party[y] = value
|
||||
else
|
||||
@boxes[x][y] = value
|
||||
end
|
||||
end
|
||||
|
||||
def pbCopy(boxDst,indexDst,boxSrc,indexSrc)
|
||||
if indexDst<0 && boxDst<self.maxBoxes
|
||||
found = false
|
||||
for i in 0...maxPokemon(boxDst)
|
||||
next if self[boxDst,i]
|
||||
found = true
|
||||
indexDst = i
|
||||
break
|
||||
end
|
||||
return false if !found
|
||||
end
|
||||
if boxDst==-1 # Copying into party
|
||||
return false if party_full?
|
||||
self.party[self.party.length] = self[boxSrc,indexSrc]
|
||||
self.party.compact!
|
||||
else # Copying into box
|
||||
pkmn = self[boxSrc,indexSrc]
|
||||
raise "Trying to copy nil to storage" if !pkmn
|
||||
pkmn.time_form_set = nil
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
self[boxDst,indexDst] = pkmn
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbMove(boxDst,indexDst,boxSrc,indexSrc)
|
||||
return false if !pbCopy(boxDst,indexDst,boxSrc,indexSrc)
|
||||
pbDelete(boxSrc,indexSrc)
|
||||
return true
|
||||
end
|
||||
|
||||
def pbMoveCaughtToParty(pkmn)
|
||||
return false if party_full?
|
||||
self.party[self.party.length] = pkmn
|
||||
end
|
||||
|
||||
def pbMoveCaughtToBox(pkmn,box)
|
||||
for i in 0...maxPokemon(box)
|
||||
if self[box,i]==nil
|
||||
if box>=0
|
||||
pkmn.time_form_set = nil if pkmn.time_form_set
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
end
|
||||
self[box,i] = pkmn
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def pbStoreCaught(pkmn)
|
||||
if @currentBox>=0
|
||||
pkmn.time_form_set = nil
|
||||
pkmn.form = 0 if pkmn.isSpecies?(:SHAYMIN)
|
||||
pkmn.heal
|
||||
end
|
||||
for i in 0...maxPokemon(@currentBox)
|
||||
if self[@currentBox,i]==nil
|
||||
self[@currentBox,i] = pkmn
|
||||
return @currentBox
|
||||
end
|
||||
end
|
||||
for j in 0...self.maxBoxes
|
||||
for i in 0...maxPokemon(j)
|
||||
if self[j,i]==nil
|
||||
self[j,i] = pkmn
|
||||
@currentBox = j
|
||||
return @currentBox
|
||||
end
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
def pbDelete(box,index)
|
||||
if self[box,index]
|
||||
self[box,index] = nil
|
||||
self.party.compact! if box==-1
|
||||
end
|
||||
end
|
||||
|
||||
def clear
|
||||
for i in 0...self.maxBoxes
|
||||
@boxes[i].clear
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Regional Storage scripts
|
||||
#===============================================================================
|
||||
class RegionalStorage
|
||||
def initialize
|
||||
@storages = []
|
||||
@lastmap = -1
|
||||
@rgnmap = -1
|
||||
end
|
||||
|
||||
def getCurrentStorage
|
||||
if !$game_map
|
||||
raise _INTL("The player is not on a map, so the region could not be determined.")
|
||||
end
|
||||
if @lastmap!=$game_map.map_id
|
||||
@rgnmap = pbGetCurrentRegion # may access file IO, so caching result
|
||||
@lastmap = $game_map.map_id
|
||||
end
|
||||
if @rgnmap<0
|
||||
raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.")
|
||||
end
|
||||
if !@storages[@rgnmap]
|
||||
@storages[@rgnmap] = PokemonStorage.new
|
||||
end
|
||||
return @storages[@rgnmap]
|
||||
end
|
||||
|
||||
def allWallpapers
|
||||
return getCurrentStorage.allWallpapers
|
||||
end
|
||||
|
||||
def availableWallpapers
|
||||
return getCurrentStorage.availableWallpapers
|
||||
end
|
||||
|
||||
def unlockWallpaper(index)
|
||||
getCurrentStorage.unlockWallpaper(index)
|
||||
end
|
||||
|
||||
def boxes
|
||||
return getCurrentStorage.boxes
|
||||
end
|
||||
|
||||
def party
|
||||
return getCurrentStorage.party
|
||||
end
|
||||
|
||||
def party_full?
|
||||
return getCurrentStorage.party_full?
|
||||
end
|
||||
|
||||
def maxBoxes
|
||||
return getCurrentStorage.maxBoxes
|
||||
end
|
||||
|
||||
def maxPokemon(box)
|
||||
return getCurrentStorage.maxPokemon(box)
|
||||
end
|
||||
|
||||
def full?
|
||||
getCurrentStorage.full?
|
||||
end
|
||||
|
||||
def currentBox
|
||||
return getCurrentStorage.currentBox
|
||||
end
|
||||
|
||||
def currentBox=(value)
|
||||
getCurrentStorage.currentBox = value
|
||||
end
|
||||
|
||||
def [](x,y=nil)
|
||||
getCurrentStorage[x,y]
|
||||
end
|
||||
|
||||
def []=(x,y,value)
|
||||
getCurrentStorage[x,y] = value
|
||||
end
|
||||
|
||||
def pbFirstFreePos(box)
|
||||
getCurrentStorage.pbFirstFreePos(box)
|
||||
end
|
||||
|
||||
def pbCopy(boxDst,indexDst,boxSrc,indexSrc)
|
||||
getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc)
|
||||
end
|
||||
|
||||
def pbMove(boxDst,indexDst,boxSrc,indexSrc)
|
||||
getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc)
|
||||
end
|
||||
|
||||
def pbMoveCaughtToParty(pkmn)
|
||||
getCurrentStorage.pbMoveCaughtToParty(pkmn)
|
||||
end
|
||||
|
||||
def pbMoveCaughtToBox(pkmn,box)
|
||||
getCurrentStorage.pbMoveCaughtToBox(pkmn,box)
|
||||
end
|
||||
|
||||
def pbStoreCaught(pkmn)
|
||||
getCurrentStorage.pbStoreCaught(pkmn)
|
||||
end
|
||||
|
||||
def pbDelete(box,index)
|
||||
getCurrentStorage.pbDelete(pkmn)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbUnlockWallpaper(index)
|
||||
$PokemonStorage.unlockedWallpapers[index] = true
|
||||
end
|
||||
|
||||
def pbLockWallpaper(index) # Don't know why you'd want to do this
|
||||
$PokemonStorage.unlockedWallpapers[index] = false
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Look through Pokémon in storage
|
||||
#===============================================================================
|
||||
# Yields every Pokémon/egg in storage in turn.
|
||||
def pbEachPokemon
|
||||
for i in -1...$PokemonStorage.maxBoxes
|
||||
for j in 0...$PokemonStorage.maxPokemon(i)
|
||||
pkmn = $PokemonStorage[i][j]
|
||||
yield(pkmn,i) if pkmn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Yields every Pokémon in storage in turn.
|
||||
def pbEachNonEggPokemon
|
||||
pbEachPokemon { |pkmn,box| yield(pkmn,box) if !pkmn.egg? }
|
||||
end
|
||||
1105
Data/Scripts/014_Pokemon/001_Pokemon.rb
Normal file
1105
Data/Scripts/014_Pokemon/001_Pokemon.rb
Normal file
File diff suppressed because it is too large
Load Diff
81
Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb
Normal file
81
Data/Scripts/014_Pokemon/002_Pokemon_MegaEvolution.rb
Normal file
@@ -0,0 +1,81 @@
|
||||
class Pokemon
|
||||
#=============================================================================
|
||||
# Mega Evolution
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#=============================================================================
|
||||
def getMegaForm(checkItemOnly = false)
|
||||
ret = 0
|
||||
GameData::Species.each do |data|
|
||||
next if data.species != @species
|
||||
if data.mega_stone && hasItem?(data.mega_stone)
|
||||
ret = data.form
|
||||
break
|
||||
elsif !checkItemOnly && data.mega_move && hasMove?(data.mega_move)
|
||||
ret = data.form
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret # form number, or 0 if no accessible Mega form
|
||||
end
|
||||
|
||||
def getUnmegaForm
|
||||
return (mega?) ? species_data.unmega_form : -1
|
||||
end
|
||||
|
||||
def hasMegaForm?
|
||||
megaForm = self.getMegaForm
|
||||
return megaForm > 0 && megaForm != form_simple
|
||||
end
|
||||
|
||||
def mega?
|
||||
megaForm = self.getMegaForm
|
||||
return megaForm > 0 && megaForm == form_simple
|
||||
end
|
||||
alias isMega? mega?
|
||||
|
||||
def makeMega
|
||||
megaForm = self.getMegaForm
|
||||
self.form = megaForm if megaForm > 0
|
||||
end
|
||||
|
||||
def makeUnmega
|
||||
unmegaForm = self.getUnmegaForm
|
||||
self.form = unmegaForm if unmegaForm >= 0
|
||||
end
|
||||
|
||||
def megaName
|
||||
formName = species_data.form_name
|
||||
return (formName && !formName.empty?) ? formName : _INTL("Mega {1}", species_data.name)
|
||||
end
|
||||
|
||||
def megaMessage # 0=default message, 1=Rayquaza message
|
||||
return species_data.mega_message
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Primal Reversion
|
||||
# NOTE: These are treated as form changes in Essentials.
|
||||
#=============================================================================
|
||||
def hasPrimalForm?
|
||||
v = MultipleForms.call("getPrimalForm",self)
|
||||
return v!=nil
|
||||
end
|
||||
|
||||
def primal?
|
||||
v = MultipleForms.call("getPrimalForm",self)
|
||||
return v!=nil && v==@form
|
||||
end
|
||||
alias isPrimal? primal?
|
||||
|
||||
def makePrimal
|
||||
v = MultipleForms.call("getPrimalForm",self)
|
||||
self.form = v if v!=nil
|
||||
end
|
||||
|
||||
def makeUnprimal
|
||||
v = MultipleForms.call("getUnprimalForm",self)
|
||||
if v!=nil; self.form = v
|
||||
elsif primal?; self.form = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
159
Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb
Normal file
159
Data/Scripts/014_Pokemon/003_Pokemon_ShadowPokemon.rb
Normal file
@@ -0,0 +1,159 @@
|
||||
#===============================================================================
|
||||
# Pokémon class.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
attr_accessor :shadow
|
||||
attr_writer :heart_gauge
|
||||
attr_writer :hyper_mode
|
||||
attr_accessor :saved_exp
|
||||
attr_accessor :saved_ev
|
||||
attr_accessor :shadow_moves
|
||||
HEART_GAUGE_SIZE = 3840
|
||||
|
||||
alias :__shadow_expeq :exp=
|
||||
def exp=(value)
|
||||
if shadowPokemon?
|
||||
@saved_exp += value - @exp
|
||||
else
|
||||
__shadow_expeq(value)
|
||||
end
|
||||
end
|
||||
|
||||
alias :__shadow_hpeq :hp=
|
||||
def hp=(value)
|
||||
__shadow_hpeq(value)
|
||||
@hyper_mode = false if @hp <= 0
|
||||
end
|
||||
|
||||
def heart_gauge
|
||||
return @heart_gauge || 0
|
||||
end
|
||||
|
||||
def adjustHeart(value)
|
||||
return if !shadowPokemon?
|
||||
@heart_gauge = (self.heart_gauge + value).clamp(0, HEART_GAUGE_SIZE)
|
||||
end
|
||||
|
||||
def heartStage
|
||||
return 0 if !shadowPokemon?
|
||||
stage_size = HEART_GAUGE_SIZE / 5.0
|
||||
return ([self.heart_gauge, HEART_GAUGE_SIZE].min / stage_size).ceil
|
||||
end
|
||||
|
||||
def shadowPokemon?
|
||||
return @shadow && @heart_gauge && @heart_gauge >= 0
|
||||
end
|
||||
alias isShadow? shadowPokemon?
|
||||
|
||||
def hyper_mode
|
||||
return (self.heart_gauge == 0 || @hp == 0) ? false : @hyper_mode
|
||||
end
|
||||
|
||||
def makeShadow
|
||||
@shadow = true
|
||||
@heart_gauge = HEART_GAUGE_SIZE
|
||||
@hyper_mode = false
|
||||
@saved_exp = 0
|
||||
@saved_ev = {}
|
||||
GameData::Stat.each_main { |s| @saved_ev[s.id] = 0 }
|
||||
@shadow_moves = []
|
||||
# Retrieve Shadow moveset for this Pokémon
|
||||
shadow_moveset = pbLoadShadowMovesets[species_data.id]
|
||||
shadow_moveset = pbLoadShadowMovesets[@species] if !shadow_moveset || shadow_moveset.length == 0
|
||||
# Record this Pokémon's Shadow moves
|
||||
if shadow_moveset && shadow_moveset.length > 0
|
||||
for i in 0...[shadow_moveset.length, MAX_MOVES].min
|
||||
@shadow_moves[i] = shadow_moveset[i]
|
||||
end
|
||||
elsif GameData::Move.exists?(:SHADOWRUSH)
|
||||
# No Shadow moveset defined; just use Shadow Rush
|
||||
@shadow_moves[0] = :SHADOWRUSH
|
||||
else
|
||||
raise _INTL("Expected Shadow moves or Shadow Rush to be defined, but they weren't.")
|
||||
end
|
||||
# Record this Pokémon's original moves
|
||||
@moves.each_with_index { |m, i| @shadow_moves[MAX_MOVES + i] = m.id }
|
||||
# Update moves
|
||||
update_shadow_moves
|
||||
end
|
||||
|
||||
def update_shadow_moves(relearn_all_moves = false)
|
||||
return if !@shadow_moves
|
||||
# Not a Shadow Pokémon (any more); relearn all its original moves
|
||||
if !shadowPokemon?
|
||||
if @shadow_moves.length > MAX_MOVES
|
||||
new_moves = []
|
||||
@shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i >= MAX_MOVES }
|
||||
replace_moves(new_moves)
|
||||
end
|
||||
@shadow_moves = nil
|
||||
return
|
||||
end
|
||||
# Is a Shadow Pokémon; ensure it knows the appropriate moves depending on its heart stage
|
||||
# Start with all Shadow moves
|
||||
new_moves = []
|
||||
@shadow_moves.each_with_index { |m, i| new_moves.push(m) if m && i < MAX_MOVES }
|
||||
num_shadow_moves = new_moves.length
|
||||
# Add some original moves (skipping ones in the same slot as a Shadow Move)
|
||||
num_original_moves = (relearn_all_moves) ? 3 : [3, 3, 2, 1, 1, 0][self.heartStage]
|
||||
if num_original_moves > 0
|
||||
relearned_count = 0
|
||||
@shadow_moves.each_with_index do |m, i|
|
||||
next if !m || i < MAX_MOVES + num_shadow_moves
|
||||
new_moves.push(m)
|
||||
relearned_count += 1
|
||||
break if relearned_count >= num_original_moves
|
||||
end
|
||||
end
|
||||
# Relearn Shadow moves plus some original moves (may not change anything)
|
||||
replace_moves(new_moves)
|
||||
end
|
||||
|
||||
def replace_moves(new_moves)
|
||||
new_moves.each do |move|
|
||||
next if !move || !GameData::Move.exists?(move) || hasMove?(move)
|
||||
if numMoves < Pokemon::MAX_MOVES # Has an empty slot; just learn move
|
||||
learn_move(move)
|
||||
next
|
||||
end
|
||||
@moves.each do |m|
|
||||
next if new_moves.include?(m.id)
|
||||
m.id = GameData::Move.get(move).id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def purifiable?
|
||||
return false if !shadowPokemon? || self.heart_gauge > 0
|
||||
return false if isSpecies?(:LUGIA)
|
||||
return true
|
||||
end
|
||||
|
||||
def check_ready_to_purify
|
||||
return if !shadowPokemon?
|
||||
update_shadow_moves
|
||||
pbMessage(_INTL("{1} can now be purified!", self.name)) if self.heart_gauge == 0
|
||||
end
|
||||
|
||||
def add_evs(added_evs)
|
||||
total = 0
|
||||
@ev.each_value { |e| total += e }
|
||||
GameData::Stat.each_main do |s|
|
||||
addition = added_evs[s.id].clamp(0, Pokemon::EV_STAT_LIMIT - @ev[s.id])
|
||||
addition = addition.clamp(0, Pokemon::EV_LIMIT - total)
|
||||
next if addition == 0
|
||||
@ev[s.id] += addition
|
||||
total += addition
|
||||
end
|
||||
end
|
||||
|
||||
alias :__shadow_clone :clone
|
||||
def clone
|
||||
ret = __shadow_clone
|
||||
if @saved_ev
|
||||
GameData::Stat.each_main { |s| ret.saved_ev[s.id] = @saved_ev[s.id] }
|
||||
end
|
||||
ret.shadow_moves = @shadow_moves.clone if @shadow_moves
|
||||
return ret
|
||||
end
|
||||
end
|
||||
78
Data/Scripts/014_Pokemon/004_Pokemon_Move.rb
Normal file
78
Data/Scripts/014_Pokemon/004_Pokemon_Move.rb
Normal file
@@ -0,0 +1,78 @@
|
||||
#===============================================================================
|
||||
# Move objects known by Pokémon.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
class Move
|
||||
# This move's ID.
|
||||
attr_reader :id
|
||||
# The amount of PP remaining for this move.
|
||||
attr_reader :pp
|
||||
# The number of PP Ups used on this move (each one adds 20% to the total PP).
|
||||
attr_reader :ppup
|
||||
|
||||
# Creates a new Move object.
|
||||
# @param move_id [Symbol, String, Integer] move ID
|
||||
def initialize(move_id)
|
||||
@id = GameData::Move.get(move_id).id
|
||||
@ppup = 0
|
||||
@pp = total_pp
|
||||
end
|
||||
|
||||
# Sets this move's ID, and caps the PP amount if it is now greater than this
|
||||
# move's total PP.
|
||||
# @param value [Symbol, String, Integer] the new move ID
|
||||
def id=(value)
|
||||
@id = GameData::Move.get(value).id
|
||||
@pp = @pp.clamp(0, total_pp)
|
||||
end
|
||||
|
||||
# Sets this move's PP, capping it at this move's total PP.
|
||||
# @param value [Integer] the new PP amount
|
||||
def pp=(value)
|
||||
@pp = value.clamp(0, total_pp)
|
||||
end
|
||||
|
||||
# Sets this move's PP Up count, and caps the PP if necessary.
|
||||
# @param value [Integer] the new PP Up value
|
||||
def ppup=(value)
|
||||
@ppup = value
|
||||
@pp = @pp.clamp(0, total_pp)
|
||||
end
|
||||
|
||||
# Returns the total PP of this move, taking PP Ups into account.
|
||||
# @return [Integer] total PP
|
||||
def total_pp
|
||||
max_pp = GameData::Move.get(@id).total_pp
|
||||
return max_pp + max_pp * @ppup / 5
|
||||
end
|
||||
alias totalpp total_pp
|
||||
|
||||
def function_code; return GameData::Move.get(@id).function_code; end
|
||||
def base_damage; return GameData::Move.get(@id).base_damage; end
|
||||
def type; return GameData::Move.get(@id).type; end
|
||||
def category; return GameData::Move.get(@id).category; end
|
||||
def accuracy; return GameData::Move.get(@id).accuracy; end
|
||||
def effect_chance; return GameData::Move.get(@id).effect_chance; end
|
||||
def target; return GameData::Move.get(@id).target; end
|
||||
def priority; return GameData::Move.get(@id).priority; end
|
||||
def flags; return GameData::Move.get(@id).flags; end
|
||||
def name; return GameData::Move.get(@id).name; end
|
||||
def description; return GameData::Move.get(@id).description; end
|
||||
def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Legacy move object known by Pokémon.
|
||||
#===============================================================================
|
||||
# @deprecated Use {Pokemon#Move} instead. PBMove is slated to be removed in v20.
|
||||
class PBMove
|
||||
attr_reader :id, :pp, :ppup
|
||||
|
||||
def self.convert(move)
|
||||
ret = Pokemon::Move.new(move.id)
|
||||
ret.ppup = move.ppup
|
||||
ret.pp = move.pp
|
||||
return ret
|
||||
end
|
||||
end
|
||||
73
Data/Scripts/014_Pokemon/005_Pokemon_Owner.rb
Normal file
73
Data/Scripts/014_Pokemon/005_Pokemon_Owner.rb
Normal file
@@ -0,0 +1,73 @@
|
||||
#===============================================================================
|
||||
# Stores information about a Pokémon's owner.
|
||||
#===============================================================================
|
||||
class Pokemon
|
||||
class Owner
|
||||
# @return [Integer] the ID of the owner
|
||||
attr_reader :id
|
||||
# @return [String] the name of the owner
|
||||
attr_reader :name
|
||||
# @return [Integer] the gender of the owner (0 = male, 1 = female, 2 = unknown)
|
||||
attr_reader :gender
|
||||
# @return [Integer] the language of the owner (see pbGetLanguage for language IDs)
|
||||
attr_reader :language
|
||||
|
||||
# @param id [Integer] the ID of the owner
|
||||
# @param name [String] the name of the owner
|
||||
# @param gender [Integer] the gender of the owner (0 = male, 1 = female, 2 = unknown)
|
||||
# @param language [Integer] the language of the owner (see pbGetLanguage for language IDs)
|
||||
def initialize(id, name, gender, language)
|
||||
validate id => Integer, name => String, gender => Integer, language => Integer
|
||||
@id = id
|
||||
@name = name
|
||||
@gender = gender
|
||||
@language = language
|
||||
end
|
||||
|
||||
# Returns a new Owner object populated with values taken from +trainer+.
|
||||
# @param trainer [Player, NPCTrainer] trainer object to read data from
|
||||
# @return [Owner] new Owner object
|
||||
def self.new_from_trainer(trainer)
|
||||
validate trainer => [Player, NPCTrainer]
|
||||
return new(trainer.id, trainer.name, trainer.gender, trainer.language)
|
||||
end
|
||||
|
||||
# Returns an Owner object with a foreign ID.
|
||||
# @param name [String] owner name
|
||||
# @param gender [Integer] owner gender
|
||||
# @param language [Integer] owner language
|
||||
# @return [Owner] foreign Owner object
|
||||
def self.new_foreign(name = '', gender = 2, language = 2)
|
||||
return new($Trainer.make_foreign_ID, name, gender, language)
|
||||
end
|
||||
|
||||
# @param new_id [Integer] new owner ID
|
||||
def id=(new_id)
|
||||
validate new_id => Integer
|
||||
@id = new_id
|
||||
end
|
||||
|
||||
# @param new_name [String] new owner name
|
||||
def name=(new_name)
|
||||
validate new_name => String
|
||||
@name = new_name
|
||||
end
|
||||
|
||||
# @param new_gender [Integer] new owner gender
|
||||
def gender=(new_gender)
|
||||
validate new_gender => Integer
|
||||
@gender = new_gender
|
||||
end
|
||||
|
||||
# @param new_language [Integer] new owner language
|
||||
def language=(new_language)
|
||||
validate new_language => Integer
|
||||
@language = new_language
|
||||
end
|
||||
|
||||
# @return [Integer] the public portion of the owner's ID
|
||||
def public_id
|
||||
return @id & 0xFFFF
|
||||
end
|
||||
end
|
||||
end
|
||||
206
Data/Scripts/014_Pokemon/006_Pokemon_Deprecated.rb
Normal file
206
Data/Scripts/014_Pokemon/006_Pokemon_Deprecated.rb
Normal file
@@ -0,0 +1,206 @@
|
||||
#===============================================================================
|
||||
# Deprecated classes, methods and constants for Pokémon.
|
||||
# These will be removed in a future Essentials version.
|
||||
#===============================================================================
|
||||
|
||||
# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon is slated to be removed in v20.
|
||||
class PokeBattle_Pokemon
|
||||
attr_reader :name, :species, :form, :formTime, :forcedForm, :fused
|
||||
attr_reader :personalID, :exp, :hp, :status, :statusCount
|
||||
attr_reader :abilityflag, :genderflag, :natureflag, :natureOverride, :shinyflag
|
||||
attr_reader :moves, :firstmoves
|
||||
attr_reader :item, :mail
|
||||
attr_reader :iv, :ivMaxed, :ev
|
||||
attr_reader :happiness, :eggsteps, :pokerus
|
||||
attr_reader :ballused, :markings, :ribbons
|
||||
attr_reader :obtainMode, :obtainMap, :obtainText, :obtainLevel, :hatchedMap
|
||||
attr_reader :timeReceived, :timeEggHatched
|
||||
attr_reader :cool, :beauty, :cute, :smart, :tough, :sheen
|
||||
attr_reader :trainerID, :ot, :otgender, :language
|
||||
attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode, :shadowmoves
|
||||
|
||||
def initialize(*args)
|
||||
raise "PokeBattle_Pokemon.new is deprecated. Use Pokemon.new instead."
|
||||
end
|
||||
|
||||
def self.convert(pkmn)
|
||||
return pkmn if pkmn.is_a?(Pokemon)
|
||||
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
|
||||
# Set level to 1 initially, as it will be recalculated later
|
||||
ret = Pokemon.new(pkmn.species, 1, owner, false, false)
|
||||
ret.forced_form = pkmn.forcedForm if pkmn.forcedForm
|
||||
ret.time_form_set = pkmn.formTime
|
||||
ret.exp = pkmn.exp
|
||||
ret.steps_to_hatch = pkmn.eggsteps
|
||||
ret.status = pkmn.status
|
||||
ret.statusCount = pkmn.statusCount
|
||||
ret.gender = pkmn.genderflag
|
||||
ret.shiny = pkmn.shinyflag
|
||||
ret.ability_index = pkmn.abilityflag
|
||||
ret.nature = pkmn.natureflag
|
||||
ret.nature_for_stats = pkmn.natureOverride
|
||||
ret.item = pkmn.item
|
||||
ret.mail = PokemonMail.convert(pkmn.mail) if pkmn.mail
|
||||
pkmn.moves.each { |m| ret.moves.push(PBMove.convert(m)) if m && m.id > 0 }
|
||||
if pkmn.firstmoves
|
||||
pkmn.firstmoves.each { |m| ret.add_first_move(m) }
|
||||
end
|
||||
if pkmn.ribbons
|
||||
pkmn.ribbons.each { |r| ret.giveRibbon(r) }
|
||||
end
|
||||
ret.cool = pkmn.cool if pkmn.cool
|
||||
ret.beauty = pkmn.beauty if pkmn.beauty
|
||||
ret.cute = pkmn.cute if pkmn.cute
|
||||
ret.smart = pkmn.smart if pkmn.smart
|
||||
ret.tough = pkmn.tough if pkmn.tough
|
||||
ret.sheen = pkmn.sheen if pkmn.sheen
|
||||
ret.pokerus = pkmn.pokerus if pkmn.pokerus
|
||||
ret.name = pkmn.name if pkmn.name != ret.speciesName
|
||||
ret.happiness = pkmn.happiness
|
||||
ret.poke_ball = pbBallTypeToItem(pkmn.ballused).id
|
||||
ret.markings = pkmn.markings if pkmn.markings
|
||||
GameData::Stat.each_main do |s|
|
||||
ret.iv[s.id] = pkmn.iv[s.id_number]
|
||||
ret.ivMaxed[s.id] = pkmn.ivMaxed[s.id_number] if pkmn.ivMaxed
|
||||
ret.ev[s.id] = pkmn.ev[s.id_number]
|
||||
end
|
||||
ret.obtain_method = pkmn.obtainMode
|
||||
ret.obtain_map = pkmn.obtainMap
|
||||
ret.obtain_text = pkmn.obtainText
|
||||
ret.obtain_level = pkmn.obtainLevel if pkmn.obtainLevel
|
||||
ret.hatched_map = pkmn.hatchedMap
|
||||
ret.timeReceived = pkmn.timeReceived
|
||||
ret.timeEggHatched = pkmn.timeEggHatched
|
||||
if pkmn.fused
|
||||
ret.fused = PokeBattle_Pokemon.convert(pkmn.fused) if pkmn.fused.is_a?(PokeBattle_Pokemon)
|
||||
ret.fused = pkmn.fused if pkmn.fused.is_a?(Pokemon)
|
||||
end
|
||||
ret.personalID = pkmn.personalID
|
||||
ret.hp = pkmn.hp
|
||||
if pkmn.shadow
|
||||
ret.shadow = pkmn.shadow
|
||||
ret.heart_gauge = pkmn.heartgauge
|
||||
ret.hyper_mode = pkmn.hypermode
|
||||
ret.saved_exp = pkmn.savedexp
|
||||
if pkmn.savedev
|
||||
GameData::Stat.each_main { |s| ret.saved_ev[s.id] = pkmn.savedev[s.pbs_order] if s.pbs_order >= 0 }
|
||||
end
|
||||
ret.shadow_moves = []
|
||||
pkmn.shadowmoves.each_with_index do |move, i|
|
||||
ret.shadow_moves[i] = GameData::Move.get(move).id if move
|
||||
end
|
||||
end
|
||||
# NOTE: Intentionally set last, as it recalculates stats.
|
||||
ret.form_simple = pkmn.form || 0
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
class Pokemon
|
||||
# @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in v20.
|
||||
MAX_POKEMON_NAME_SIZE = MAX_NAME_SIZE
|
||||
deprecate_constant :MAX_POKEMON_NAME_SIZE
|
||||
|
||||
# @deprecated Use {Owner#public_id} instead. This alias is slated to be removed in v20.
|
||||
def publicID
|
||||
Deprecation.warn_method('Pokemon#publicID', 'v20', 'Pokemon::Owner#public_id')
|
||||
return @owner.public_id
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#id} instead. This alias is slated to be removed in v20.
|
||||
def trainerID
|
||||
Deprecation.warn_method('Pokemon#trainerID', 'v20', 'Pokemon::Owner#id')
|
||||
return @owner.id
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#id=} instead. This alias is slated to be removed in v20.
|
||||
def trainerID=(value)
|
||||
Deprecation.warn_method('Pokemon#trainerID=', 'v20', 'Pokemon::Owner#id=')
|
||||
@owner.id = value
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#name} instead. This alias is slated to be removed in v20.
|
||||
def ot
|
||||
Deprecation.warn_method('Pokemon#ot', 'v20', 'Pokemon::Owner#name')
|
||||
return @owner.name
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#name=} instead. This alias is slated to be removed in v20.
|
||||
def ot=(value)
|
||||
Deprecation.warn_method('Pokemon#ot=', 'v20', 'Pokemon::Owner#name=')
|
||||
@owner.name = value
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#gender} instead. This alias is slated to be removed in v20.
|
||||
def otgender
|
||||
Deprecation.warn_method('Pokemon#otgender', 'v20', 'Pokemon::Owner#gender')
|
||||
return @owner.gender
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#gender=} instead. This alias is slated to be removed in v20.
|
||||
def otgender=(value)
|
||||
Deprecation.warn_method('Pokemon#otgender=', 'v20', 'Pokemon::Owner#gender=')
|
||||
@owner.gender = value
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#language} instead. This alias is slated to be removed in v20.
|
||||
def language
|
||||
Deprecation.warn_method('Pokemon#language', 'v20', 'Pokemon::Owner#language')
|
||||
return @owner.language
|
||||
end
|
||||
|
||||
# @deprecated Use {Owner#language=} instead. This alias is slated to be removed in v20.
|
||||
def language=(value)
|
||||
Deprecation.warn_method('Pokemon#language=', 'v20', 'Pokemon::Owner#language=')
|
||||
@owner.language = value
|
||||
end
|
||||
|
||||
# @deprecated Use {Pokemon#shiny=} instead. This alias is slated to be removed in v20.
|
||||
def makeShiny
|
||||
Deprecation.warn_method('Pokemon#makeShiny', 'v20', 'Pokemon#shiny=true')
|
||||
self.shiny = true
|
||||
end
|
||||
|
||||
# @deprecated Use {Pokemon#shiny=} instead. This alias is slated to be removed in v20.
|
||||
def makeNotShiny
|
||||
Deprecation.warn_method('Pokemon#makeNotShiny', 'v20', 'Pokemon#shiny=false')
|
||||
self.shiny = false
|
||||
end
|
||||
|
||||
deprecated_method_alias :isEgg?, :egg?, removal_in: 'v20'
|
||||
deprecated_method_alias :isAble?, :able?, removal_in: 'v20'
|
||||
deprecated_method_alias :isFainted?, :fainted?, removal_in: 'v20'
|
||||
deprecated_method_alias :isShiny?, :shiny?, removal_in: 'v20'
|
||||
deprecated_method_alias :setForm, :form=, removal_in: 'v20'
|
||||
deprecated_method_alias :setGender, :gender=, removal_in: 'v20'
|
||||
deprecated_method_alias :isMale?, :male?, removal_in: 'v20'
|
||||
deprecated_method_alias :isFemale?, :female?, removal_in: 'v20'
|
||||
deprecated_method_alias :isGenderless?, :genderless?, removal_in: 'v20'
|
||||
deprecated_method_alias :isSingleGendered?, :singleGendered?, removal_in: 'v20'
|
||||
deprecated_method_alias :setAbility, :ability_index=, removal_in: 'v20'
|
||||
deprecated_method_alias :setNature, :nature=, removal_in: 'v20'
|
||||
deprecated_method_alias :setItem, :item=, removal_in: 'v20'
|
||||
deprecated_method_alias :healStatus, :heal_status, removal_in: 'v20'
|
||||
deprecated_method_alias :knowsMove?, :hasMove?, removal_in: 'v20'
|
||||
deprecated_method_alias :resetMoves, :reset_moves, removal_in: 'v20'
|
||||
deprecated_method_alias :pbLearnMove, :learn_move, removal_in: 'v20'
|
||||
deprecated_method_alias :pbDeleteMove, :forget_move, removal_in: 'v20'
|
||||
deprecated_method_alias :pbDeleteMoveAtIndex, :forget_move_at_index, removal_in: 'v20'
|
||||
deprecated_method_alias :pbRecordFirstMoves, :record_first_moves, removal_in: 'v20'
|
||||
deprecated_method_alias :pbAddFirstMove, :add_first_move, removal_in: 'v20'
|
||||
deprecated_method_alias :pbRemoveFirstMove, :remove_first_move, removal_in: 'v20'
|
||||
deprecated_method_alias :pbClearFirstMoves, :clear_first_moves, removal_in: 'v20'
|
||||
deprecated_method_alias :pbUpdateShadowMoves, :update_shadow_moves, removal_in: 'v20'
|
||||
deprecated_method_alias :isForeign?, :foreign?, removal_in: 'v20'
|
||||
deprecated_method_alias :calcStats, :calc_stats, removal_in: 'v20'
|
||||
end
|
||||
|
||||
# (see Pokemon#initialize)
|
||||
# @deprecated Use +Pokemon.new+ instead. This method and its aliases are
|
||||
# slated to be removed in v20.
|
||||
def pbNewPkmn(species, level, owner = $Trainer, withMoves = true)
|
||||
Deprecation.warn_method('pbNewPkmn', 'v20', 'Pokemon.new')
|
||||
return Pokemon.new(species, level, owner, withMoves)
|
||||
end
|
||||
alias pbGenPkmn pbNewPkmn
|
||||
alias pbGenPoke pbNewPkmn
|
||||
Reference in New Issue
Block a user