Advertiser Content

Scripting Question Function Code Help

Started by clawort May 20th, 2019 9:52 PM
  • 1193 views
  • 9 replies

WolfPP

Discord: Wolf#1235

Male
Brazil
Seen 1 Hour Ago
Posted 1 Hour Ago
632 posts
336 Days
Burn your neurons and edit Sucker Punch for what you want:

################################################################################
# Fails if the target didn't chose a damaging move to use this round, or has
# already moved. (Sucker Punch)
################################################################################
class PokeBattle_Move_116 < PokeBattle_Move
  def pbMoveFailed(attacker,opponent)
    return true if @battle.choices[opponent.index][0]!=1 # Didn't choose a move
    oppmove=@battle.choices[opponent.index][2]
    return true if !oppmove || oppmove.id<=0 || oppmove.pbIsStatus?
    return true if opponent.hasMovedThisRound? && oppmove.function!=0xB0 # Me First
    return false
  end
end
Check Heavy Slam's code to recognize the weight:
################################################################################
# Power increases the heavier the user is than the target. (Heat Crash, Heavy Slam)
################################################################################
class PokeBattle_Move_09B < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    n=(attacker.weight/opponent.weight(attacker)).floor
    ret=40
    ret=60 if n>=2
    ret=80 if n>=3
    ret=100 if n>=4
    ret=120 if n>=5
    return ret
  end
end
Good luck.

Poq

Seen 1 Week Ago
Posted 2 Weeks Ago
145 posts
1.9 Years
Also, this might go without saying, but make sure to assign a unique code to it as well. In the scripts where move functions are defined, you'll see this pattern at the start:
class PokeBattle_Move_### < PokeBattle_Move
where ### is the actual function code - the one that you would assign to the move in the PBS. It's a three digit hexadecimal number. Base essentials goes up to 158 with function codes, so the next available would be 159, then 15A, up to 15F, then 160. But they don't have to be sequential. You could just start up at 500 and guarantee that you're not overriding another code.

And sorry if this is all stuff you're aware of - just trying to provide a thorough answer and maybe help out someone else who comes across this post in the future.

clawort

Male
Australia
Seen June 16th, 2019
Posted June 16th, 2019
82 posts
144 Days
Burn your neurons and edit Sucker Punch for what you want:

################################################################################
# Fails if the target didn't chose a damaging move to use this round, or has
# already moved. (Sucker Punch)
################################################################################
class PokeBattle_Move_116 < PokeBattle_Move
  def pbMoveFailed(attacker,opponent)
    return true if @battle.choices[opponent.index][0]!=1 # Didn't choose a move
    oppmove=@battle.choices[opponent.index][2]
    return true if !oppmove || oppmove.id<=0 || oppmove.pbIsStatus?
    return true if opponent.hasMovedThisRound? && oppmove.function!=0xB0 # Me First
    return false
  end
end
Check Heavy Slam's code to recognize the weight:
################################################################################
# Power increases the heavier the user is than the target. (Heat Crash, Heavy Slam)
################################################################################
class PokeBattle_Move_09B < PokeBattle_Move
  def pbBaseDamage(basedmg,attacker,opponent)
    n=(attacker.weight/opponent.weight(attacker)).floor
    ret=40
    ret=60 if n>=2
    ret=80 if n>=3
    ret=100 if n>=4
    ret=120 if n>=5
    return ret
  end
end
Good luck.
Yeah but...

How do I do that?

Also, I think I already started so, is this correct?
################################################################################
# Fails if the target is heavier than the user. (Sky Lunge)
################################################################################
class PokeBattle_Move_15A < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return (attacker.weight<opponent.weight)
end

clawort

Male
Australia
Seen June 16th, 2019
Posted June 16th, 2019
82 posts
144 Days
Also, this might go without saying, but make sure to assign a unique code to it as well. In the scripts where move functions are defined, you'll see this pattern at the start:
class PokeBattle_Move_### < PokeBattle_Move
where ### is the actual function code - the one that you would assign to the move in the PBS. It's a three digit hexadecimal number. Base essentials goes up to 158 with function codes, so the next available would be 159, then 15A, up to 15F, then 160. But they don't have to be sequential. You could just start up at 500 and guarantee that you're not overriding another code.

And sorry if this is all stuff you're aware of - just trying to provide a thorough answer and maybe help out someone else who comes across this post in the future.
Already got that! :D

WolfPP

Discord: Wolf#1235

Male
Brazil
Seen 1 Hour Ago
Posted 1 Hour Ago
632 posts
336 Days
################################################################################
# Fails if the target is heavier than the user. (Sky Lunge)
################################################################################
class PokeBattle_Move_15A < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return (attacker.weight<opponent.weight)
end
Pay attention, you need to put 'return true if' and then 'return false', like you saw in Sucker Punch. Also, you don't need '()' between code.

Poq

Seen 1 Week Ago
Posted 2 Weeks Ago
145 posts
1.9 Years
Pay attention, you need to put 'return true if' and then 'return false', like you saw in Sucker Punch. Also, you don't need '()' between code.
Actually, I think that syntax is fine since (attacker.weight<opponent.weight) will already be a boolean value. The only change I might add is
class PokeBattle_Move_15A < PokeBattle_Move
  def pbMoveFailed(attacker,opponent)
    return ((attacker.weight<opponent.weight) rescue false) 
  end
just to catch any errors.

clawort

Male
Australia
Seen June 16th, 2019
Posted June 16th, 2019
82 posts
144 Days
Actually, I think that syntax is fine since (attacker.weight<opponent.weight) will already be a boolean value. The only change I might add is
class PokeBattle_Move_15A < PokeBattle_Move
  def pbMoveFailed(attacker,opponent)
    return ((attacker.weight<opponent.weight) rescue false) 
  end
just to catch any errors.
Okay! Thanks!

clawort

Male
Australia
Seen June 16th, 2019
Posted June 16th, 2019
82 posts
144 Days
Okay so it works!

Everything functions correctly. The move works on Pokemon that are lighter than the user but not heavier than the user!

This is the function code I used:
################################################################################
# Fails if the target is heavier than the user. (Sky Lunge)
################################################################################
class PokeBattle_Move_15A < PokeBattle_Move
def pbMoveFailed(attacker,opponent)
return true if ((attacker.weight<opponent.weight) rescue false)
return false
end
end
Advertiser Content