- 76
- Posts
- 11
- Years
- Seen Mar 31, 2014
Hello,
Ok, I want to beef up the variety of fishing-based encounters by adding a bait system. This doesn't replace the old fishing system; it just enhances it by changing the pool of Pokemon that fishing on a given map will draw from. You can still fish without bait if you want (though I need to mod the code so that you have to have at least one rod in your inventory to use bait). I would also like to do special baits that increase the chance of getting a shiny Pokemon, and possibly certain baits that will have a 100% hook rate. I know there's switches that can be turned on to change these factors but I'm not sure where to put them in the item code to make them bait-specific.
I've got one type of bait partially implemented, but I seem to be unable to find the last little bit of code to modify/copy to get it to work right. Whenever I try to use it wherever I can use a rod, it just says "You can't use that here."
Here are all the changes I've made to the code so far:
PokemonItemEffects
I looked at the Fishing section of PokemonField. I see the code that manages the animation, bite chances, reaction testing (which I modified to increase the reaction time), etc. I do not see anything that defines the Rods as Encounter methods....
PokemonEncounters
I've edited the Items.txt file to include the item and I didn't have problems getting it into my inventory. I just can't seem to be able to use it.
Oh, and I spotted that I needed to add it to the PokemonBalls section under Lure Balls:
Could someone tell me what I'm still overlooking?
Thank you!
Ok, I want to beef up the variety of fishing-based encounters by adding a bait system. This doesn't replace the old fishing system; it just enhances it by changing the pool of Pokemon that fishing on a given map will draw from. You can still fish without bait if you want (though I need to mod the code so that you have to have at least one rod in your inventory to use bait). I would also like to do special baits that increase the chance of getting a shiny Pokemon, and possibly certain baits that will have a 100% hook rate. I know there's switches that can be turned on to change these factors but I'm not sure where to put them in the item code to make them bait-specific.
I've got one type of bait partially implemented, but I seem to be unable to find the last little bit of code to modify/copy to get it to work right. Whenever I try to use it wherever I can use a rod, it just says "You can't use that here."
Here are all the changes I've made to the code so far:
PokemonItemEffects
Spoiler:
I checked the PokemonItemEffects, and presumed that I should at least copy and paste the Rods stuff and replace the Rods with my items, and changed it so that the Baits are consumed rather than permanent. I assume that if I want to run a check to see if the player has a rod before using the bait, I should put that kind of check here? I have a global switch for the player having a rod (Global Switch 0062: Have Fishing Rod), but I'm not sure how to word the check in the scripts. Would it be $PokemonGlobal.Have Fishing Rod == true?
Goes in PokemonItemEffects (just after the Rods is ideal):
I also found other stuff relating to the rods and the fact that they're encounter types. PokemonItemEffects ~ line 925, and added this:
Goes in PokemonItemEffects (just after the Rods is ideal):
Code:
ItemHandlers::UseFromBag.add(:OLDBAIT,proc{|item|
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if (pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && notCliff) ||
(pbIsWaterTag?(terrain) && $PokemonGlobal.surfing)
next 4
else
Kernel.pbMessage(_INTL("Can't use that here."))
next 0
end
})
ItemHandlers::UseFromBag.copy(:OLDBAIT,:CHEAPBAIT,:GOODBAIT,:GREATBAIT,:SUPERBAIT)
Code:
ItemHandlers::UseInField.add(:OLDBAIT,proc{|item|
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if !pbIsWaterTag?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
Kernel.pbMessage(_INTL("Can't use that here."))
next
end
encounter=$PokemonEncounters.hasEncounter?(EncounterTypes::OldBait)
if pbFishing(encounter)
pbEncounter(EncounterTypes::OldBait)
end
})
I looked at the Fishing section of PokemonField. I see the code that manages the animation, bite chances, reaction testing (which I modified to increase the reaction time), etc. I do not see anything that defines the Rods as Encounter methods....
PokemonEncounters
Spoiler:
As for PokemonEncounters, I see the obvious stuff right at the start, and after that I see it talking about assessing how many steps have been taken, whether or not the area is a cave, a land, or a water area, moves and items that modify encounter rates, stuff about out-of-range encounters, but nothing about Rod-based encounters unless I'm missing something. I only modified the top sections of PokemonEncounters, but I pasted the whole file here for the sake of ease:
Code:
module EncounterTypes
Land = 0
Cave = 1
Water = 2
RockSmash = 3
OldRod = 4
GoodRod = 5
SuperRod = 6
HeadbuttLow = 7
HeadbuttHigh = 8
LandMorning = 9
LandDay = 10
LandNight = 11
BugContest = 12
OldBait = 13
Names=[
"Land",
"Cave",
"Water",
"RockSmash",
"OldRod",
"GoodRod",
"SuperRod",
"HeadbuttLow",
"HeadbuttHigh",
"LandMorning",
"LandDay",
"LandNight",
"BugContest",
"OldBait"
]
EnctypeChances=[
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[60,30,5,4,1],
[60,30,5,4,1],
[70,30],
[60,20,20],
[40,40,15,4,1],
[30,25,20,10,5,5,4,1],
[30,25,20,10,5,5,4,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[60,20,20]
]
EnctypeDensities=[25,10,10,0,0,0,0,0,0,25,25,25,25,0]
EnctypeCompileDens=[1,2,3,0,0,0,0,0,0,1,1,1,1,0]
end
class PokemonEncounters
def initialize
@enctypes=[]
@density=nil
end
def stepcount
return @stepcount
end
def clearStepCount
@stepcount=0
end
def hasEncounter?(enc)
return false if @density==nil || enc<0
return @enctypes[enc] ? true : false
end
def isCave?
return false if @density==nil
return @enctypes[EncounterTypes::Cave] ? true : false
end
def isGrass?
return false if @density==nil
return (@enctypes[EncounterTypes::Land] ||
@enctypes[EncounterTypes::LandMorning] ||
@enctypes[EncounterTypes::LandDay] ||
@enctypes[EncounterTypes::LandNight] ||
@enctypes[EncounterTypes::BugContest]) ? true : false
end
def isWater?
return false if @density==nil
return @enctypes[EncounterTypes::Water] ? true : false
end
def isEncounterPossibleHere?
if $PokemonGlobal && $PokemonGlobal.surfing
return true
elsif pbGetTerrainTag($game_player)==PBTerrain::Ice
return false
elsif self.isCave?
return true
elsif self.isGrass?
return pbIsGrassTag?($game_map.terrain_tag($game_player.x,$game_player.y))
else
return false
end
end
def pbEncounterType
if $PokemonGlobal && $PokemonGlobal.surfing
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isGrass?
time=pbGetTimeNow
enctype=EncounterTypes::Land
enctype=EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) &&
PBDayNight.isNight?(time)
enctype=EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) &&
PBDayNight.isDay?(time)
enctype=EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning)
&& PBDayNight.isMorning?(time)
if pbInBugContest?
if self.hasEncounter?(EncounterTypes::BugContest)
enctype=EncounterTypes::BugContest
end
end
return enctype
else
return -1
end
end
def setup(mapID)
@density=nil
@stepcount=0
@enctypes=[]
begin
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
@density=data[mapID][0]
@enctypes=data[mapID][1]
else
@density=nil
@enctypes=[]
end
rescue
@density=nil
@enctypes=[]
end
end
def pbMapHasEncounter?(mapID,enctype)
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
enctypes=data[mapID][1]
density=data[mapID][0]
else
return false
end
return false if density==nil || enctype<0
return enctypes[enctype] ? true : false
end
def pbMapEncounter(mapID,enctype)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
enctypes=data[mapID][1]
else
return nil
end
return nil if enctypes[enctype]==nil
chances=EncounterTypes::EnctypeChances[enctype]
chancetotal=0
chances.each {|a| chancetotal+=a}
rnd=rand(chancetotal)
chosenpkmn=0
chance=0
for i in 0...chances.length
chance+=chances[i]
if rnd<chance
chosenpkmn=i
break
end
end
encounter=enctypes[enctype][chosenpkmn]
level=encounter[1]+rand(1+encounter[2]-encounter[1])
return [encounter[0],level]
end
def pbEncounteredPokemon(enctype)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
return nil if @enctypes[enctype]==nil
chances=EncounterTypes::EnctypeChances[enctype]
chancetotal=0
chances.each {|a| chancetotal+=a}
rnd=rand(chancetotal)
chosenpkmn=0
chance=0
for i in 0...chances.length
chance+=chances[i]
if rnd<chance
chosenpkmn=i
break
end
end
encounter=@enctypes[enctype][chosenpkmn]
return nil if !encounter
level=encounter[1]+rand(1+encounter[2]-encounter[1])
return [encounter[0],level]
end
def pbCanEncounter?(encounter)
return false if !encounter || !$Trainer
if $PokemonGlobal.repel>0 && $Trainer.ablePokemonCount>0 &&
encounter[1]<=$Trainer.ablePokemonParty[0].level
return false
end
if $game_system.encounter_disabled || ($DEBUG && Input.press?(Input::CTRL))
return false
end
return true
end
def pbGenerateEncounter(enctype)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
return nil if @density==nil
return nil if @density[enctype]==0 || !@density[enctype]
return nil if @enctypes[enctype]==nil
@stepcount+=1
return nil if @stepcount<=3 # Check three steps after battle ends
encount=@density[enctype]*16
if $PokemonGlobal.bicycle
encount=(encount*4/5)
end
if $PokemonMap.blackFluteUsed
encount/=2
end
if $PokemonMap.whiteFluteUsed
encount=(encount*3/2)
end
if $Trainer.party.length>0 && !$Trainer.party[0].egg?
if isConst?($Trainer.party[0].item,PBItems,:CLEANSETAG)
encount=(encount*2/3)
elsif isConst?($Trainer.party[0].item,PBItems,:PUREINCENSE)
encount=(encount*2/3)
end
if isConst?($Trainer.party[0].ability,PBAbilities,:STENCH)
encount=(encount/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:WHITESMOKE)
encount=(encount/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:QUICKFEET)
encount=(encount/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:SNOWCLOAK) &&
$game_screen.weather_type==3
encount=(encount/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:SANDVEIL) &&
$game_screen.weather_type==4
encount=(encount/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:SWARM)
encount=(encount*3/2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:ILLUMINATE)
encount=(encount*2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:ARENATRAP)
encount=(encount*2)
elsif isConst?($Trainer.party[0].ability,PBAbilities,:NOGUARD)
encount=(encount*2)
end
end
return nil if rand(2874)>=encount
encpoke=pbEncounteredPokemon(enctype)
if $Trainer.party.length>0 && !$Trainer.party[0].egg?
if encpoke && isConst?($Trainer.party[0].ability,PBAbilities,:INTIMIDATE) &&
encpoke[1]<=$Trainer.party[0].level-5 && rand(2)==0
encpoke=nil
end
if encpoke && isConst?($Trainer.party[0].ability,PBAbilities,:KEENEYE) &&
encpoke[1]<=$Trainer.party[0].level-5 && rand(2)==0
encpoke=nil
end
end
return encpoke
end
end
I've edited the Items.txt file to include the item and I didn't have problems getting it into my inventory. I just can't seem to be able to use it.
Code:
527,OLDBAIT,Old Bait,8,100,"BROKEN This isn't very fresh, but it might attract something....",0,0,0,
Code:
BallHandlers::ModifyCatchRate.add(:LUREBALL,proc{|ball,catchRate,battle,battler|
catchRate*=3 if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
$PokemonTemp.encounterType==EncounterTypes::GoodRod ||
$PokemonTemp.encounterType==EncounterTypes::OldBait ||
$PokemonTemp.encounterType==EncounterTypes::SuperRod
Thank you!