• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Trying to make HM turn into switches in game

hirokimura

Miltank's Fanboy Number One
150
Posts
6
Years
  • Hey, I'd like to ask if this is possible to check if a switch is active in a script that isn't part of an event? I mean, I want to make the player be able to use HMs without having an item, but at a certain point of the game. Looking at essentials script, I can see where is the line that requires surf, but I wonder if I can change it with a property that checks if a switch is active, and if yes, what if this property? That would be cool to help, as I'm trying to learn by editing myself too ^^
    Thank you :3
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Hi there,

    you can check for the Global Switches (the ones you can set in an event) by using this expression:
    Code:
    $game_switches[YOUR VARIABLE NUMBER GOES IN HERE]

    For example: You want to use the swich number 100
    to check if it is on you use
    Code:
    $game_switches[100]==true
    note that the == is a compartor opposed to = which assigns a value.
     

    hirokimura

    Miltank's Fanboy Number One
    150
    Posts
    6
    Years
  • Hey Ego ^^ Thanks for the help ^^
    I'll try to come up with a script based on what you said then ^^ Let's try :)
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Hey Ego ^^ Thanks for the help ^^
    I'll try to come up with a script based on what you said then ^^ Let's try :)

    No problem :)
    Feel free to post your code here if you encounter any problems. But also make sure to add error messages as well as a description of what you were doing.
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    Just a quick note, you shouldn't use == true on switches (booleans - these are either true or false), but leave them out. To check for it being true, just type $game_switches[ID] to check for true, and !$game_switches[ID] to check for false. The exclamation mark just inverts it.
     

    hirokimura

    Miltank's Fanboy Number One
    150
    Posts
    6
    Years
  • Hey !! Sorry for late reply !
    So I've been trying and it worked !!!
    I did replace this part Pfield move line 709 with that

    def Kernel.pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = getID(PBMoves,:SURF)
    movefinder = Kernel.pbCheckMove(move)
    if !$game_switches[280]
    return false
    end
    if Kernel.pbConfirmMessage(_INTL("You could travel that water using your Levitation Skill. Use it?"))
    speciesname = (movefinder) ? movefinder.name : $Trainer.name
    Kernel.pbMessage(_INTL("\PN uses Levitation Skill - Level 1.",speciesname,PBMoves.getName(move)))
    Kernel.pbCancelVehicles
    pbHiddenMoveAnimation(movefinder)
    surfbgm = pbGetMetadata(0,MetadataSurfBGM)
    pbCueBGM(surfbgm,0.5) if surfbgm
    pbStartSurfing
    return true
    end
    return false
    end

    I didn't touch at anything else since I don't want it to crash and even if move is still defined at surf and there are movefinder methods, that won't leave an impact in the game. Thanks for the infos Marin and Ego ! I'll try to come up with the same things for other TMs and I might share the thing if nothing bugs ! (And yeah, there will be superpowers in my game, I'm nuts xD)

    I'm grateful, thank you so much ^^
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Hey !! Sorry for late reply !
    So I've been trying and it worked !!!
    I did replace this part Pfield move line 709 with that



    I didn't touch at anything else since I don't want it to crash and even if move is still defined at surf and there are movefinder methods, that won't leave an impact in the game. Thanks for the infos Marin and Ego ! I'll try to come up with the same things for other TMs and I might share the thing if nothing bugs ! (And yeah, there will be superpowers in my game, I'm nuts xD)

    I'm grateful, thank you so much ^^

    Glad that we could help and thanks for the feedback :)
     
    Back
    Top