Misc tidying

This commit is contained in:
Maruno17
2021-01-31 19:13:51 +00:00
parent f68cc1c98b
commit 168a1e5df7
19 changed files with 520 additions and 585 deletions

View File

@@ -53,26 +53,26 @@ module GameData
def self.editor_properties def self.editor_properties
return [ return [
["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")], ["Outdoor", BooleanProperty, _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")], ["ShowArea", BooleanProperty, _INTL("If true, the game will display the map's name upon entry.")],
["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")], ["Bicycle", BooleanProperty, _INTL("If true, the bicycle can be used on this map.")],
["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")], ["BicycleAlways", BooleanProperty, _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")], ["HealingSpot", MapCoordsProperty, _INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")],
["Weather", WeatherEffectProperty, _INTL("Weather conditions in effect for this map.")], ["Weather", WeatherEffectProperty, _INTL("Weather conditions in effect for this map.")],
["MapPosition", RegionMapCoordsProperty, _INTL("Identifies the point on the regional map for this map.")], ["MapPosition", RegionMapCoordsProperty, _INTL("Identifies the point on the regional map for this map.")],
["DiveMap", MapProperty, _INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")], ["DiveMap", MapProperty, _INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")],
["DarkMap", BooleanProperty, _INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")], ["DarkMap", BooleanProperty, _INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")],
["SafariMap", BooleanProperty, _INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")], ["SafariMap", BooleanProperty, _INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")],
["SnapEdges", BooleanProperty, _INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")], ["SnapEdges", BooleanProperty, _INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")],
["Dungeon", BooleanProperty, _INTL("If true, this map has a randomly generated layout. See the wiki for more information.")], ["Dungeon", BooleanProperty, _INTL("If true, this map has a randomly generated layout. See the wiki for more information.")],
["BattleBack", StringProperty, _INTL("PNG files named 'XXX_bg', 'XXX_base0', 'XXX_base1', 'XXX_message' in Battlebacks folder, where XXX is this property's value.")], ["BattleBack", StringProperty, _INTL("PNG files named 'XXX_bg', 'XXX_base0', 'XXX_base1', 'XXX_message' in Battlebacks folder, where XXX is this property's value.")],
["WildBattleBGM", BGMProperty, _INTL("Default BGM for wild Pokémon battles on this map.")], ["WildBattleBGM", BGMProperty, _INTL("Default BGM for wild Pokémon battles on this map.")],
["TrainerBattleBGM", BGMProperty, _INTL("Default BGM for trainer battles on this map.")], ["TrainerBattleBGM", BGMProperty, _INTL("Default BGM for trainer battles on this map.")],
["WildVictoryME", MEProperty, _INTL("Default ME played after winning a wild Pokémon battle on this map.")], ["WildVictoryME", MEProperty, _INTL("Default ME played after winning a wild Pokémon battle on this map.")],
["TrainerVictoryME", MEProperty, _INTL("Default ME played after winning a Trainer battle on this map.")], ["TrainerVictoryME", MEProperty, _INTL("Default ME played after winning a Trainer battle on this map.")],
["WildCaptureME", MEProperty, _INTL("Default ME played after catching a wild Pokémon on this map.")], ["WildCaptureME", MEProperty, _INTL("Default ME played after catching a wild Pokémon on this map.")],
["MapSize", MapSizeProperty, _INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")], ["MapSize", MapSizeProperty, _INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")],
["Environment", EnvironmentProperty, _INTL("The default battle environment for battles on this map.")] ["Environment", EnumProperty2.new(PBEnvironment), _INTL("The default battle environment for battles on this map.")]
] ]
end end

View File

@@ -0,0 +1,83 @@
module PBTypeEffectiveness
INEFFECTIVE = 0
NOT_EFFECTIVE_ONE = 1
NORMAL_EFFECTIVE_ONE = 2
SUPER_EFFECTIVE_ONE = 4
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3
def self.ineffective?(value)
return value == INEFFECTIVE
end
def self.notVeryEffective?(value)
return value > INEFFECTIVE && value < NORMAL_EFFECTIVE
end
def self.resistant?(value)
return value < NORMAL_EFFECTIVE
end
def self.normalEffective?(value)
return value == NORMAL_EFFECTIVE
end
def self.superEffective?(value)
return value > NORMAL_EFFECTIVE
end
end
module PBTypes
def self.regularTypesCount
ret = 0
GameData::Type.each { |t| ret += 1 if !t.pseudo_type && t.id != :SHADOW }
return ret
end
def self.isPhysicalType?(type); return GameData::Type.get(type).physical?; end
def self.isSpecialType?(type); return GameData::Type.get(type).special?; end
def self.isPseudoType?(type); return GameData::Type.get(type).pseudo_type; end
def self.getEffectiveness(attack_type, target_type)
return GameData::Type.get(target_type).effectiveness(attack_type)
end
def self.getCombinedEffectiveness(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
mod1 = self.getEffectiveness(attack_type, target_type1)
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
mod3 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if target_type2 && target_type1 != target_type2
mod2 = self.getEffectiveness(attack_type, target_type2)
end
if target_type3 && target_type1 != target_type3 && target_type2 != target_type3
mod3 = self.getEffectiveness(attack_type, target_type3)
end
return mod1 * mod2 * mod3
end
def self.ineffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.ineffective?(value)
end
def self.notVeryEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.notVeryEffective?(value)
end
def self.resistant?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.resistant?(value)
end
def self.normalEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.normalEffective?(value)
end
def self.superEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = self.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.superEffective?(value)
end
end

View File

@@ -1,83 +0,0 @@
module PBTypeEffectiveness
INEFFECTIVE = 0
NOT_EFFECTIVE_ONE = 1
NORMAL_EFFECTIVE_ONE = 2
SUPER_EFFECTIVE_ONE = 4
NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3
def self.ineffective?(value)
return value == INEFFECTIVE
end
def self.notVeryEffective?(value)
return value > INEFFECTIVE && value < NORMAL_EFFECTIVE
end
def self.resistant?(value)
return value < NORMAL_EFFECTIVE
end
def self.normalEffective?(value)
return value == NORMAL_EFFECTIVE
end
def self.superEffective?(value)
return value > NORMAL_EFFECTIVE
end
end
class PBTypes
def PBTypes.regularTypesCount
ret = 0
GameData::Type.each { |t| ret += 1 if !t.pseudo_type && t.id != :SHADOW }
return ret
end
def PBTypes.isPhysicalType?(type); return GameData::Type.get(type).physical?; end
def PBTypes.isSpecialType?(type); return GameData::Type.get(type).special?; end
def PBTypes.isPseudoType?(type); return GameData::Type.get(type).pseudo_type; end
def PBTypes.getEffectiveness(attack_type, target_type)
return GameData::Type.get(target_type).effectiveness(attack_type)
end
def PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
mod1 = PBTypes.getEffectiveness(attack_type, target_type1)
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
mod3 = PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if target_type2 && target_type1 != target_type2
mod2 = PBTypes.getEffectiveness(attack_type, target_type2)
end
if target_type3 && target_type1 != target_type3 && target_type2 != target_type3
mod3 = PBTypes.getEffectiveness(attack_type, target_type3)
end
return mod1 * mod2 * mod3
end
def PBTypes.ineffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.ineffective?(value)
end
def PBTypes.notVeryEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.notVeryEffective?(value)
end
def PBTypes.resistant?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.resistant?(value)
end
def PBTypes.normalEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.normalEffective?(value)
end
def PBTypes.superEffective?(attack_type, target_type1, target_type2 = nil, target_type3 = nil)
value = PBTypes.getCombinedEffectiveness(attack_type, target_type1, target_type2, target_type3)
return PBTypeEffectiveness.superEffective?(value)
end
end

View File

@@ -26,10 +26,9 @@ module PBNatures
QUIRKY = 24 QUIRKY = 24
def self.maxValue; 24; end def self.maxValue; 24; end
def self.getCount; 25; end
def self.getName(id) def self.getName(id)
id = getID(PBNatures,id) id = getID(PBNatures, id)
names = [ names = [
_INTL("Hardy"), _INTL("Hardy"),
_INTL("Lonely"), _INTL("Lonely"),
@@ -61,15 +60,17 @@ module PBNatures
end end
def self.getStatRaised(id) def self.getStatRaised(id)
m = (id%25)/5 # 25 here is (number of stats)**2, not PBNatures.getCount stats = [PBStats::ATTACK, PBStats::DEFENSE, PBStats::SPEED,
return [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED, PBStats::SPATK, PBStats::SPDEF]
PBStats::SPATK,PBStats::SPDEF][m] m = (id % (stats.length ** 2)) / stats.length
return stats[m]
end end
def self.getStatLowered(id) def self.getStatLowered(id)
m = id%5 # Don't need to %25 here because 25 is a multiple of 5 stats = [PBStats::ATTACK, PBStats::DEFENSE, PBStats::SPEED,
return [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED, PBStats::SPATK, PBStats::SPDEF]
PBStats::SPATK,PBStats::SPDEF][m] m = id % stats.length
return stats[m]
end end
def self.getStatChanges(id) def self.getStatChanges(id)

View File

@@ -8,6 +8,8 @@ module PBGenderRates
FemaleSevenEighths = 6 FemaleSevenEighths = 6
AlwaysFemale = 7 AlwaysFemale = 7
def self.maxValue; return 7; end
def self.genderByte(gender) def self.genderByte(gender)
case gender case gender
when AlwaysMale then return 0 when AlwaysMale then return 0

View File

@@ -16,27 +16,4 @@ module PBEggGroups
Dragon = 14 Dragon = 14
def self.maxValue; 14; end def self.maxValue; 14; end
def self.getCount; 15; end
def self.getName(id)
id = getID(PBEggGroups,id)
names = [
_INTL("Undiscovered"),
_INTL("Monster"),
_INTL("Water 1"),
_INTL("Bug"),
_INTL("Flying"),
_INTL("Field"),
_INTL("Fairy"),
_INTL("Grass"),
_INTL("Human-like"),
_INTL("Water 3"),
_INTL("Mineral"),
_INTL("Amorphous"),
_INTL("Water 2"),
_INTL("Ditto"),
_INTL("Dragon")
]
return names[id]
end
end end

View File

@@ -11,8 +11,7 @@ module PBColors
White = 8 White = 8
Pink = 9 Pink = 9
def self.maxValue; 9; end def self.maxValue; 9; end
def self.getCount; 10; end
def self.getName(id) def self.getName(id)
id = getID(PBColors,id) id = getID(PBColors,id)

View File

@@ -10,8 +10,7 @@ module PBHabitats
Urban = 8 Urban = 8
Rare = 9 Rare = 9
def self.maxValue; 9; end def self.maxValue; 9; end
def self.getCount; 10; end
def self.getName(id) def self.getName(id)
id = getID(PBHabitats,id) id = getID(PBHabitats,id)

View File

@@ -81,7 +81,6 @@ module PBRibbons
WORLDCHAMPION = 80 WORLDCHAMPION = 80
def self.maxValue; 80; end def self.maxValue; 80; end
def self.getCount; 80; end
def self.getName(id) def self.getName(id)
id = getID(PBRibbons,id) id = getID(PBRibbons,id)

View File

@@ -1,139 +1,139 @@
#===============================================================================
# This class is designed to favor different values more than a uniform # This class is designed to favor different values more than a uniform
# random generator does # random generator does
#===============================================================================
class AntiRandom class AntiRandom
def initialize(size) def initialize(size)
@old=[] @old = []
@new=[] @new = []
for i in 0...size @new = Array.new(size) { |i| i }
@new[i]=i
end
end end
def get def get
if @new.length==0 if @new.length == 0 # No new values
# No new values @new = @old.clone
@new=@old.clone
@old.clear @old.clear
end end
if @old.length>0 && rand(7)==0 if @old.length > 0 && rand(7) == 0 # Get old value
# Get old value return @old[rand(@old.length)]
value=rand(@old.length)
return @old[value]
end end
if @new.length>0 if @new.length > 0 # Get new value
# Get new value ret = @new.delete_at(rand(@new.length))
value=rand(@new.length)
ret=@new.delete_at(value)
@old.push(ret) @old.push(ret)
return ret return ret
end end
# Get old value return @old[rand(@old.length)] # Get old value
value=rand(@old.length)
return @old[value]
end end
end end
class DungeonMaze #===============================================================================
#
#===============================================================================
module DungeonMaze
TILE_WIDTH = 13 TILE_WIDTH = 13
TILE_HEIGHT = 13 TILE_HEIGHT = 13
MINWIDTH = 5
MINHEIGHT = 4
MAXWIDTH = 11
MAXHEIGHT = 10
None = 0
TurnLeft = 1
TurnRight = 2
Turn180 = 3
def self.paintRect(tile,x,y,w,h) # paints a room def self.paintRect(tile, x, y, width, height) # paints a room
for j in 0...h for j in 0...height
for i in 0...w for i in 0...width
tile[(j+y)*TILE_WIDTH+(i+x)]=3 tile[(y + j) * TILE_WIDTH + (x + i)] = 3
end end
end end
end end
def self.paintTile(dungeon,dstX,dstY,tile,rotation) # paints a tile def self.paintTile(dungeon, dstX, dstY, tile, rotation) # paints a tile
if rotation==None case rotation
for y in 0...TILE_HEIGHT;for x in 0...TILE_WIDTH when None
dungeon[x+dstX,y+dstY]=tile[y*TILE_WIDTH+x] for y in 0...TILE_HEIGHT
end;end for x in 0...TILE_WIDTH
elsif rotation==TurnLeft dungeon[x + dstX, y + dstY] = tile[y * TILE_WIDTH + x]
for y in 0...TILE_HEIGHT;for x in 0...TILE_WIDTH end
dungeon[y+dstX,TILE_WIDTH-1-x+dstY]=tile[y*TILE_WIDTH+x] end
end;end when TurnLeft
elsif rotation==TurnRight for y in 0...TILE_HEIGHT
for y in 0...TILE_HEIGHT;for x in 0...TILE_WIDTH for x in 0...TILE_WIDTH
dungeon[TILE_HEIGHT-1-y+dstX,x+dstY]=tile[y*TILE_WIDTH+x] dungeon[y + dstX , TILE_WIDTH - 1 - x + dstY] = tile[y * TILE_WIDTH + x]
end;end end
elsif rotation==Turn180 end
for y in 0...TILE_HEIGHT;for x in 0...TILE_WIDTH when TurnRight
dungeon[TILE_WIDTH-1-x+dstX,TILE_HEIGHT-1-y+dstY]=tile[y*TILE_WIDTH+x] for y in 0...TILE_HEIGHT
end;end for x in 0...TILE_WIDTH
dungeon[TILE_HEIGHT - 1 - y + dstX, x + dstY] = tile[y * TILE_WIDTH + x]
end
end
when Turn180
for y in 0...TILE_HEIGHT
for x in 0...TILE_WIDTH
dungeon[TILE_WIDTH - 1 - x + dstX, TILE_HEIGHT - 1 - y + dstY] = tile[y * TILE_WIDTH + x]
end
end
end end
end end
MINWIDTH = 5 def self.paintCell(dungeon, xDst, yDst, tile, rotation)
MINHEIGHT = 4
MAXWIDTH = 11
MAXHEIGHT = 10
None = 0
TurnLeft = 1
TurnRight = 2
Turn180 = 3
def self.paintCell(dungeon,xDst,yDst,tile,rotation)
return false if !tile return false if !tile
paintTile(dungeon,xDst,yDst,tile,rotation) paintTile(dungeon, xDst, yDst, tile, rotation)
if rand(10)<7 return false if rand(100) < 30
# Generate a randomly placed room # Generate a randomly placed room
width=MINWIDTH+rand(MAXWIDTH-MINWIDTH+1) width = rand(MINWIDTH, MAXWIDTH)
height=MINHEIGHT+rand(MAXHEIGHT-MINHEIGHT+1) height = rand(MINHEIGHT, MAXHEIGHT)
return false if width<=0 || height<=0 return false if width <= 0 || height <= 0
centerX=TILE_WIDTH/2 centerX = TILE_WIDTH / 2 + rand(5) - 2
centerY=TILE_HEIGHT/2 centerY = TILE_HEIGHT / 2 + rand(5) - 2
centerX=(rand(2)==0) ? centerX-rand(3) : centerX+rand(3) x = centerX - (width / 2)
centerY=(rand(2)==0) ? centerY-rand(3) : centerY+rand(3) y = centerY - (height / 2)
x=centerX-(width/2) rect = [x, y, width, height]
y=centerY-(height/2) rect[0] = 1 if rect[0] < 1
rect=[x,y,width,height] rect[1] = 2 if rect[1] < 2
rect[0]=1 if rect[0]<1 rect[0] = TILE_WIDTH - 1 - width if rect[0] + width > TILE_WIDTH - 1
rect[1]=2 if rect[1]<2 rect[1] = TILE_HEIGHT - 1 - height if rect[0] + height > TILE_HEIGHT - 1
rect[0]=TILE_WIDTH-1-width if rect[0]+width>TILE_WIDTH-1 dungeon.paint(rect, xDst, yDst)
rect[1]=TILE_HEIGHT-1-height if rect[0]+height>TILE_HEIGHT-1 return true
dungeon.paint(rect,xDst,yDst)
return true
end
return false
end end
def self.generateTiles def self.generateTiles
tiles=[] tiles = []
for i in 0...6 for i in 0...6
tiles[i]=[] tiles[i] = []
for j in 0...TILE_WIDTH*TILE_HEIGHT for j in 0...TILE_WIDTH * TILE_HEIGHT
tiles[i][j]=0 tiles[i][j] = 0
end end
end end
paintRect(tiles[0],5,0,3,10) # N paintRect(tiles[0], 5, 0, 3, 10) # N
paintRect(tiles[1],5,0,3,8) # N E paintRect(tiles[1], 5, 0, 3, 8) # N E
paintRect(tiles[1],5,5,8,3) paintRect(tiles[1], 5, 5, 8, 3)
paintRect(tiles[2],5,0,3,8) # N W E paintRect(tiles[2], 5, 0, 3, 8) # N W E
paintRect(tiles[2],0,5,13,3) paintRect(tiles[2], 0, 5, 13, 3)
paintRect(tiles[3],5,0,3,13) # N S paintRect(tiles[3], 5, 0, 3, 13) # N S
paintRect(tiles[4],5,0,3,13) paintRect(tiles[4], 5, 0, 3, 13)
paintRect(tiles[4],0,5,13,3) paintRect(tiles[4], 0, 5, 13, 3)
realtiles=[ realtiles = [
[tiles[4],None], # N W E S [tiles[4], None], # N W E S
[tiles[2],Turn180], # W E S [tiles[2], Turn180], # W E S
[tiles[2],TurnRight], # N E S [tiles[2], TurnRight], # N E S
[tiles[1],TurnRight], # E S [tiles[1], TurnRight], # E S
[tiles[2],TurnLeft], # N W S [tiles[2], TurnLeft], # N W S
[tiles[1],Turn180], # W S [tiles[1], Turn180], # W S
[tiles[3],None], # N S [tiles[3], None], # N S
[tiles[0],Turn180], # S [tiles[0], Turn180], # S
[tiles[2],None], # N W E [tiles[2], None], # N W E
[tiles[3],TurnLeft], # W E [tiles[3], TurnLeft], # W E
[tiles[1],None], # N E [tiles[1], None], # N E
[tiles[0],TurnRight], # E [tiles[0], TurnRight], # E
[tiles[1],TurnLeft], # N W [tiles[1], TurnLeft], # N W
[tiles[0],TurnLeft], # W [tiles[0], TurnLeft], # W
[tiles[0],None], # N [tiles[0], None], # N
[nil,None] [nil, None]
] ]
return realtiles return realtiles
end end
@@ -142,198 +142,226 @@ end
module EdgeMasks module EdgeMasks
North=1;West=2;East=4;South=8;Visited=16 North = 1
West = 2
East = 4
South = 8
Visited = 16
end end
class MazeNode class MazeNode
def initialize def initialize
@edges=0 @edges = 0
end end
def setEdge(e); @edges|=e; end def setEdge(e); @edges |= e; end
def clearEdge(e); @edges&=~e; end def clearEdge(e); @edges &= ~e; end
def clear; @edges=0; end def clear; @edges = 0; end
def set; @edges=15; end def set; @edges = 15; end
def getEdge(e); return (@edges&e)!=0; end def getEdge(e); return (@edges & e) != 0; end
def isBlocked?; return @edges!=0; end def isBlocked?; return @edges != 0; end
end end
class NodeListElement class NodeListElement
attr_accessor :x,:y attr_accessor :x, :y
def initialize(x,y) def initialize(x, y)
@x=x;@y=y @x = x
@y = y
end end
end end
class Maze class Maze
attr_accessor :cellWidth,:cellHeight,:nodeWidth,:nodeHeight attr_accessor :cellWidth, :cellHeight, :nodeWidth, :nodeHeight
def initialize(cw,ch) @@dirs = [EdgeMasks::North, EdgeMasks::South, EdgeMasks::East, EdgeMasks::West]
@nodes=[]
@cells=[] def initialize(cw, ch)
raise ArgumentError.new if cw==0 || ch==0 @nodes = []
@cellWidth=cw @cells = []
@cellHeight=ch raise ArgumentError.new if cw == 0 || ch == 0
@nodeWidth=cw+1 @cellWidth = cw
@nodeHeight=ch+1 @cellHeight = ch
for i in 0...@nodeWidth*@nodeHeight @nodeWidth = cw + 1
@nodes[i]=MazeNode.new @nodeHeight = ch + 1
for i in 0...@nodeWidth * @nodeHeight
@nodes[i] = MazeNode.new
end end
for i in 0...cw*ch for i in 0...cw * ch
@cells[i]=0 @cells[i] = 0
end end
clearAllEdges() clearAllEdges()
clearAllCells() clearAllCells()
end end
def buildNodeList def buildNodeList
list=[] list = []
for x in 0...nodeWidth for x in 0...nodeWidth
for y in 0...nodeHeight for y in 0...nodeHeight
list.push(NodeListElement.new(x,y)) list.push(NodeListElement.new(x, y))
end end
end end
list.shuffle! list.shuffle!
return list return list
end end
def setEdgeNode(x,y,edge) def setEdgeNode(x, y, edge)
return if x<0||x>=nodeWidth||y<0||y>=nodeHeight return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y*nodeWidth+x].setEdge(edge) @nodes[y * nodeWidth + x].setEdge(edge)
e=0;nx=0;ny=0 e = 0
if edge==EdgeMasks::North nx = 0
e=EdgeMasks::South;nx=x;ny=y-1 ny = 0
elsif edge==EdgeMasks::South case edge
e=EdgeMasks::North;nx=x;ny=y+1 when EdgeMasks::North
elsif edge==EdgeMasks::East e = EdgeMasks::South
e=EdgeMasks::West;nx=x+1;ny=y nx = x
elsif edge==EdgeMasks::West ny = y - 1
e=EdgeMasks::East;nx=x-1;ny=y when EdgeMasks::South
e = EdgeMasks::North
nx = x
ny = y + 1
when EdgeMasks::East
e = EdgeMasks::West
nx = x + 1
ny = y
when EdgeMasks::West
e = EdgeMasks::East
nx = x - 1
ny = y
else else
return return
end end
return if nx<0||ny<0||nx>=nodeWidth||ny>=nodeHeight return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny*nodeWidth+nx].setEdge(e) @nodes[ny * nodeWidth + nx].setEdge(e)
end end
def clearEdgeNode(x,y,edge) def clearEdgeNode(x, y, edge)
return if x<0||x>=nodeWidth||y<0||y>=nodeHeight return if x < 0 || x >= nodeWidth || y < 0 || y >= nodeHeight
@nodes[y*nodeWidth+x].clearEdge(edge) @nodes[y * nodeWidth + x].clearEdge(edge)
e=0;nx=0;ny=0 e = 0
if edge==EdgeMasks::North nx = 0
e=EdgeMasks::South;nx=x;ny=y-1 ny = 0
elsif edge==EdgeMasks::South case edge
e=EdgeMasks::North;nx=x;ny=y+1 when EdgeMasks::North
elsif edge==EdgeMasks::East e = EdgeMasks::South
e=EdgeMasks::West;nx=x+1;ny=y nx = x
elsif edge==EdgeMasks::West ny = y - 1
e=EdgeMasks::East;nx=x-1;ny=y when EdgeMasks::South
e = EdgeMasks::North
nx = x
ny = y + 1
when EdgeMasks::East
e = EdgeMasks::West
nx = x + 1
ny = y
when EdgeMasks::West
e = EdgeMasks::East
nx = x - 1
ny = y
else else
raise ArgumentError.new raise ArgumentError.new
end end
return if nx<0||ny<0||nx>=nodeWidth||ny>=nodeHeight return if nx < 0 || ny < 0 || nx >= nodeWidth || ny >= nodeHeight
@nodes[ny*nodeWidth+nx].clearEdge(e) @nodes[ny * nodeWidth + nx].clearEdge(e)
end end
def isBlockedNode?(x,y) def isBlockedNode?(x, y)
return false if x<0||y<0||x>=nodeWidth||y>=nodeHeight return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight
return @nodes[y*nodeWidth+x].isBlocked? return @nodes[y * nodeWidth + x].isBlocked?
end end
def getEdgeNode(x,y,edge) def getEdgeNode(x, y, edge)
return false if x<0||y<0||x>=nodeWidth||y>=nodeHeight return false if x < 0 || y < 0 || x >= nodeWidth || y >= nodeHeight
return @nodes[y*nodeWidth+x].getEdge(edge) return @nodes[y * nodeWidth + x].getEdge(edge)
end end
def getEdgePattern(x,y) def getEdgePattern(x, y)
pattern=0 pattern = 0
pattern|=EdgeMasks::North if getEdgeNode(x,y,EdgeMasks::North) pattern |= EdgeMasks::North if getEdgeNode(x, y, EdgeMasks::North)
pattern|=EdgeMasks::South if getEdgeNode(x,y,EdgeMasks::South) pattern |= EdgeMasks::South if getEdgeNode(x, y, EdgeMasks::South)
pattern|=EdgeMasks::East if getEdgeNode(x,y,EdgeMasks::East) pattern |= EdgeMasks::East if getEdgeNode(x, y, EdgeMasks::East)
pattern|=EdgeMasks::West if getEdgeNode(x,y,EdgeMasks::West) pattern |= EdgeMasks::West if getEdgeNode(x, y, EdgeMasks::West)
return pattern return pattern
end end
def setAllEdges def setAllEdges
for c in 0...nodeWidth*nodeHeight for c in 0...nodeWidth * nodeHeight
@nodes[c].set @nodes[c].set
end end
end end
def clearAllEdges def clearAllEdges
for c in 0...nodeWidth*nodeHeight for c in 0...nodeWidth * nodeHeight
@nodes[c].clear @nodes[c].clear
end end
end end
def clearAllCells def clearAllCells
for c in 0...cellWidth*cellHeight for c in 0...cellWidth * cellHeight
@cells[c]=0 @cells[c] = 0
end end
end end
def setVisited(x,y) def setVisited(x, y)
return if x<0||y<0||x>=cellWidth||x>=cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y*cellWidth+x]|=EdgeMasks::Visited @cells[y * cellWidth + x] |= EdgeMasks::Visited
end end
def getVisited(x,y) def getVisited(x, y)
return false if x<0||y<0||x>=cellWidth||x>=cellHeight return false if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
return (@cells[y*cellWidth+x]&EdgeMasks::Visited)!=0 return (@cells[y * cellWidth + x] & EdgeMasks::Visited) != 0
end end
def clearVisited(x,y) def clearVisited(x, y)
return if x<0||y<0||x>=cellWidth||x>=cellHeight return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight
@cells[y*cellWidth+x]&=~EdgeMasks::Visited @cells[y * cellWidth + x] &=~EdgeMasks::Visited
end end
@@dirs=[EdgeMasks::North,EdgeMasks::South,
EdgeMasks::East,EdgeMasks::West]
def randomDir def randomDir
return @@dirs[rand(4)] return @@dirs[rand(4)]
end end
def buildMazeWall(x,y,dir,len) def buildMazeWall(x, y, dir, len)
wx=x;wy=y return if isBlockedNode?(x, y)
return if isBlockedNode?(x,y) wx = x
wy = y
len.times do len.times do
ox=wx;oy=wy ox = wx
wy-=1 if dir==EdgeMasks::North oy = wy
wx-=1 if dir==EdgeMasks::West wy -= 1 if dir == EdgeMasks::North
wx+=1 if dir==EdgeMasks::East wx -= 1 if dir == EdgeMasks::West
wy+=1 if dir==EdgeMasks::South wx += 1 if dir == EdgeMasks::East
if isBlockedNode?(wx,wy) wy += 1 if dir == EdgeMasks::South
setEdgeNode(ox,oy,dir); return if isBlockedNode?(wx, wy)
else setEdgeNode(ox, oy, dir)
setEdgeNode(ox,oy,dir) return
end end
setEdgeNode(ox,oy,dir)
end end
end end
def generateWallGrowthMaze(minWall=nil,maxWall=nil) def generateWallGrowthMaze(minWall = nil, maxWall = nil)
minWall=0 if !minWall minWall = 0 if !minWall
maxWall=cellWidth if !maxWall maxWall = cellWidth if !maxWall
nlist=buildNodeList() nlist = buildNodeList()
return if nlist.length==0 return if nlist.length == 0
for c in 0...nlist.length for c in 0...nlist.length
d=randomDir() d = randomDir()
len=rand(minWall+(maxWall-minWall)+1) len = rand(maxWall + 1)
x=nlist[c].x x = nlist[c].x
y=nlist[c].y y = nlist[c].y
buildMazeWall(x,y,d,len) buildMazeWall(x, y, d, len)
end end
end end
def recurseDepthFirst(x, y, depth) def recurseDepthFirst(x, y, depth)
setVisited(x,y) setVisited(x, y)
dirs = @@dirs.shuffle! dirs = @@dirs.shuffle!
for c in 0...4 for c in 0...4
d = dirs[c] d = dirs[c]
@@ -363,194 +391,194 @@ class Maze
end end
def generateDepthFirstMaze def generateDepthFirstMaze
sx=rand(cellWidth) sx = rand(cellWidth)
sy=rand(cellHeight) sy = rand(cellHeight)
setAllEdges() setAllEdges()
recurseDepthFirst(sx,sy,0) recurseDepthFirst(sx, sy, 0)
end end
end end
class Dungeon class Dungeon
attr_accessor :width,:height attr_accessor :width, :height
XBUFFER = 7 XBUFFER = 8
YBUFFER = 5 YBUFFER = 6
class DungeonTable class DungeonTable
def initialize(dungeon) def initialize(dungeon)
@dungeon=dungeon @dungeon = dungeon
end end
def xsize; @dungeon.width; end def xsize; @dungeon.width; end
def ysize; @dungeon.height; end def ysize; @dungeon.height; end
def [](x,y) def [](x, y)
[1,2,3,2][@dungeon[x,y]] [1, 2, 3, 2][@dungeon[x, y]] # Void, room floor, wall, corridor floor
end end
end end
def initialize(width,height) def initialize(width, height)
@width=width @width = width
@height=height @height = height
@array=[] @array = []
end end
def clear def clear
for i in 0...width*height for i in 0...width * height
@array[i]=0 @array[i] = 0
end end
end end
def write def write
ret="" ret = ""
i=0 i = 0
for y in 0...@height for y in 0...@height
for x in 0...@width for x in 0...@width
ret+=[" ",".","~"][value(x,y)] ret += [" ", ".", "~", ","][value(x, y)] # Void, room floor, wall, corridor floor
i+=1 i += 1
end end
ret+="\r\n" ret += "\r\n"
end end
return ret return ret
end end
def [](x,y) def [](x, y)
@array[y*@width+x] @array[y * @width + x]
end end
def []=(x,y,value) def []=(x, y, value)
@array[y*@width+x]=value @array[y * @width + x] = value
end end
def value(x,y) def value(x, y)
return 0 if x<0||y<0||x>=@width||y>=@height return 0 if x < 0 || y < 0 || x >= @width || y >= @height
@array[y*@width+x] @array[y * @width + x]
end end
def get(x,y) def get(x, y)
return false if x<0||y<0||x>=@width||y>=@height return false if x < 0 || y < 0 || x >= @width || y >= @height
@array[y*@width+x]!=0 @array[y * @width + x] != 0
end end
def isWall?(x,y) def isWall?(x, y)
if value(x,y)==0 if value(x, y) == 0 # This tile is void
v1=value(x,y+1) v1 = value(x, y + 1)
return true if (v1==1||v1==3) return true if v1 == 1 || v1 == 3 # The tile below is room floor/corridor floor
if v1==0 if v1 == 0 # The tile below is void
v1=value(x,y+2) v1 = value(x, y + 2)
return true if (v1==1||v1==3) return true if v1 == 1 || v1 == 3 # The tile below that is room floor/corridor floor
end end
end end
return false return false
end end
def isRoom?(x,y) def isRoom?(x, y)
if value(x,y)==1 if value(x, y) == 1 # This tile is a room floor
return false if value(x-1,y-1)==3 return false if value(x - 1, y - 1) == 3
return false if value(x,y-1)==3 return false if value( x, y - 1) == 3
return false if value(x+1,y-1)==3 return false if value(x + 1, y - 1) == 3
return false if value(x-1,y)==3 return false if value(x - 1, y) == 3
return false if value(x+1,y)==3 return false if value(x + 1, y) == 3
return false if value(x-1,y+1)==3 return false if value(x - 1, y + 1) == 3
return false if value(x,y+1)==3 return false if value( x, y + 1) == 3
return false if value(x+1,y+1)==3 return false if value(x + 1, y + 1) == 3
return true return true # No surrounding tiles are corridor floor
end end
return false return false
end end
def generate def generate
self.clear self.clear
maxWidth=@width-(XBUFFER*2) maxWidth = @width - XBUFFER * 2
maxHeight=@height-(YBUFFER*2) maxHeight = @height - YBUFFER * 2
cellWidth=DungeonMaze::TILE_WIDTH cellWidth = DungeonMaze::TILE_WIDTH
cellHeight=DungeonMaze::TILE_HEIGHT cellHeight = DungeonMaze::TILE_HEIGHT
return if maxWidth<0 || maxHeight<0 return if maxWidth < 0 || maxHeight < 0
if maxWidth<cellWidth || maxHeight<cellHeight if maxWidth < cellWidth || maxHeight < cellHeight # Map is too small
for x in 0...maxWidth for x in 0...maxWidth
for y in 0...maxHeight for y in 0...maxHeight
self[x+XBUFFER,y+YBUFFER]=1 self[x + XBUFFER, y + YBUFFER] = 1 # Make all tiles room floor
end end
end end
return return
end end
maze=Maze.new(maxWidth/cellWidth,maxHeight/cellHeight) maze = Maze.new(maxWidth / cellWidth, maxHeight / cellHeight)
maze.generateDepthFirstMaze() maze.generateDepthFirstMaze()
tiles=DungeonMaze.generateTiles() tiles = DungeonMaze.generateTiles()
roomcount=0 roomcount = 0
for y in 0...maxHeight/cellHeight for y in 0...maxHeight / cellHeight
for x in 0...maxWidth/cellWidth for x in 0...maxWidth / cellWidth
tile=maze.getEdgePattern(x,y) tile = maze.getEdgePattern(x, y)
if DungeonMaze.paintCell(self,XBUFFER+x*cellWidth, if DungeonMaze.paintCell(self, XBUFFER + x * cellWidth, YBUFFER + y * cellHeight,
YBUFFER+y*cellHeight,tiles[tile][0],tiles[tile][1]) tiles[tile][0], tiles[tile][1])
roomcount+=1 roomcount += 1
end end
end end
end end
if roomcount==0 if roomcount == 0
# Handle situation where no rooms were generated # Handle situation where no rooms were generated
for x in 0...maxWidth for x in 0...maxWidth
for y in 0...maxHeight for y in 0...maxHeight
self[x+XBUFFER,y+YBUFFER]=1 self[x + XBUFFER, y + YBUFFER] = 1 # Make all tiles room floor
end end
end end
end end
# Generate walls # Generate walls
for y in 0...@height for y in 0...@height
for x in 0...@width for x in 0...@width
if isWall?(x,y) self[x, y] = 2 if isWall?(x, y) # Make appropriate tiles wall tiles
self[x,y]=2
end
end end
end end
end end
def generateMapInPlace(map) def generateMapInPlace(map)
tbl=DungeonTable.new(self) tbl = DungeonTable.new(self)
for i in 0...map.width for i in 0...map.width
for j in 0...map.height for j in 0...map.height
nb=TileDrawingHelper.tableNeighbors(tbl,i,j) nb = TileDrawingHelper.tableNeighbors(tbl, i, j)
tile=TileDrawingHelper::NeighborsToTiles[nb] tile = TileDrawingHelper::NeighborsToTiles[nb]
map.data[i,j,0]=tile+48*(tbl[i,j]) map.data[i, j, 0] = tile + 48 * (tbl[i, j])
map.data[i,j,1]=0 map.data[i, j, 1] = 0
map.data[i,j,2]=0 map.data[i, j, 2] = 0
end end
end end
end end
def paint(rect,offsetX,offsetY) def paint(rect,offsetX,offsetY)
for y in (rect[1]+offsetY...rect[1]+offsetY+rect[3]) for y in (rect[1] + offsetY)...(rect[1] + offsetY + rect[3])
for x in (rect[0]+offsetX...rect[0]+offsetX+rect[2]) for x in (rect[0] + offsetX)...(rect[0] + offsetX + rect[2])
self[x,y]=1 # room tile self[x, y] = 1 # room tile
end end
end end
end end
def intersects?(r1,r2) def intersects?(r1, r2)
return !((( r2[0] + r2[2] <= r1[0] ) || return !(((r2[0] + r2[2] <= r1[0]) ||
( r2[0] >= r1[0] + r1[2] ) || (r2[0] >= r1[0] + r1[2]) ||
( r2[1] + r2[3] <= r1[1] ) || (r2[1] + r2[3] <= r1[1]) ||
( r2[1] >= r1[1] + r1[3] ) ) && (r2[1] >= r1[1] + r1[3])) &&
(( r1[0] <= r2[0] + r2[2] )|| ((r1[0] <= r2[0] + r2[2])||
( r1[0] >= r2[0] + r2[2] ) || (r1[0] >= r2[0] + r2[2]) ||
( r1[1] + r1[3] <= r2[1] ) || (r1[1] + r1[3] <= r2[1]) ||
( r1[1] >= r2[1] + r2[3] )) (r1[1] >= r2[1] + r2[3]))
); );
end end
end end
def pbRandomRoomTile(dungeon,tiles) # Get a random room tile that isn't too close to a corridor (to avoid blocking
ar1=AntiRandom.new(dungeon.width) # a room's entrance)
ar2=AntiRandom.new(dungeon.height) def pbRandomRoomTile(dungeon, tiles)
((tiles.length+1)*1000).times do ar1 = AntiRandom.new(dungeon.width)
x=ar1.get() ar2 = AntiRandom.new(dungeon.height)
y=ar2.get() ((tiles.length + 1) * 1000).times do
if dungeon.isRoom?(x,y) && x = ar1.get()
!tiles.any? { |item| (item[0]-x).abs<2 && (item[1]-y).abs<2 } y = ar2.get()
ret=[x,y] if dungeon.isRoom?(x, y) &&
!tiles.any? { |item| (item[0] - x).abs < 2 && (item[1] - y).abs < 2 }
ret = [x, y]
tiles.push(ret) tiles.push(ret)
return ret return ret
end end
@@ -560,26 +588,26 @@ end
Events.onMapCreate += proc { |_sender, e| Events.onMapCreate += proc { |_sender, e|
mapID = e[0] mapID = e[0]
map = e[1] map = e[1]
next if !GameData::MapMetadata.exists?(mapID) || next if !GameData::MapMetadata.exists?(mapID) ||
!GameData::MapMetadata.get(mapID).random_dungeon !GameData::MapMetadata.get(mapID).random_dungeon
# this map is a randomly generated dungeon # this map is a randomly generated dungeon
dungeon=Dungeon.new(map.width,map.height) dungeon = Dungeon.new(map.width, map.height)
dungeon.generate dungeon.generate
dungeon.generateMapInPlace(map) dungeon.generateMapInPlace(map)
roomtiles=[] roomtiles = []
# Reposition events # Reposition events
for event in map.events.values for event in map.events.values
tile=pbRandomRoomTile(dungeon,roomtiles) tile = pbRandomRoomTile(dungeon, roomtiles)
if tile if tile
event.x=tile[0] event.x = tile[0]
event.y=tile[1] event.y = tile[1]
end end
end end
# Override transfer X and Y # Override transfer X and Y
tile=pbRandomRoomTile(dungeon,roomtiles) tile = pbRandomRoomTile(dungeon, roomtiles)
if tile if tile
$game_temp.player_new_x=tile[0] $game_temp.player_new_x = tile[0]
$game_temp.player_new_y=tile[1] $game_temp.player_new_y = tile[1]
end end
} }

View File

@@ -196,15 +196,11 @@ class PokemonBag_Scene
@sprites["itemlist"].baseColor = ITEMLISTBASECOLOR @sprites["itemlist"].baseColor = ITEMLISTBASECOLOR
@sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR @sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport) @sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport)
@sprites["itemtext"] = Window_UnformattedTextPokemon.new("") @sprites["itemtext"] = Window_UnformattedTextPokemon.newWithSize("",
@sprites["itemtext"].x = 72 72, 270, Graphics.width - 72 - 24, 128, @viewport)
@sprites["itemtext"].y = 270
@sprites["itemtext"].width = Graphics.width-72-24
@sprites["itemtext"].height = 128
@sprites["itemtext"].baseColor = ITEMTEXTBASECOLOR @sprites["itemtext"].baseColor = ITEMTEXTBASECOLOR
@sprites["itemtext"].shadowColor = ITEMTEXTSHADOWCOLOR @sprites["itemtext"].shadowColor = ITEMTEXTSHADOWCOLOR
@sprites["itemtext"].visible = true @sprites["itemtext"].visible = true
@sprites["itemtext"].viewport = @viewport
@sprites["itemtext"].windowskin = nil @sprites["itemtext"].windowskin = nil
@sprites["helpwindow"] = Window_UnformattedTextPokemon.new("") @sprites["helpwindow"] = Window_UnformattedTextPokemon.new("")
@sprites["helpwindow"].visible = false @sprites["helpwindow"].visible = false

View File

@@ -207,16 +207,11 @@ class PokemonMart_Scene
@sprites["itemwindow"].viewport = @viewport @sprites["itemwindow"].viewport = @viewport
@sprites["itemwindow"].index = 0 @sprites["itemwindow"].index = 0
@sprites["itemwindow"].refresh @sprites["itemwindow"].refresh
@sprites["itemtextwindow"] = Window_UnformattedTextPokemon.new("") @sprites["itemtextwindow"] = Window_UnformattedTextPokemon.newWithSize("",
64, Graphics.height - 96 - 16, Graphics.width - 64, 128, @viewport)
pbPrepareWindow(@sprites["itemtextwindow"]) pbPrepareWindow(@sprites["itemtextwindow"])
@sprites["itemtextwindow"].x = 64
@sprites["itemtextwindow"].y = Graphics.height - 96 - 16
@sprites["itemtextwindow"].width = Graphics.width - 64
@sprites["itemtextwindow"].height = 128
@sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248) @sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248)
@sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0) @sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0)
@sprites["itemtextwindow"].visible = true
@sprites["itemtextwindow"].viewport = @viewport
@sprites["itemtextwindow"].windowskin = nil @sprites["itemtextwindow"].windowskin = nil
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("") @sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["helpwindow"]) pbPrepareWindow(@sprites["helpwindow"])

View File

@@ -637,7 +637,7 @@ PokemonDebugMenuCommands.register("setnature", {
"always_show" => true, "always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
commands = [] commands = []
(PBNatures.getCount).times do |i| (PBNatures.maxValue + 1).times do |i|
statUp = PBNatures.getStatRaised(i) statUp = PBNatures.getStatRaised(i)
statDown = PBNatures.getStatLowered(i) statDown = PBNatures.getStatLowered(i)
if statUp != statDown if statUp != statDown
@@ -654,10 +654,10 @@ PokemonDebugMenuCommands.register("setnature", {
mag = _INTL("Nature is {1}.", PBNatures.getName(pkmn.nature)) mag = _INTL("Nature is {1}.", PBNatures.getName(pkmn.nature))
cmd = screen.pbShowCommands(mag, commands, cmd) cmd = screen.pbShowCommands(mag, commands, cmd)
break if cmd < 0 break if cmd < 0
if cmd >= 0 && cmd < PBNatures.getCount # Set nature if cmd >= 0 && cmd <= PBNatures.maxValue # Set nature
pkmn.nature = cmd pkmn.nature = cmd
pkmn.calcStats pkmn.calcStats
elsif cmd == PBNatures.getCount # Reset elsif cmd == PBNatures.maxValue + 1 # Reset
pkmn.nature = nil pkmn.nature = nil
end end
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)

View File

@@ -284,12 +284,8 @@ def pbDefinePath(canvas)
showline=false showline=false
sliderwin2.visible=false sliderwin2.visible=false
# This window displays the mouse's current position # This window displays the mouse's current position
window=Window_UnformattedTextPokemon.new("") window=Window_UnformattedTextPokemon.newWithSize("",
window.x=0 0, 320 - 64, 128, 64, canvas.viewport)
window.y=320-64
window.width=128
window.height=64
window.viewport=canvas.viewport
loop do loop do
Graphics.update Graphics.update
Input.update Input.update

View File

@@ -667,7 +667,7 @@ module TrainerPokemonProperty
pkmn_properties.concat([ pkmn_properties.concat([
[_INTL("Ability"), LimitProperty2.new(99), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")], [_INTL("Ability"), LimitProperty2.new(99), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")], [_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
[_INTL("Nature"), NatureProperty, _INTL("Nature of the Pokémon.")], [_INTL("Nature"), EnumProperty2.new(PBNatures), _INTL("Nature of the Pokémon.")],
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")], [_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")], [_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")],
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")], [_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
@@ -958,13 +958,8 @@ def pbPokemonEditor
[_INTL("BaseStats"), BaseStatsProperty, _INTL("Base stats of the Pokémon.")], [_INTL("BaseStats"), BaseStatsProperty, _INTL("Base stats of the Pokémon.")],
[_INTL("EffortPoints"), EffortValuesProperty, _INTL("Effort Value points earned when this species is defeated.")], [_INTL("EffortPoints"), EffortValuesProperty, _INTL("Effort Value points earned when this species is defeated.")],
[_INTL("BaseEXP"), LimitProperty.new(9999), _INTL("Base experience earned when this species is defeated.")], [_INTL("BaseEXP"), LimitProperty.new(9999), _INTL("Base experience earned when this species is defeated.")],
[_INTL("GrowthRate"), EnumProperty.new([ [_INTL("GrowthRate"), EnumProperty2.new(PBGrowthRates), _INTL("Pokémon's growth rate.")],
_INTL("Medium"), _INTL("Erratic"), _INTL("Fluctuating"), [_INTL("GenderRate"), EnumProperty2.new(PBGenderRates), _INTL("Proportion of males to females for this species.")],
_INTL("Parabolic"), _INTL("Fast"), _INTL("Slow")]), _INTL("Pokémon's growth rate.")],
[_INTL("GenderRate"), EnumProperty.new([
_INTL("Genderless"), _INTL("AlwaysMale"), _INTL("FemaleOneEighth"),
_INTL("Female25Percent"), _INTL("Female50Percent"), _INTL("Female75Percent"),
_INTL("FemaleSevenEighths"), _INTL("AlwaysFemale")]), _INTL("Proportion of males to females for this species.")],
[_INTL("Rareness"), LimitProperty.new(255), _INTL("Catch rate of this species (0-255).")], [_INTL("Rareness"), LimitProperty.new(255), _INTL("Catch rate of this species (0-255).")],
[_INTL("Happiness"), LimitProperty.new(255), _INTL("Base happiness of this species (0-255).")], [_INTL("Happiness"), LimitProperty.new(255), _INTL("Base happiness of this species (0-255).")],
[_INTL("Moves"), MovePoolProperty, _INTL("Moves which the Pokémon learns while levelling up.")], [_INTL("Moves"), MovePoolProperty, _INTL("Moves which the Pokémon learns while levelling up.")],
@@ -979,28 +974,16 @@ def pbPokemonEditor
[_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")], [_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")],
[_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")], [_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")],
[_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")], [_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")],
[_INTL("Compat1"), EnumProperty.new([ [_INTL("Compat1"), EnumProperty2.new(PBEggGroups), _INTL("Compatibility group (egg group) for breeding purposes.")],
"Undiscovered", "Monster", "Water 1", "Bug", "Flying", [_INTL("Compat2"), EnumProperty2.new(PBEggGroups), _INTL("Compatibility group (egg group) for breeding purposes.")],
"Field", "Fairy", "Grass", "Human-like", "Water 3",
"Mineral", "Amorphous", "Water 2", "Ditto", "Dragon"]), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"), EnumProperty.new([
"Undiscovered", "Monster", "Water 1", "Bug", "Flying",
"Field", "Fairy", "Grass", "Human-like", "Water 3",
"Mineral", "Amorphous", "Water 2", "Ditto", "Dragon"]), _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")], [_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")], [_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")], [_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
[_INTL("Height"), NonzeroLimitProperty.new(999), _INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")], [_INTL("Height"), NonzeroLimitProperty.new(999), _INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
[_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")], [_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"), EnumProperty.new([ [_INTL("Color"), EnumProperty2.new(PBColors), _INTL("Pokémon's body color.")],
_INTL("Red"), _INTL("Blue"), _INTL("Yellow"), _INTL("Green"),
_INTL("Black"), _INTL("Brown"), _INTL("Purple"), _INTL("Gray"),
_INTL("White"), _INTL("Pink")]), _INTL("Pokémon's body color.")],
[_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")], [_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"), EnumProperty.new([ [_INTL("Habitat"), EnumProperty2.new(PBHabitats), _INTL("The habitat of this species.")],
_INTL("None"), _INTL("Grassland"), _INTL("Forest"), _INTL("WatersEdge"),
_INTL("Sea"), _INTL("Cave"), _INTL("Mountain"), _INTL("RoughTerrain"),
_INTL("Urban"), _INTL("Rare")]), _INTL("The habitat of this species.")],
[_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")], [_INTL("Generation"), LimitProperty.new(99999), _INTL("The number of the generation the Pokémon debuted in.")],
[_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")], [_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
[_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")], [_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
@@ -1418,20 +1401,12 @@ def pbAnimationsOrganiser
cmdwin = pbListWindow([]) cmdwin = pbListWindow([])
cmdwin.viewport = viewport cmdwin.viewport = viewport
cmdwin.z = 2 cmdwin.z = 2
title = Window_UnformattedTextPokemon.new(_INTL("Animations Organiser")) title = Window_UnformattedTextPokemon.newWithSize(_INTL("Animations Organiser"),
title.x = Graphics.width/2 Graphics.width / 2, 0, Graphics.width / 2, 64, viewport)
title.y = 0 title.z = 2
title.width = Graphics.width/2 info = Window_AdvancedTextPokemon.newWithSize(_INTL("Z+Up/Down: Swap\nZ+Left: Delete\nZ+Right: Insert"),
title.height = 64 Graphics.width / 2, 64, Graphics.width / 2, Graphics.height - 64, viewport)
title.viewport = viewport info.z = 2
title.z = 2
info = Window_AdvancedTextPokemon.new(_INTL("Z+Up/Down: Swap\nZ+Left: Delete\nZ+Right: Insert"))
info.x = Graphics.width/2
info.y = 64
info.width = Graphics.width/2
info.height = Graphics.height-64
info.viewport = viewport
info.z = 2
commands = [] commands = []
refreshlist = true; oldsel = -1 refreshlist = true; oldsel = -1
cmd = [0,0] cmd = [0,0]

View File

@@ -209,6 +209,32 @@ end
class EnumProperty2
def initialize(value)
@module = value
end
def set(settingname,oldsetting)
commands = []
for i in 0..@module.maxValue
commands.push(getConstantName(@module, i))
end
cmd = pbMessage(_INTL("Choose a value for {1}.", settingname), commands, -1, nil, oldsetting)
return oldsetting if cmd < 0
return cmd
end
def defaultValue
return nil
end
def format(value)
return (value) ? getConstantName(@module, value) : "-"
end
end
module BGMProperty module BGMProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MusicFileLister.new(true,oldsetting)) chosenmap = pbListScreen(settingname,MusicFileLister.new(true,oldsetting))
@@ -393,27 +419,6 @@ end
module NatureProperty
def self.set(_settingname,_oldsetting)
commands = []
(PBNatures.getCount).times do |i|
commands.push(PBNatures.getName(i))
end
ret = pbShowCommands(nil,commands,-1)
return (ret>=0) ? ret : nil
end
def self.defaultValue
return nil
end
def self.format(value)
return (value) ? getConstantName(PBNatures,value) : "-"
end
end
class IVsProperty class IVsProperty
def initialize(limit) def initialize(limit)
@limit = limit @limit = limit
@@ -592,13 +597,9 @@ end
def chooseMapPoint(map,rgnmap=false) def chooseMapPoint(map,rgnmap=false)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height) viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=99999 viewport.z=99999
title=Window_UnformattedTextPokemon.new(_INTL("Click a point on the map.")) title = Window_UnformattedTextPokemon.newWithSize(_INTL("Click a point on the map."),
title.x=0 0, Graphics.height - 64, Graphics.width, 64, viewport)
title.y=Graphics.height-64 title.z = 2
title.width=Graphics.width
title.height=64
title.viewport=viewport
title.z=2
if rgnmap if rgnmap
sprite=RegionMapSprite.new(map,viewport) sprite=RegionMapSprite.new(map,viewport)
else else
@@ -737,23 +738,6 @@ end
module EnvironmentProperty
def self.set(_settingname,_oldsetting)
options = []
for i in 0..PBEnvironment.maxValue
options.push(getConstantName(PBEnvironment,i) || "ERROR")
end
cmd = pbMessage(_INTL("Choose an environment."),options,1)
return cmd
end
def self.format(value)
return (value) ? (getConstantName(PBEnvironment,value) || "ERROR") : "-"
end
end
module MapProperty module MapProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MapLister.new(oldsetting ? oldsetting : 0)) chosenmap = pbListScreen(settingname,MapLister.new(oldsetting ? oldsetting : 0))
@@ -789,14 +773,10 @@ end
module PocketProperty module PocketProperty
def self.pocketnames
return [_INTL("Items"), _INTL("Medicine"), _INTL("Poké Balls"),
_INTL("TMs & HMs"), _INTL("Berries"), _INTL("Mail"),
_INTL("Battle Items"), _INTL("Key Items")]
end
def self.set(_settingname, oldsetting) def self.set(_settingname, oldsetting)
cmd = pbMessage(_INTL("Choose a pocket for this item."), pocketnames(), -1) commands = pbPocketNames.clone
commands.shift
cmd = pbMessage(_INTL("Choose a pocket for this item."), commands, -1)
return (cmd >= 0) ? cmd + 1 : oldsetting return (cmd >= 0) ? cmd + 1 : oldsetting
end end
@@ -806,7 +786,7 @@ module PocketProperty
def self.format(value) def self.format(value)
return _INTL("No Pocket") if value == 0 return _INTL("No Pocket") if value == 0
return (value) ? pocketnames[value - 1] : value.inspect return (value) ? pbPocketNames[value] : value.inspect
end end
end end

View File

@@ -64,7 +64,7 @@ def pbListScreenBlock(title,lister)
list.viewport = viewport list.viewport = viewport
list.z = 2 list.z = 2
title = Window_UnformattedTextPokemon.newWithSize(title, title = Window_UnformattedTextPokemon.newWithSize(title,
Graphics.width / 2, 0, Graphics.width - title.x, 64, viewport) Graphics.width / 2, 0, Graphics.width / 2, 64, viewport)
title.z = 2 title.z = 2
lister.setViewport(viewport) lister.setViewport(viewport)
selectedmap = -1 selectedmap = -1

View File

@@ -81,12 +81,8 @@ class PokemonTilesetScene
@tileset = @tilesetwrapper.data[1] @tileset = @tilesetwrapper.data[1]
@tilehelper = TileDrawingHelper.fromTileset(@tileset) @tilehelper = TileDrawingHelper.fromTileset(@tileset)
@sprites = {} @sprites = {}
@sprites["title"] = Window_UnformattedTextPokemon.new(_INTL("Tileset Editor\r\nPgUp/PgDn: SCROLL\r\nZ: MENU")) @sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Tileset Editor\r\nPgUp/PgDn: SCROLL\r\nZ: MENU"),
@sprites["title"].viewport = @viewport TILESET_WIDTH, 0, Graphics.width - TILESET_WIDTH, 128, @viewport)
@sprites["title"].x = TILESET_WIDTH
@sprites["title"].y = 0
@sprites["title"].width = Graphics.width - TILESET_WIDTH
@sprites["title"].height = 128
@sprites["tileset"] = IconSprite.new(0,0,@viewport) @sprites["tileset"] = IconSprite.new(0,0,@viewport)
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}") @sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
@sprites["tileset"].src_rect = Rect.new(0,0,TILESET_WIDTH,Graphics.height) @sprites["tileset"].src_rect = Rect.new(0,0,TILESET_WIDTH,Graphics.height)

View File

@@ -327,13 +327,9 @@ class MapScreenScene
@selmapid=-1 @selmapid=-1
addBackgroundPlane(@sprites,"background","Trainer Card/bg",@viewport) addBackgroundPlane(@sprites,"background","Trainer Card/bg",@viewport)
@sprites["selsprite"]=SelectionSprite.new(@viewport) @sprites["selsprite"]=SelectionSprite.new(@viewport)
@sprites["title"]=Window_UnformattedTextPokemon.new(_INTL("F: Help")) @sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("F: Help"),
@sprites["title"].x=0 0, 600 - 64, 800, 64, @viewport)
@sprites["title"].y=600-64 @sprites["title"].z = 2
@sprites["title"].width=800
@sprites["title"].height=64
@sprites["title"].viewport=@viewport
@sprites["title"].z=2
@mapinfos=load_data("Data/MapInfos.rxdata") @mapinfos=load_data("Data/MapInfos.rxdata")
conns=MapFactoryHelper.getMapConnections conns=MapFactoryHelper.getMapConnections
@mapconns=[] @mapconns=[]
@@ -362,13 +358,9 @@ class MapScreenScene
helptext+=_INTL("Double-click: Edit map's metadata\r\n") helptext+=_INTL("Double-click: Edit map's metadata\r\n")
helptext+=_INTL("Drag map to move it\r\n") helptext+=_INTL("Drag map to move it\r\n")
helptext+=_INTL("Arrow keys/drag canvas: Move around canvas") helptext+=_INTL("Arrow keys/drag canvas: Move around canvas")
title=Window_UnformattedTextPokemon.new(helptext) title = Window_UnformattedTextPokemon.newWithSize(helptext,
title.x=0 0, 0, 800 * 8 / 10, 600, @viewport)
title.y=0 title.z = 2
title.width=800*8/10
title.height=600
title.viewport=@viewport
title.z=2
loop do loop do
Graphics.update Graphics.update
Input.update Input.update