RPGMakerID
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Komunitas RPG Maker Indonesia
 
IndeksIndeks  Latest imagesLatest images  PencarianPencarian  PendaftaranPendaftaran  Login  
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.

 

 [VX] On-map Bullet System

Go down 
+2
shikami
bungatepijalan
6 posters
PengirimMessage
bungatepijalan
Moe Princess
bungatepijalan


Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer

Trophies
Awards:
[VX] On-map Bullet System Empty
PostSubyek: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 19:49

On-map Bullet System
Version: 1.0
Type: Misc Add-on


Pengenalan

This script enables you to spawn a bullet that can trigger using event's self switch or switch (for hitting player).
You may use this for creating your own ABS (action battle system) because this is also used as a part of ABS.

NB: Script ini termasuk yang digunakan dalam game The Mystery House



Petunjuk & Pemasangan

- Just place the script above Main.

- To create a bullet, use code:
@bullet = $scene.createbullet(name, source, speed, dir, atk[, target])
where
@bullet = last created bullet object
name = picture name for created bullet
source = Game_Character object from which the bullet is spawned
($game_player or $game_map.events[@event_id])
speed = bullet speed
dir = 1: down
2: left
3: right
4: up
5: Southwest
6: Northwest
7: Northeast
8: Southeast
9: Toward target
10: Toward target (homing)
11: Angled direction (use @bullet.bullet_angle to determine angle)
atk = bullet attack value
target = Game_Character object to which the bullet move
(if use dir = 9 or 10)

- Accessible bullet properties:
@bullet.speed
@bullet.bullet_dir
@bullet.bullet_angle (in degrees, CCW from east)
@bullet.source (read-only)
@bullet.atk
and all attributes inherited from Game_Picture

- Global variables:
$scene.bullet_hitting = bullet that just hit an object

- Script configurations: see and edit at module BulletMod.



Screenshot

Spoiler:
(Usage on The Mystery House)
Spoiler:
Spoiler:



Demo

http://dl.dropbox.com/u/39428704/Bullet%20System.zip



Script

Code:
#==============================================================================
# On-map Bullet System
#==============================================================================
# Information:
#  This script enables you to spawn a bullet that can trigger using event's
#  self switch or switch (for hitting player).
#
# Usage:
#  - To create a bullet, use code:
#      @bullet = $scene.createbullet(name, source, speed, dir, atk[, target])
#    where
#      @bullet = last created bullet object
#      name = picture name for created bullet
#      source = Game_Character object from which the bullet is spawned
#                ($game_player or $game_map.events[@event_id])
#      speed = bullet speed
#      dir = 1: down
#            2: left
#            3: right
#            4: up
#            5: Southwest
#            6: Northwest
#            7: Northeast
#            8: Southeast
#            9: Toward target
#            10: Toward target (homing)
#            11: Angled direction (use @bullet.bullet_angle to determine angle)
#      atk = bullet attack value
#      target = Game_Character object to which the bullet move
#                (if use dir = 9 or 10)
#
#  - Accessible bullet properties:
#      @bullet.speed
#      @bullet.bullet_dir
#      @bullet.bullet_angle (in degrees, CCW from east)
#      @bullet.source (read-only)
#      @bullet.atk
#      and all attributes inherited from Game_Picture
#
#  - Global variables:
#      $scene.bullet_hitting = bullet that just hit an object
#
#  - Script configurations at module BulletMod.
#
# Installation:
#  Just place above Main.
#
# Credits
#  Alissa Liu
#
#==============================================================================

#---------------------------------------------------------------------------
# ** BulletMod Module
#---------------------------------------------------------------------------
module BulletMod
  FromPicID = 31              # Min Picture ID
  ToPicID = 61                # Max Picture ID
  PlayerHit = 16              # Player Hit Switch
  TriggerSS = "D"            # Target's Self Switch triggered when touching
                              # the bullet
end

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

class Game_Character
  #--------------------------------------------------------------------------
  # * Determine Character Collision
  #    x : x-coordinate
  #    y : y-coordinate
  #    Detects normal character collision, including the player and vehicles.
  #--------------------------------------------------------------------------
  def collide_with_characters2?(x, y)
    if self != $game_player && x==$game_player.x && y==$game_player.y
      return $game_player
    end
    for event in $game_map.events_xy(x, y)          # Matches event position
      unless event.through                          # Passage OFF?
        if event!=self
          return event if event.priority_type == 1    # Target is normal char
        end
      end
    end
    return nil
  end
end

#==============================================================================
# ** Bullet
#------------------------------------------------------------------------------

#==============================================================================
class Bullet < Game_Picture
  attr_accessor :speed
  attr_accessor :bullet_dir
  attr_accessor :bullet_angle
  attr_reader  :source
  attr_accessor :atk
  alias bulletinit initialize unless method_defined?('bulletinit')
  alias bulletshow show unless method_defined?('bulletshow')
  alias bulletupdate update unless method_defined?('bulletupdate')
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    number : picture index
  #--------------------------------------------------------------------------
  def initialize(number)
    bulletinit(number)
    @bullet_dir = -1
    @bullet_angle = 0
    @speed = 0
  end
  #--------------------------------------------------------------------------
  # * Show Picture
  #--------------------------------------------------------------------------
  def show(name, source, speed, dir, target=nil)
    bulletshow(name,1,source.screen_x,source.screen_y-16,100,100,255,0)
    @real_x = source.real_x.to_f
    @real_y = source.real_y.to_f
    @real_xo = @real_x
    @real_yo = @real_y
    @speed = speed
    @bullet_dir = dir
    @source = source
    @target = target
    if source==target
      erase
    else
      if dir==9
        @dx = speed/Math::sqrt((target.real_x-source.real_x)*(target.real_x-source.real_x)+
          (target.real_y-source.real_y)*(target.real_y-source.real_y))*(target.real_x-source.real_x)
        @dy = speed/Math::sqrt((target.real_x-source.real_x)*(target.real_x-source.real_x)+
          (target.real_y-source.real_y)*(target.real_y-source.real_y))*(target.real_y-source.real_y)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @name != ""
      x_last = @real_x
      y_last = @real_y
      case @bullet_dir
      when 1
        @real_y += @speed  # Down
      when 2
        @real_x -= @speed  # Left
      when 3
        @real_x += @speed  # Right
      when 4
        @real_y -= @speed  # Up
      when 5
        # Southwest
        @real_y += @speed*0.707
        @real_x -= @speed*0.707
      when 6
        # Northwest
        @real_y -= @speed*0.707
        @real_x -= @speed*0.707
      when 7
        # Northeast
        @real_y -= @speed*0.707
        @real_x += @speed*0.707
      when 8
        # Southeast
        @real_y += @speed*0.707
        @real_x += @speed*0.707
      when 9
        # Towards target
        @real_x += @dx
        @real_y += @dy
      when 10
        # Homing
        @dx = speed/Math::sqrt((@target.real_x-@real_x)*(@target.real_x-@real_x)+
          (@target.real_y-@real_y)*(@target.real_y-@real_y))*(@target.real_x-@real_x)
        @dy = speed/Math::sqrt((@target.real_x-@real_x)*(@target.real_x-@real_x)+
          (@target.real_y-@real_y)*(@target.real_y-@real_y))*(@target.real_y-@real_y)
        @real_x += @dx
        @real_y += @dy
      when 11
        # Angled direction
        @dx = @speed*Math::cos(@bullet_angle*Math::PI/180)
        @dy = -@speed*Math::sin(@bullet_angle*Math::PI/180)
        @real_x += @dx
        @real_y += @dy
      end
      @x = (($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16).round
      @y = (($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 16).round
      if ((x_last/256).round!=(@real_xo/256).round || (y_last/256).round!=(@real_yo/256).round)
        if !$game_map.passable?($game_map.round_x(@real_x/256).round,$game_map.round_y(@real_y/256).round) &&
          !$game_map.ship_passable?($game_map.round_x(@real_x/256).round,$game_map.round_y(@real_y/256).round)
          erase
        else
          coli = @source.collide_with_characters2?($game_map.round_x(@real_x/256).round,$game_map.round_y(@real_y/256).round)
          if (coli != nil)
            if coli == $game_player || coli.id<=0
              $game_switches[BulletMod::PlayerHit] = true
            else
              key = [$game_map.map_id,coli.id,BulletMod::TriggerSS]
              $game_self_switches[key] = true
            end
            $scene.bullet_source = @source
            $scene.bullet_hitting = self
            $scene.bullet_hitting_name = name
            erase
          end
        end
      end
      if @x<=0 || @x>=544 || @y<=0 || @y>=416
        erase
      end
      bulletupdate
    end
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
  attr_accessor :bullet_source
  attr_accessor :bullet_hitting
  attr_accessor :bullet_hitting_name
  # Alias things
  alias bulletinit initialize unless method_defined?('bulletinit')
  alias bulletupdate update unless method_defined?('bulletupdate')
  alias bulletterminate terminate unless method_defined?('bulletterminate')
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    $bullet_sprite = []
    for i in BulletMod::FromPicID..BulletMod::ToPicID
      $bullet_sprite[i-BulletMod::FromPicID] = Bullet.new(i)
    end
    bulletinit
  end
  #--------------------------------------------------------------------------
  # * createbullet
  #--------------------------------------------------------------------------
  def createbullet(name, source, speed, dir, atk, target=nil)
    ret_id = BulletMod::FromPicID
    while $bullet_sprite[ret_id-BulletMod::FromPicID].name != "" && ret_id<BulletMod::ToPicID
      ret_id += 1
    end
    if $bullet_sprite[ret_id-BulletMod::FromPicID].name == ""
      $bullet_sprite[ret_id-BulletMod::FromPicID].show(name, source, speed, dir, target)
      $bullet_sprite[ret_id-BulletMod::FromPicID].atk = atk
      return $bullet_sprite[ret_id-BulletMod::FromPicID]
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    bulletupdate
    for bulletspr in $bullet_sprite
      if bulletspr.name != ""
        if $game_player.transfer?
          bulletspr.erase
        else
          bulletspr.update
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    for bulletspr in $bullet_sprite
      bulletspr.erase
    end
    bulletterminate
  end
end

class Spriteset_Map
  alias bulletcreatepic create_pictures unless method_defined?('bulletcreatepic')
  #--------------------------------------------------------------------------
  # * Create Picture Sprite
  #--------------------------------------------------------------------------
  def create_pictures(*args);bulletcreatepic(*args)
    for bulletspr in $bullet_sprite
      @picture_sprites.push(Sprite_Picture.new(@viewport1,bulletspr))
    end
  end
end

class Sprite_Picture < Sprite
  alias bulletpic_upd update unless method_defined?('bulletpic_upd')
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update(*args);bulletpic_upd(*args)
    if @picture.number >= BulletMod::FromPicID && @picture.number <= BulletMod::ToPicID
      self.z = $game_player.screen_z+50+@picture.number-BulletMod::FromPicID
    end
  end
end


Credit

  • bungatepijalan
Kembali Ke Atas Go down
http://miyuki-maker.blogspot.co.id/
shikami
Member 1000 Konsep
avatar


Level 5
Posts : 3744
Thanked : 31
Engine : Multi-Engine User
Skill : Beginner
Type : Developer

Trophies
Awards:


[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 19:55

sepertinya ga praktis sekali bikinnya =,=a
ga bisakah lebih disederhanakan ?
Kembali Ke Atas Go down
http://shikamicro.wordpress.com
bungatepijalan
Moe Princess
bungatepijalan


Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer

Trophies
Awards:
[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 20:02

@^
ini penggunaannya secara general, ga dikhususkan utk ABS
jadi ini masih cukup mentah :|
prinsip utama disini cuma nyalain self switch event target kalo mengenainya, atau nyalain switch yg ditentukan kalo mengenai player
Kembali Ke Atas Go down
http://miyuki-maker.blogspot.co.id/
Kuru
Senior
Senior
Kuru


Level 5
Posts : 985
Thanked : 9
Engine : RMVX
Skill : Beginner
Type : Writer

Trophies
Awards:

[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 21:05

Unduh lagi :ngacay2:
Kembali Ke Atas Go down
http://pejuangmimpi7.blogspot.com
nisamerica
Living Skeleton
nisamerica


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

Trophies
Awards:


[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 23:00

Hey, hey, jangan bilang kalo ini bisa memungkinkan event untuk bergerak lebih dari 8 arah, atau bahkan secara sin cos tan?? :shocked:
Kembali Ke Atas Go down
bungatepijalan
Moe Princess
bungatepijalan


Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer

Trophies
Awards:
[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 23:04

@^
yang bergerak lebih dari 8 arah itu pelurunya, bukan eventnya, dan peluru itu sebenernya berupa picture :v
Kembali Ke Atas Go down
http://miyuki-maker.blogspot.co.id/
nisamerica
Living Skeleton
nisamerica


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

Trophies
Awards:


[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-09, 23:07

*jleb* AHAGH picture toh :hammer:

Tapi keren nih pake picture bisa dibikin collision, rumit ga bikinnya? :D
Tapi hebat bikinnya ga terlalu banyak abrisnya, bisa dibilang dikit malah :swt:


Btw Kuro Creator kayanya bakal seneng ini :D
Kembali Ke Atas Go down
maihime
Senior
Senior
maihime


Level 5
Posts : 677
Thanked : 143
Engine : Multi-Engine User
Skill : Very Beginner
Type : Artist

[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-10, 20:40

*baru lihat... :shocked:
Ehm!
Peluru berupa picture? :o
Menarik! XD Mai mau coba... :3
Mai download dulu, ya... :D
Kembali Ke Atas Go down
http://gus-1993.deviantart.com
Bcyborg21
Novice
Novice
Bcyborg21


Level 5
Posts : 204
Thanked : 1
Engine : RMVX
Skill : Advanced
Type : Artist

[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty2011-11-11, 06:21

, wahhh, sangar nih, perlu di jajal. ijin unduh ya . . .
Kembali Ke Atas Go down
Sponsored content





[VX] On-map Bullet System Empty
PostSubyek: Re: [VX] On-map Bullet System   [VX] On-map Bullet System Empty

Kembali Ke Atas Go down
 
[VX] On-map Bullet System
Kembali Ke Atas 
Halaman 1 dari 1
 Similar topics
-
» [VX] Weapon's Bullet
» (request) Bullet time effect script

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