Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Torterra Tree Minigame by Vendily
- https://twitter.com/Vendily1/status/1287168317174800385
- pbTorterraState.pbStart(event_id of the leader, array of event ids for the trees (though it can really be anything))
- pbTorterraState.pbStart(@event_id,[2,3,4,5,6,7]) (current event and the tree ids)
- pbTorterraState.pbShowRound to start the minigame proper and do the shakes. you only need to call it once, unless you want to reshow the current round.
- Check if pbTorterraState.decision==1 is true for the game to be won.
- use pbInTorterra? to see if the minigame is still in progress. It doesn't end until pbTorterraState.pbEnd is called.
- put pbTorterraState.pbInteract(@event_id) in the events that activate. you don't need to check for in progress.
- You will need to adjust the pbMoveRoute as they are still the same as my project and use hard coded character graphics.
- =end
- class PokemonGlobalMetadata
- attr_accessor :torterraState
- end
- class TorterraState
- MAX_ROUNDS = 3
- attr_accessor :decision
- attr_accessor :moves
- attr_accessor :round
- def initialize
- @inProgress=false
- @moves=nil
- @round=0
- @decision=0
- end
- def inProgress?
- return @inProgress
- end
- def pbStart(leader_id,event_ids)
- @inProgress=true
- @decision=0
- @moves=[]
- @round=0
- @leader=leader_id
- @events=event_ids
- @orders=[]
- m=3
- for r in 0...MAX_ROUNDS
- tmp=[]
- for i in 0...m
- tmp.push(@events[rand(@events.length)])
- end
- @orders.push(tmp.clone)
- m+=1
- end
- end
- def pbShowRound
- shakes=@orders[@round]
- event=$game_map.events[@leader]
- pbMoveRoute(event,[
- PBMoveRoute::Graphic,"sleepers",0,4,3,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"sleepers",0,6,0,
- PBMoveRoute::Wait,8,
- PBMoveRoute::Graphic,"sleepers",0,4,3,
- PBMoveRoute::Wait,4
- ])
- pbWait(2*2*6)
- for m in shakes
- event=$game_map.events[m]
- pbMoveRoute(event,[
- PBMoveRoute::Graphic,"headbutt tree",0,2,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,4,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,8,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,6,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,2,0
- ])
- pbWait(2*2*10)
- end
- end
- def pbInteract(event_id)
- return if !inProgress?
- return if @decision>0
- event=$game_map.events[event_id]
- pbMoveRoute(event,[
- PBMoveRoute::Graphic,"headbutt tree",0,2,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,4,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,8,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,6,0,
- PBMoveRoute::Wait,4,
- PBMoveRoute::Graphic,"headbutt tree",0,2,0
- ])
- pbWait(2*2*4)
- @moves.push(event_id)
- pbVerify
- end
- def pbVerify
- ret=nil
- for i in 0...@moves.length
- ret=false if @moves[i]!=@orders[@round][i]
- end
- if ret.nil?
- ret=true if @moves.length==@orders[@round].length
- end
- return if ret.nil?
- if ret
- Kernel.pbMessage(_INTL("Correct!"))
- @round+=1
- else
- Kernel.pbMessage(_INTL("Incorrect!"))
- end
- if @round==MAX_ROUNDS
- @decision=1
- Kernel.pbMessage(_INTL("That's all three!\\1"))
- Kernel.pbMessage(_INTL("Come back to me!"))
- return
- end
- @moves=[]
- pbShowRound
- end
- def pbEnd
- @start=nil
- @inProgress=false
- @steps=0
- @decision=0
- $game_map.need_refresh=true
- end
- end
- def pbInTorterra?
- return pbTorterraState.inProgress?
- end
- def pbTorterraState
- if !$PokemonGlobal.torterraState
- $PokemonGlobal.torterraState=TorterraState.new
- end
- return $PokemonGlobal.torterraState
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement