The PokéCommunity Forums Fan Games Custom Game Development Scripts & Tutorials
Essentials Tutorial Turn HM moves into items

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #51    
Old June 20th, 2016 (11:17 PM).
Vernerl Vernerl is offline
 
Join Date: May 2016
Gender: Male
Posts: 9
Quote:
Originally Posted by Zeak6464 View Post
This is 100% Working on version 15+

Item Effect
Code:
#Surf
ItemHandlers::UseFromBag.add(:SURFBOARD,proc{|item|
   next canUseMoveSurf? ? 2 : 0
})

ItemHandlers::UseInField.add(:SURFBOARD,proc{|item|
   useMoveSurf if canUseMoveSurf?
})
Hidden Moves
Code:
#===============================================================================
# Surf
#===============================================================================
def Kernel.pbSurf
if $game_player.pbHasDependentEvents?
return false
end
if $DEBUG || movefinder=Kernel.pbCheckMove(:SURF)
if $DEBUG || $PokemonBag.pbQuantity(PBItems::SURFBOARD)>0
if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to swim?"))
speciesname=!movefinder ? $Trainer.name : movefinder.name
Kernel.pbMessage(_INTL("You started swimming!",speciesname))

surfbgm=pbGetMetadata(0,MetadataSurfBGM)
if surfbgm
pbCueBGM(surfbgm,0.5)
end

pbStartSurfing()
return true
end
end
end
return false
end

def pbStartSurfing()
Kernel.pbCancelVehicles
$PokemonEncounters.clearStepCount
$PokemonGlobal.surfing=true
Kernel.pbUpdateVehicle
Kernel.pbJumpToward
Kernel.pbUpdateVehicle
$game_player.check_event_trigger_here([1,2])
end

def pbEndSurf(xOffset,yOffset)
return false if !$PokemonGlobal.surfing
x=$game_player.x
y=$game_player.y
currentTag=$game_map.terrain_tag(x,y)
facingTag=Kernel.pbFacingTerrainTag
if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
if Kernel.pbJumpToward
Kernel.pbCancelVehicles
$game_map.autoplayAsCue
$game_player.increase_steps
result=$game_player.check_event_trigger_here([1,2])
Kernel.pbOnStepTaken(result)
end
return true
end
return false
end

Events.onAction+=proc{|sender,e|
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
!pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
Kernel.pbSurf
return
end
}

def canUseMoveSurf?
terrain=Kernel.pbFacingTerrainTag
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
if $PokemonGlobal.surfing
Kernel.pbMessage(_INTL("You're already swimming."))
return false
end
if $game_player.pbHasDependentEvents?
Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
return false
end
if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
return false
end
#if !PBTerrain.isSurfable?(terrain) || !notCliff
if !pbIsWaterTag?(terrain) || !notCliff
Kernel.pbMessage(_INTL("No swimming here!"))
return false
end
return true
end

def useMoveSurf
if !pbHiddenMoveAnimation(nil)
Kernel.pbMessage(_INTL("You started swimming!",$Trainer.name,"Surf"))
end
pbStartSurfing()
return true
end

HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
if !pbHiddenMoveAnimation(pokemon)
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
pbStartSurfing()
return true
})
But the problem isn't surf, it's Rock Smash.
Reply With Quote

Relevant Advertising!

  #52    
Old June 25th, 2016 (2:46 PM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,662
Quote:
Originally Posted by Vernerl View Post
Nope. I turned it off in the settings beforehand. It still doesn't work.
I tested your code right now and it is working. Make sure that you have HM07 in bag and, in settings, HIDDENMOVESCOUNTBADGES = true and BADGEFORROCKSMASH=0 .
__________________
Reply With Quote
  #53    
Old June 26th, 2016 (1:25 AM).
Vernerl Vernerl is offline
 
Join Date: May 2016
Gender: Male
Posts: 9
Well it's not working here, so...
Reply With Quote
  #54    
Old June 26th, 2016 (7:15 AM).
Zeak6464's Avatar
Zeak6464 Zeak6464 is offline
The Cold Guy
 
Join Date: Mar 2013
Location: USA
Age: 24
Gender: Male
Nature: Calm
Posts: 633
Send a message via Skype™ to Zeak6464
Quote:
Originally Posted by Vernerl View Post
Well it's not working here, so...
you forgot to "def canUseMoveRocksmash?" & "def canUseMoveRocksmash"
__________________


Reply With Quote
  #55    
Old June 29th, 2016 (10:41 PM).
Vernerl Vernerl is offline
 
Join Date: May 2016
Gender: Male
Posts: 9
Quote:
Originally Posted by Zeak6464 View Post
you forgot to "def canUseMoveRocksmash?" & "def canUseMoveRocksmash"
What? Where?
Reply With Quote
  #56    
Old July 21st, 2016 (10:56 PM).
max93 max93 is offline
 
Join Date: Jan 2016
Posts: 23
hi to all, in my game i would made this item, but i want that moves continuing to have their effect, can i do this? and how? thanks ç_ç
Reply With Quote
  #57    
Old July 25th, 2016 (7:23 PM).
Rot8er_ConeX's Avatar
Rot8er_ConeX Rot8er_ConeX is offline
 
Join Date: May 2015
Location: The Dissa Region
Gender: Male
Posts: 811
Quote:
Originally Posted by max93 View Post
hi to all, in my game i would made this item, but i want that moves continuing to have their effect, can i do this? and how? thanks ç_ç
As far as I'm aware this adds the item functionality rather than replacing the moves with the items.
__________________
Features of Pokemon Entropy

The black circular "doodles" in the lower right corner of my avatar are actually my username written in Gallifreyan. Yes I'm a Whovian.
Reply With Quote
  #58    
Old July 26th, 2016 (7:16 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,662
Quote:
Originally Posted by max93 View Post
hi to all, in my game i would made this item, but i want that moves continuing to have their effect, can i do this? and how? thanks ç_ç
Don't comment the 'HiddenMoveHandlers::CanUseMove' proc. Instead of changing the line 'if $DEBUG || movefinder' to 'if $DEBUG || $PokemonBag.pbQuantity(PBItems::YOURITEMINTERNALNAME)>0', change it into 'if $DEBUG || movefinder || $PokemonBag.pbQuantity(PBItems::YOURITEMINTERNALNAME)>0'.
__________________
Reply With Quote
  #59    
Old January 29th, 2017 (5:29 AM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Ok so I have this for Flash and it gives me a syntax error. Can someone explain what the problem is?
Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
def canUseFlash?
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORSLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   return true
end

HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
def canUseFlash
   darkness=$PokemonTemp.darknessSprite
   return false if !darkness || darkness.disposed?
   if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("{1} used the Torch!",$Trainer.name))
   end
   $PokemonGlobal.flashUsed=true
   while darkness.radius<176
     Graphics.update
     Input.update
     pbUpdateSceneMap
     darkness.radius+=4
   end
   return true
end
Code:
ItemHandlers::UseFromBag.add(:TORCH,proc{|item| next canUseFlash? ? 2:0 })

ItemHandlers::UseInField.add(:TORCH,proc{|item| canUseFlash if canUseFlash? })
Reply With Quote
  #60    
Old February 6th, 2017 (2:06 PM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,662
Quote:
Originally Posted by Mashirosakura View Post
Ok so I have this for Flash and it gives me a syntax error. Can someone explain what the problem is?
Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
def canUseFlash?
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORSLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   return true
end

HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
def canUseFlash
   darkness=$PokemonTemp.darknessSprite
   return false if !darkness || darkness.disposed?
   if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("{1} used the Torch!",$Trainer.name))
   end
   $PokemonGlobal.flashUsed=true
   while darkness.radius<176
     Graphics.update
     Input.update
     pbUpdateSceneMap
     darkness.radius+=4
   end
   return true
end
Code:
ItemHandlers::UseFromBag.add(:TORCH,proc{|item| next canUseFlash? ? 2:0 })

ItemHandlers::UseInField.add(:TORCH,proc{|item| canUseFlash if canUseFlash? })
Instead of

Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
def canUseFlash?
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORSLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   return true
end
try

Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORSLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   return true
})
Like the examples.
__________________
Reply With Quote
  #61    
Old February 9th, 2017 (12:09 PM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Click image for larger version

Name:	issue.png
Views:	5
Size:	56.7 KB
ID:	81311

Click image for larger version

Name:	syntax.png
Views:	3
Size:	6.0 KB
ID:	81312

Well I tried and it causes another error. Unless I did something stupid.
Reply With Quote
  #62    
Old February 9th, 2017 (4:30 PM).
Vendily's Avatar
Vendily Vendily is offline
Making BW-style OWs for RMXP
 
Join Date: Aug 2015
Gender: Female
Nature: Calm
Posts: 658
Quote:
Originally Posted by Mashirosakura View Post
Attachment 81311

Attachment 81312

Well I tried and it causes another error. Unless I did something stupid.

You're missing an end for your if
Code:
if $PokemonGlobal.flashUsed
  Kernel.pbMessage(_INTL("This is already in use"))
  return false
end
return true
__________________
Resources for ROM hackers has moved.

Reply With Quote
  #63    
Old February 10th, 2017 (6:39 AM). Edited 4 Weeks Ago by Mashirosakura.
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Quote:
Originally Posted by Vendily View Post
You're missing an end for your if
Code:
if $PokemonGlobal.flashUsed
  Kernel.pbMessage(_INTL("This is already in use"))
  return false
end
return true
It worked! Thanks very much

EDIT: I just realised this code is just the base code for flash...and that doesn't help for me actually turning it into an item.
Reply With Quote
  #64    
Old 3 Weeks Ago (2:15 PM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Ok, as I see my previous edit didn't really get an answer, I'll double-post (though I don't want to).
So what I got given when I asked for help getting an alternative (in item form) for Flash was the base code for it. I must have been misunderstood then so I'm clearing it up. Now, can anyone help me with the code for a working Flash item?
Reply With Quote
  #65    
Old 1 Week Ago (10:14 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,662
Quote:
Originally Posted by Mashirosakura View Post
Ok, as I see my previous edit didn't really get an answer, I'll double-post (though I don't want to).
So what I got given when I asked for help getting an alternative (in item form) for Flash was the base code for it. I must have been misunderstood then so I'm clearing it up. Now, can anyone help me with the code for a working Flash item?
I tested right now and the method is equals to Cut one. It's even easier, since Flash can't be used outside menu.

The code:

Code:
605,LANTERN,Lantern,Lanterns,8,0,"A lantern that illuminate caves.",2,0,6
I copied the two HiddenMoveHandlers below (these are in base Essentials):

Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   end
   return true
})

HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
   darkness=$PokemonTemp.darknessSprite
   return false if !darkness || darkness.disposed?
   if !pbHiddenMoveAnimation(pokemon)
     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
   end
   $PokemonGlobal.flashUsed=true
   while darkness.radius<176
     Graphics.update
     Input.update
     pbUpdateSceneMap
     darkness.radius+=4
   end
   return true
})
For making the two methods below. I added after the handlers:

Code:
def canUseMoveFlash?
  if !$DEBUG &&
    !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
  end
  if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
  end
  if $PokemonGlobal.flashUsed
    Kernel.pbMessage(_INTL("This is in use already."))
    return false
  end
  return true
end
 
def useMoveFlash
  darkness=$PokemonTemp.darknessSprite
  return false if !darkness || darkness.disposed?
  if !pbHiddenMoveAnimation(nil)
    Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Flash"))
  end
  $PokemonGlobal.flashUsed=true
  while darkness.radius<176
    Graphics.update
    Input.update
    pbUpdateSceneMap
    darkness.radius+=4
  end
  return true
end
And I added at PokemonItemEffects script section:

Code:
ItemHandlers::UseFromBag.add(:LANTERN,proc{|item|
   next canUseMoveFlash? ? 2 : 0
})

ItemHandlers::UseInField.add(:LANTERN,proc{|item|
   useMoveFlash if canUseMoveFlash?
})
__________________
Reply With Quote
  #66    
Old 1 Week Ago (11:14 AM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Quote:
Originally Posted by FL View Post
I tested right now and the method is equals to Cut one. It's even easier, since Flash can't be used outside menu.

The code:

Code:
605,LANTERN,Lantern,Lanterns,8,0,"A lantern that illuminate caves.",2,0,6
I copied the two HiddenMoveHandlers below (these are in base Essentials):

Code:
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc{|move,pkmn|
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   if $PokemonGlobal.flashUsed
     Kernel.pbMessage(_INTL("This is in use already."))
     return false
   end
   return true
})

HiddenMoveHandlers::UseMove.add(:FLASH,proc{|move,pokemon|
   darkness=$PokemonTemp.darknessSprite
   return false if !darkness || darkness.disposed?
   if !pbHiddenMoveAnimation(pokemon)
     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
   end
   $PokemonGlobal.flashUsed=true
   while darkness.radius<176
     Graphics.update
     Input.update
     pbUpdateSceneMap
     darkness.radius+=4
   end
   return true
})
For making the two methods below. I added after the handlers:

Code:
def canUseMoveFlash?
  if !$DEBUG &&
    !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORFLASH : $Trainer.badges[BADGEFORFLASH])
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
  end
  if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
  end
  if $PokemonGlobal.flashUsed
    Kernel.pbMessage(_INTL("This is in use already."))
    return false
  end
  return true
end
 
def useMoveFlash
  darkness=$PokemonTemp.darknessSprite
  return false if !darkness || darkness.disposed?
  if !pbHiddenMoveAnimation(nil)
    Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Flash"))
  end
  $PokemonGlobal.flashUsed=true
  while darkness.radius<176
    Graphics.update
    Input.update
    pbUpdateSceneMap
    darkness.radius+=4
  end
  return true
end
And I added at PokemonItemEffects script section:

Code:
ItemHandlers::UseFromBag.add(:LANTERN,proc{|item|
   next canUseMoveFlash? ? 2 : 0
})

ItemHandlers::UseInField.add(:LANTERN,proc{|item|
   useMoveFlash if canUseMoveFlash?
})
Thanks very much, it's 100% working!
Whilst we're still on the subject, I've tried out your surf one and it no longer works, something about pbIsWaterTag?
Attached Thumbnails
surfbug.png‎  
Reply With Quote
  #67    
Old 4 Days Ago (11:09 AM).
FL's Avatar
FL FL is offline
Pokémon Island Creator
 
Join Date: Sep 2010
Gender: Male
Posts: 1,662
Quote:
Originally Posted by Mashirosakura View Post
Thanks very much, it's 100% working!
Whilst we're still on the subject, I've tried out your surf one and it no longer works, something about pbIsWaterTag?
Did you tried the described on latest posts?
__________________
Reply With Quote
  #68    
Old 4 Days Ago (2:31 PM).
Mashirosakura's Avatar
Mashirosakura Mashirosakura is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 25
Quote:
Originally Posted by FL View Post
Did you tried the described on latest posts?
Yes, I did. Here, this is a clearer way of me showing you the issue.
Attached Thumbnails
script.png‎  
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 6:09 PM.