Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.

Share | 
 

 [XP] Alissa Advanced Move Route

Topik sebelumnya Topik selanjutnya Go down 
[XP] Alissa Advanced Move Route Empty2011-11-02, 11:56
Post[XP] Alissa Advanced Move Route
#1
bungatepijalan 
Moe Princess
bungatepijalan

Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer
Awards:
[XP] Alissa Advanced Move Route Vide
Alissa Advanced Move Route
(for RMXP)
Version: 1.0
Type: Misc Add-on


Pengenalan

Script ini menambahkan beberapa fungsi untuk Set Move Route:
- move_toward_event(event_id)
- move_away_from_event(event_id)
- move_toward_point(x,y)
- turn_toward_event(event_id)
- turn_toward_point(x,y)
- jump_down([turn_ok])
- jump_left([turn_ok])
- jump_right([turn_ok])
- jump_up([turn_ok])
- jump_random
- jump_toward_event(event_id)
- jump_away_from_event(event_id)
- jump_forward
- jump_backward
- show_animation(animation_id[,event_id])
- set_variable(var_id,value)
- add_variable(var_id,value)
- mul_variable(var_id,value)
- div_variable(var_id,value)
- mod_variable(var_id,value)
- get_variable(var_id)
- set_self_switch(selfswitch,value[,eventid])
- get_switch(switch_id)
- get_self_switch(selfswitch[,eventid])
- erase_event([event])
- label(label_name)
- jump_label(label_name[,cond])
- cmp_jump_label(label_name,cmp,exp1,exp2)
- end_route

Keterangan parameter-parameternya silakan diliat di body scriptnya

NB: Script ini untuk rekuesan dari nisamerica, tapi fungsi2nya diperkaya lagi. Beberapa fungsinya juga diambil dari script XPnya LiTTleDRAgo yang serupa ( https://rmid.forumotion.net/t3396-xp-advanced-move-route )



Petunjuk & Pemasangan

Cukup pasang di atas slot 'Main'.
Lalu di Set Move Route, tambahkan command Script dan gunakan fungsi yang disebutkan diatas.


Screenshot

(ngapain di-SS :v)



Demo

(If requested, probably, tapi cukup pake scriptnya dan coba fungsi2nya)


Script

Code:
#==============================================================================
# Alissa Advanced Move Route (XP)
#==============================================================================
# Information:
#  This script adds some functions to Set Move Route Command:
#    - move_toward_event(event_id)
#    - move_away_from_event(event_id)
#    - move_toward_point(x,y)
#    - turn_toward_event(event_id)
#    - turn_toward_point(x,y)
#    - jump_down([turn_ok])
#    - jump_left([turn_ok])
#    - jump_right([turn_ok])
#    - jump_up([turn_ok])
#    - jump_random
#    - jump_toward_event(event_id)
#    - jump_away_from_event(event_id)
#    - jump_forward
#    - jump_backward
#    - show_animation(animation_id[,event_id])
#    - set_variable(var_id,value)
#    - add_variable(var_id,value)
#    - mul_variable(var_id,value)
#    - div_variable(var_id,value)
#    - mod_variable(var_id,value)
#    - get_variable(var_id)
#    - set_self_switch(selfswitch,value[,eventid])
#    - get_switch(switch_id)
#    - get_self_switch(selfswitch[,eventid])
#    - erase_event([event])
#    - label(label_name)
#    - jump_label(label_name[,cond])
#    - cmp_jump_label(label_name,cmp,exp1,exp2)
#    - end_route
#
#  See parameter details at each function definitions.
#
# Usage:
#  At Set Move Route command, add movement command Script, and type
#  a function mentioned above.
#
# Installation:
#  Just place above Main.
#
# Credits
#  Alissa Liu
#  LiTTleDRAgo
#
#==============================================================================

if Object.const_defined?('SDK')
 SDK.log('Advanced Move Route', 'Alissa', 1, '1.11.11')
 !@alissa_advmoveroute_disabled = true if !SDK.enabled?('Advanced Move Route')
end

if !@alissa_advmoveroute_disabled
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move toward Event/Player
  #    event_id : Event ID or -1 for player
  #--------------------------------------------------------------------------
  def move_toward_event(event_id)
    return if $game_map.events == nil
    if event_id == -1
      event = $game_player
    else
      event = $game_map.events[event_id]
    end
    # Get difference in player coordinates
    sx = @x - event.x
    sy = @y - event.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal and vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move towards player, prioritize left and right directions
      sx > 0 ? move_left : move_right
      if not moving? and sy != 0
        sy > 0 ? move_up : move_down
      end
    # If vertical distance is longer
    else
      # Move towards player, prioritize up and down directions
      sy > 0 ? move_up : move_down
      if not moving? and sx != 0
        sx > 0 ? move_left : move_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Move away from Event/Player
  #    event_id : Event ID or -1 for player
  #--------------------------------------------------------------------------
  def move_away_from_event(event_id)
    return if $game_map.events == nil
    if event_id == -1
      event = $game_player
    else
      event = $game_map.events[event_id]
    end
    # Get difference in player coordinates
    sx = @x - event.x
    sy = @y - event.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal and vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move away from player, prioritize left and right directions
      sx > 0 ? move_right : move_left
      if not moving? and sy != 0
        sy > 0 ? move_down : move_up
      end
    # If vertical distance is longer
    else
      # Move away from player, prioritize up and down directions
      sy > 0 ? move_down : move_up
      if not moving? and sx != 0
        sx > 0 ? move_right : move_left
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Move toward Position
  #    x,y : Designated position
  #--------------------------------------------------------------------------
  def move_toward_point(x,y)
    # Get difference in player coordinates
    sx = @x - x
    sy = @y - y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal and vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move towards player, prioritize left and right directions
      sx > 0 ? move_left : move_right
      if not moving? and sy != 0
        sy > 0 ? move_up : move_down
      end
    # If vertical distance is longer
    else
      # Move towards player, prioritize up and down directions
      sy > 0 ? move_up : move_down
      if not moving? and sx != 0
        sx > 0 ? move_left : move_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Towards Event/Player
  #--------------------------------------------------------------------------
  def turn_toward_event(event_id)
    return if $game_map.events == nil
    if event_id == -1
      event = $game_player
    else
      event = $game_map.events[event_id]
    end
    # Get difference in player coordinates
    sx = @x - event.x
    sy = @y - event.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # If horizontal distance is longer
    if sx.abs > sy.abs
      # Turn to the right or left towards player
      sx > 0 ? turn_left : turn_right
    # If vertical distance is longer
    else
      # Turn up or down towards player
      sy > 0 ? turn_up : turn_down
    end
  end
  #--------------------------------------------------------------------------
  # * Turn Towards Position
  #    x,y : Designated position
  #--------------------------------------------------------------------------
  def turn_toward_point(x,y)
    # Get difference in player coordinates
    sx = @x - x
    sy = @y - y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # If horizontal distance is longer
    if sx.abs > sy.abs
      # Turn to the right or left towards player
      sx > 0 ? turn_left : turn_right
    # If vertical distance is longer
    else
      # Turn up or down towards player
      sy > 0 ? turn_up : turn_down
    end
  end
  #--------------------------------------------------------------------------
  # * Jump Down
  #    turn_ok : Allows change of direction on the spot
  #--------------------------------------------------------------------------
  def jump_down(turn_ok = true)
    # Turn down
    if turn_ok
      turn_down
    end
    # If passable
    if passable?(@x, @y, 2)
      # Turn down
      turn_down
      # Update coordinates
      jump(0,1)
      # Increase steps
      increase_steps
    # If impassable
    else
      # Determine if touch event is triggered
      check_event_trigger_touch(@x, @y+1)
    end
  end
  #--------------------------------------------------------------------------
  # * Jump Left
  #    turn_ok : Allows change of direction on the spot
  #--------------------------------------------------------------------------
  def jump_left(turn_ok = true)
    # Turn left
    if turn_ok
      turn_left
    end
    # If passable
    if passable?(@x, @y, 4)
      # Turn left
      turn_left
      # Update coordinates
      jump(-1,0)
      # Increase steps
      increase_steps
    # If impassable
    else
      # Determine if touch event is triggered
      check_event_trigger_touch(@x-1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # * Jump Right
  #    turn_ok : Allows change of direction on the spot
  #--------------------------------------------------------------------------
  def jump_right(turn_ok = true)
    # Turn right
    if turn_ok
      turn_right
    end
    # If passable
    if passable?(@x, @y, 6)
      # Turn right
      turn_right
      # Update coordinates
      jump(1,0)
      # Increase steps
      increase_steps
    # If impassable
    else
      # Determine if touch event is triggered
      check_event_trigger_touch(@x+1, @y)
    end
  end
  #--------------------------------------------------------------------------
  # * Jump up
  #    turn_ok : Allows change of direction on the spot
  #--------------------------------------------------------------------------
  def jump_up(turn_ok = true)
    # Turn up
    if turn_ok
      turn_up
    end
    # If passable
    if passable?(@x, @y, 8)
      # Turn up
      turn_up
      # Update coordinates
      jump(0,-1)
      # Increase steps
      increase_steps
    # If impassable
    else
      # Determine if touch event is triggered
      check_event_trigger_touch(@x, @y-1)
    end
  end
  #--------------------------------------------------------------------------
  # * Jump at Random
  #--------------------------------------------------------------------------
  def jump_random
    case rand(4)
    when 0
      jump_down
    when 1
      jump_left
    when 2
      jump_right
    when 3
      jump_up
    end
  end
  #--------------------------------------------------------------------------
  # * Jump toward Event/Player
  #    event_id : Event ID or -1 for player
  #--------------------------------------------------------------------------
  def jump_toward_event(event_id)
    return if $game_map.events == nil
    if event_id == -1
      event = $game_player
    else
      event = $game_map.events[event_id]
    end
    # Get difference in player coordinates
    sx = @x - event.x
    sy = @y - event.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal and vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move towards player, prioritize left and right directions
      sx > 0 ? jump_left : jump_right
      if not jumping? and sy != 0
        sy > 0 ? jump_up : jump_down
      end
    # If vertical distance is longer
    else
      # Move towards player, prioritize up and down directions
      sy > 0 ? jump_up : jump_down
      if not jumping? and sx != 0
        sx > 0 ? jump_left : jump_right
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Jump away from Event/Player
  #    event_id : Event ID or -1 for player
  #--------------------------------------------------------------------------
  def jump_away_from_event(event_id)
    return if $game_map.events == nil
    if event_id == -1
      event = $game_player
    else
      event = $game_map.events[event_id]
    end
    # Get difference in player coordinates
    sx = @x - event.x
    sy = @y - event.y
    # If coordinates are equal
    if sx == 0 and sy == 0
      return
    end
    # Get absolute value of difference
    abs_sx = sx.abs
    abs_sy = sy.abs
    # If horizontal and vertical distances are equal
    if abs_sx == abs_sy
      # Increase one of them randomly by 1
      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
    end
    # If horizontal distance is longer
    if abs_sx > abs_sy
      # Move away from player, prioritize left and right directions
      sx > 0 ? jump_right : jump_left
      if not jumping? and sy != 0
        sy > 0 ? jump_down : jump_up
      end
    # If vertical distance is longer
    else
      # Move away from player, prioritize up and down directions
      sy > 0 ? jump_down : jump_up
      if not jumping? and sx != 0
        sx > 0 ? jump_right : jump_left
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Jump Forward
  #--------------------------------------------------------------------------
  def jump_forward
    case @direction
    when 2;  jump_down(false)
    when 4;  jump_left(false)
    when 6;  jump_right(false)
    when 8;  jump_up(false)
    end
  end
  #--------------------------------------------------------------------------
  # * Jump Backward
  #--------------------------------------------------------------------------
  def jump_backward
    last_direction_fix = @direction_fix
    @direction_fix = true
    case @direction
    when 2;  jump_up(false)
    when 4;  jump_right(false)
    when 6;  jump_left(false)
    when 8;  jump_down(false)
    end
    @direction_fix = last_direction_fix
  end
  #--------------------------------------------------------------------------
  # * Show Animation
  #    animation_id : Animation ID
  #    event_id : Event ID or -1 for player
  #--------------------------------------------------------------------------
  def show_animation(animation_id,event_id=self.id)
    if event_id == -1
      character = $game_player
    else
      character = $game_map.events[event_id]
    end
    if character != nil
      character.animation_id = animation_id
    end
  end
  #--------------------------------------------------------------------------
  # * Control Variables
  #--------------------------------------------------------------------------
  def set_variable(var_id,value = 0)
    $game_variables[var_id] = value if var_id > 0
    $game_map.need_refresh = true
  end
  def add_variable(var_id,value = 0)
    $game_variables[var_id] += value if var_id > 0
    $game_map.need_refresh = true
  end
  def mul_variable(var_id,value = 0)
    $game_variables[var_id] *= value if var_id > 0
    $game_map.need_refresh = true
  end
  def div_variable(var_id,value = 0)
    $game_variables[var_id] /= value if var_id > 0
    $game_map.need_refresh = true
  end
  def mod_variable(var_id,value = 0)
    $game_variables[var_id] = $game_variables[var_id] % value if var_id > 0
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # * Get Variables
  #--------------------------------------------------------------------------
  def get_variable(var_id)
    return $game_variables[var_id]
  end
  #--------------------------------------------------------------------------
  # * Control Self Switch
  #--------------------------------------------------------------------------
  def set_self_switch(selfswitch,value,eventid=self.id)
    key = [$game_map.map_id,eventid,selfswitch]
    $game_self_switches[key] = value
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # * Get Switch
  #--------------------------------------------------------------------------
  def get_switch(switch_id)
    return $game_switches[switch_id]
  end
  #--------------------------------------------------------------------------
  # * Get Self Switch
  #--------------------------------------------------------------------------
  def get_self_switch(selfswitch,eventid=self.id)
    key = [$game_map.map_id,eventid,selfswitch]
    return $game_self_switches[key]
  end
  #--------------------------------------------------------------------------
  # * Erase Event
  #--------------------------------------------------------------------------
  def erase_event(event = self.id)
    $game_map.events[event].erase if event > 0
    $game_map.need_refresh = true
  end
  #--------------------------------------------------------------------------
  # * Label
  #    label_name : Label Name
  #--------------------------------------------------------------------------
  def label(label_name)
    @move_route.list[@move_route_index].code = 46
    @move_route.list[@move_route_index].parameters[0] = label_name
  end
  #--------------------------------------------------------------------------
  # * Jump to Label
  #    label_name : Label Name
  #    cond : Evaluation script code returning boolean value (in string)
  #--------------------------------------------------------------------------
  def jump_label(label_name,cond="true")
    for i in 0...@move_route.list.size
      if @move_route.list[i].code == 46 && @move_route.list[i].parameters[0] == label_name
        @move_route_index = i if eval(cond)
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Compare and Jump to Label
  #    label_name : Label Name
  #    cmp = "eq" : equal to
  #          "ne" : not equal to
  #          "gt" : greater than
  #          "lt" : less than
  #          "ge" : greater than or equal to
  #          "le" : less than or equal to
  #    exp1,exp2 : Expression 1, Expression 2 (can be values, switches, or variables)
  #--------------------------------------------------------------------------
  def cmp_jump_label(label_name,cmp,exp1,exp2)
    cond = true
    case cmp
    when "eq"
      cond = (exp1 == exp2)
    when "ne"
      cond = (exp1 != exp2)
    when "gt"
      cond = (exp1 > exp2)
    when "lt"
      cond = (exp1 < exp2)
    when "ge"
      cond = (exp1 >= exp2)
    when "le"
      cond = (exp1 <= exp2)
    end
    for i in 0...@move_route.list.size
      if @move_route.list[i].code == 46 && @move_route.list[i].parameters[0] == label_name
        @move_route_index = i if cond
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * End Move Route
  #--------------------------------------------------------------------------
  def end_route
    @move_route.list[@move_route_index].code = 0
    @move_route_index -= 1
  end
end
end


Credits

  • bungatepijalan
  • LiTTleDRAgo


Terakhir diubah oleh bungatepijalan tanggal 2011-11-06, 22:10, total 1 kali diubah (Reason for editing : tambahan fungsi lagi...)
[XP] Alissa Advanced Move Route Empty2011-11-02, 14:14
PostRe: [XP] Alissa Advanced Move Route
#2
Nefusa 7 
Senior
Senior
Nefusa 7

Level 5
Posts : 954
Thanked : 6
Engine : RMXP
Skill : Intermediate
Type : Scripter

[XP] Alissa Advanced Move Route Vide
gak ada demonya ya..? :hmm:
dikasih demo dunk biar lebih jelas caranya.. :hammer: :D

btw bagus kk :thumbup:
[XP] Alissa Advanced Move Route Empty2011-11-02, 14:52
PostRe: [XP] Alissa Advanced Move Route
#3
McPherson 
Senior
Senior
McPherson

Level 5
Posts : 777
Thanked : 7
Engine : Multi-Engine User
Skill : Intermediate
Type : Mapper
Awards:

[XP] Alissa Advanced Move Route Vide
@Atas
Post Count Hunter Detected! :p

Gk perlu lah Demo, da bgus d kasih scriptnya.. hehe..
anyways, thx for sharing.. :)

[XP] Alissa Advanced Move Route Empty2011-11-02, 15:02
PostRe: [XP] Alissa Advanced Move Route
#4
Nefusa 7 
Senior
Senior
Nefusa 7

Level 5
Posts : 954
Thanked : 6
Engine : RMXP
Skill : Intermediate
Type : Scripter

[XP] Alissa Advanced Move Route Vide
@atas
maap ya.. :sembah:
saya yang belum jelas cara makainya.. :hammer:
[XP] Alissa Advanced Move Route Empty2011-11-02, 17:51
PostRe: [XP] Alissa Advanced Move Route
#5
redlagart 
Advance
Advance
redlagart

Level 5
Posts : 342
Thanked : 5
Engine : Multi-Engine User
Skill : Intermediate
Type : Artist
Awards:
[XP] Alissa Advanced Move Route Vide
nice share om allisa...:thumbup:

kaga ad versi vx nya y??
[XP] Alissa Advanced Move Route Empty2011-11-02, 18:04
PostRe: [XP] Alissa Advanced Move Route
#6
bungatepijalan 
Moe Princess
bungatepijalan

Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer
Awards:
[XP] Alissa Advanced Move Route Vide
@^
ga liat ya :v
https://rmid.forumotion.net/t4831-vx-alissa-advanced-move-route
[XP] Alissa Advanced Move Route Empty2011-11-02, 20:11
PostRe: [XP] Alissa Advanced Move Route
#7
nisamerica 
Living Skeleton
nisamerica

Kosong
Posts : 1668
Thanked : 25
Engine : RMVX
Skill : Very Beginner
Type : Artist
Awards:


[XP] Alissa Advanced Move Route Vide
WOOOOOOOO cepet banget!! Thank you very much!! XD
Dengan ini akan mudah!! XD (semoga)

Thanks, cendol pertama hari ini, dan cendol kedua besok :thumbup:


BTW
Mending link ke trid yang satu lagi dicantumin di first post biar orang2 tau kalo ada versi lain :D
[XP] Alissa Advanced Move Route Empty2011-11-03, 04:53
PostRe: [XP] Alissa Advanced Move Route
#8
fachiru 
Sherlockian
fachiru

Level 5
Posts : 634
Thanked : 6
Engine : RMXP
Skill : Beginner
Type : Writer

[XP] Alissa Advanced Move Route Vide
WAAAAAH!!!
HEBAT HEBAAAAAT
BTJ TENKYUUUUUUUUUUUUUUUUUUUUUUUU~
kebantu inimah XD *males set move route manual* :hammer:
cendoled yah XD
[XP] Alissa Advanced Move Route Empty
PostRe: [XP] Alissa Advanced Move Route
#9
Sponsored content 




[XP] Alissa Advanced Move Route Vide
 

[XP] Alissa Advanced Move Route

Topik sebelumnya Topik selanjutnya Kembali Ke Atas 

Similar topics

+
Halaman 1 dari 1

Permissions in this forum:Anda tidak dapat menjawab topik
RPGMakerID :: Scripts & Event Systems :: RMXP Scripts-