Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Event Based ABS

Introduction
This System (or whatever) creates events for an ABS.

Two Scripts are Required... if you want it to work.
But I'll put it all in one spoiler
#=============================================================================
# ** SG Settings Control
#=============================================================================
# sandgolem
# Version 3 (beta)
# 1.06.06
#=============================================================================
#
# Thanks Prexus, Saucetenuto, SephirothSpawn & Trickster!
# This script wouldn't exist without their help
#
#=============================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# under the default scripts and the SDK if you're using it.
#
# This script -MUST- be above all the SG Scripts, other than Loading Screen
# This script controls and saves all settings for the SG Scripts
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================
#
# These commands are explained better on pages where they're most useful.
#
# Commands added, can be used in event script:
# sg_on('name') - turns that name to true
# sg_on('name','name2','name3')
# sg_off('name') - turns that name to false (off)
# sg_off('name','name2','name3')
# sg_st('word','name') - turns name to the first value
# or sg_st(#,'name','name2','name3')
# sg_vst(var,'name1') - Sets 'name' to what's in the variable
# sg_vst(var,'name1','name2','name3')
# sg_ar('name','','',#,...) - creates a new array, replacing another
# that has the same name
# sg_ast('name','word','newword') - turns the spot where word is in the
# array to the newword
# sg_ast('name',#,'newword') or - turns what's placed at spot # in the
# sg_ast('name',#,#) array to the third option. Note: The
# arrays start at 0, not 1
# sg_2var(variable,'name') - Should only be used for #s
# Turns the variable to what's in 'name'
# sg_2var(variable,'name','name2','name3')
#
# These are used to alter $game_sg in a more friendly way for non-scripters.
# Each command is for one setting ONLY. The ones with multiple names are for
# larger ones, like this:
# $game_sg['encounter']['var'] = 5 would be sg_st(5,'encounter','var')
#
# You may also find a call script fix useful, allows lines to continue to the
# next: http://www.gamebaker.com/rmxp/scripts/call-script-fix.htm
#
#=============================================================================

if $sg_loaded != true
$data_sg = {}
end

$sg_defaults = {}

class SG_Start
def construct(i)
if $sg_defaults == false
$game_sg = false
elsif $sg_defaults == nil
$game_sg = nil
elsif $sg_defaults == true
$game_sg = true
elsif $sg_defaults.is_a?(Fixnum)
$game_sg = $sg_defaults
else
$game_sg = $sg_defaults.clone
end
end

def start_game
$game_sg = {}
sg_temp = $sg_defaults.keys
for i in 0...sg_temp.size
construct(sg_temp)
end
end
end

class Scene_Title
alias sandgolem_settings_title_newgame command_new_game
def command_new_game
sg_temp = SG_Start.new
sg_temp.start_game
sg_temp = nil
sandgolem_settings_title_newgame
end
end

def sg_makesetting(name,name2,name3,setting)
if name2 == nil
$game_sg[name.downcase] = setting
elsif name3 == nil
$game_sg[name.downcase][name2.downcase] = setting
elsif name3 != nil
$game_sg[name.downcase][name2.downcase][name3.downcase] = setting
end
end

def sg_on(name,name2=nil,name3=nil)
sg_makesetting(name,name2,name3,true)
end

def sg_off(name,name2=nil,name3=nil)
sg_makesetting(name,name2,name3,false)
return true # 10 bonus points if you know why this is there! :)
end

def sg_st(set,name,name2=nil,name3=nil)
sg_makesetting(name,name2,name3,set)
return true # same reason, just incase
end

def sg_set(name,set) # Compatability
sg_makesetting(name,nil,nil,set)
return true # same reason, just incase
end

def sg_vst(set,name,name2=nil,name3=nil)
sg_makesetting(name,name2,name3,$game_variables[set])
end

def sg_ar(array_name_string, *args)
for i in 0...args.size
if args.is_a?(String)
args = args.chomp
end
end
$game_sg[array_name_string.downcase] = args
end

def sg_ast(array_name_string, changing, new)
sg_temp = $game_sg[array_name_string]
sg_temp2 = 0
if changing.is_a?(String)
loop do
if sg_temp2 > sg_temp.size
p 'Setting to change with sg_ast does not exist! Contact game creator'
p 'Array named:', array_name_string, sg_temp
p 'Attempted to change:', changing
return
end
if sg_temp[sg_temp2] == changing
sg_temp[sg_temp2] = new.chomp
$game_sg[array_name_string] = sg_temp
return
end
sg_temp2 += 1
end
else
sg_temp[changing] = new.chomp
$game_sg[array_name_string] = sg_temp
end
end

def sg_2var(sg1,sg2,sg3=nil,sg4=nil)
if sg2.is_a?(String)
sg2 = sg2.downcase
end
if sg3 == nil
$game_variables[sg1] = $game_sg[sg2].to_i
else
if sg3.is_a?(String)
sg3 = sg3.downcase
end
if sg4 == nil
$game_variables[sg1] = $game_sg[sg2][sg3].to_i
else
if sg4.is_a?(String)
sg4 = sg4.downcase
end
$game_variables[sg1] = $game_sg[sg2][sg3][sg4].to_i
end
end
end

begin
SDK.log("SG Settings Control", "sandgolem", 3, "1.06.06")
@sg_temp == true

class Scene_Save < Scene_File
alias sandgolem_control_save_write write_data
def write_data(file)
sandgolem_control_save_write(file)
Marshal.dump($game_sg, file)
end
end

class Scene_Load < Scene_File
alias sandgolem_control_load_read read_data
def read_data(file)
sg_temp = SG_Start.new
sg_temp.start_game
sandgolem_control_load_read(file)
if !file.eof
$game_sg = Marshal.restore(file)
sg_temp2 = $sg_defaults.keys
for i in 0...sg_temp2.size
if !$game_sg.has_key?(sg_temp2)
sg_temp.construct(sg_temp2)
end
end
end
sg_temp = nil
end
end
rescue
if @sg_temp != true # if no sdk

class Scene_Save < Scene_File
alias sandgolem_control_save_write write_save_data
def write_save_data(file)
sandgolem_control_save_write(file)
Marshal.dump($game_sg, file)
end
end

class Scene_Load < Scene_File
alias sandgolem_control_load_read read_save_data
def read_save_data(file)
sg_temp = SG_Start.new
sg_temp.start_game
sandgolem_control_load_read(file)
if !file.eof
$game_sg = Marshal.restore(file)
sg_temp2 = $sg_defaults.keys
for i in 0...sg_temp2.size
if !$game_sg.has_key?(sg_temp2)
sg_temp.construct(sg_temp2)
end
end
end
sg_temp = nil
end
end
end
@sg_temp = nil
end

# Don't change this unless you know what you're doing
#=============================================================================
# ** SG Self Variables B
#=============================================================================
# sandgolem
# Version 1
# 19.04.06
#=============================================================================
#
# To use this script, use variables #1 - 3 in any events.
# It'll be whatever that event's self variable for it is.
# This also works for event page conditions
# In battle, these are temporary variables that is reset with each.
#
#=============================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts. Needs to be under SG Script Control, but
# above any that alias Game_Event's refresh.
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================

class Scene_Title
alias sandgolem_selfvarb_title_main command_new_game
def command_new_game
sandgolem_selfvarb_title_main
$sg_self_variables = {}
end
end

class Scene_Save < Scene_File
alias sandgolem_selfvarb_save_write write_save_data
def write_save_data(file)
$game_sg['selfvars'] = $sg_self_variables
sandgolem_selfvarb_save_write(file)
$game_sg['selfvars'] = nil
end
end

class Scene_Load < Scene_File
alias sandgolem_selfvarb_load_read read_save_data
def read_save_data(file)
sandgolem_selfvarb_load_read(file)
if $game_sg['selfvars'] != nil
$sg_self_variables = $game_sg['selfvars']
$game_sg['selfvars'] = nil
end
end
end

class Scene_Battle
alias sandgolem_selfvarb_battle_main main
def main
for i in 1 .. 3
$game_variables = 0
end
sandgolem_selfvarb_battle_main
end
end

class Interpreter
alias sandgolem_selfvarb_interp_execcommand execute_command
def execute_command
if $scene.is_a?(Scene_Map)
for i in 1 .. 3
key = [@map_id, @event_id, i]
if $sg_self_variables[key] != nil
$game_variables = $sg_self_variables[key]
else
$game_variables = 0
end
end
end
sandgolem_selfvarb_interp_execcommand
end

alias sandgolem_selfvarb_interp_command122 command_122
def command_122
sandgolem_selfvarb_interp_command122
if @parameters[0] <= 3 && $scene.is_a?(Scene_Map)
for i in @parameters[0] .. @parameters[1]
if i <= 3
key = [@map_id, @event_id, i]
$sg_self_variables[key] = $game_variables[1]
end
end
$game_map.need_refresh = true
end
end
end

class Game_Event < Game_Character

def refresh
new_page = nil
unless @erased
for page in @event.pages.reverse
c = page.condition
if c.switch1_valid
if $game_switches[c.switch1_id] == false
next
end
end
if c.switch2_valid
if $game_switches[c.switch2_id] == false
next
end
end
#------------------------------------------------------------------------------
# Begin SG Self Variables edit
#------------------------------------------------------------------------------
if c.variable_valid
if c.variable_id <= 3
key = [$game_map.map_id, @event.id, c.variable_id]
if $sg_self_variables[key] != nil
if $sg_self_variables[key] < c.variable_value
next
end
else
next
end
elsif $game_variables[c.variable_id] < c.variable_value
next
end
end
#------------------------------------------------------------------------------
# End SG Self Variables edit
#------------------------------------------------------------------------------
if c.self_switch_valid
key = [@map_id, @event.id, c.self_switch_ch]
if $game_self_switches[key] != true
next
end
end
new_page = page
break
end
end
if new_page == @page
return
end
@page = new_page
clear_starting
if @page == nil
@tile_id = 0
@character_name = ""
@character_hue = 0
@move_type = 0
@through = true
@trigger = nil
@list = nil
@interpreter = nil
return
end
@tile_id = @page.graphic.tile_id
@character_name = @page.graphic.character_name
@character_hue = @page.graphic.character_hue
if @original_direction != @page.graphic.direction
@direction = @page.graphic.direction
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != @page.graphic.pattern
@pattern = @page.graphic.pattern
@original_pattern = @pattern
end
@opacity = @page.graphic.opacity
@blend_type = @page.graphic.blend_type
@move_type = @page.move_type
@move_speed = @page.move_speed
@move_frequency = @page.move_frequency
@move_route = @page.move_route
@move_route_index = 0
@move_route_forcing = false
@walk_anime = @page.walk_anime
@step_anime = @page.step_anime
@direction_fix = @page.direction_fix
@through = @page.through
@always_on_top = @page.always_on_top
@trigger = @page.trigger
@list = @page.list
@interpreter = nil
if @trigger == 4
@interpreter = Interpreter.new
end
check_event_trigger_auto
end
end

=begin
┌──────────────────────────────────────┐
│● Damage Display 1.0 │
│ │
│ Created By │
│ │
│ Trickster (tricksterguy@hotmail.com)│
│ │
│ │
└──────────────────────────────────────┘

â–ºInstructions
Add this above main.

To call just do
$damage.push(Damage.new(damage, type[, param, viewport])
anything within the [] is optional
damage is the String to Display or Damage to Display
type is the type of where to display use either 'player', 'actor',
'enemy', 'event', 'tile', or just specify the x coordinate
param is the parameter you can leave this off if using player, the index if using actor or enemy
the events id if using event, an array [tile_x, tile_y] if using tile, or
the y coordinate

Optional
viewport is the viewport of the sprite you can leave this off

=end

class Damage < ::Sprite
attr_accessor :duration

def initialize(dealt_damage, type, param = nil, viewport = Viewport.new(0,0,640,480))
super(viewport)
case type.downcase
when 'player'
@battler = $game_player
when 'actor'
@battler = $game_party.actors[param]
when 'enemy'
@battler = $game_troop.enemies[param]
when 'event'
@battler = $game_map.events[param]
when 'tile'
x = (param[0] % $game_map.width) * 32
y = (param[1] % $game_map.height) * 32
else
x = type
y = param
end
@base_y = @battler.nil? ? y : @battler.screen_y
@base_x = @battler.nil? ? x : @battler.screen_x
@off_y = self.oy / 2
@off_x = 0
self.ox = 80
self.oy = 20
self.x = 0
self.y = 0
self.z = 9000
@damage = dealt_damage
damage(@damage)
end

def dispose
dispose_damage
super
end

def damage(value)
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
self.bitmap = bitmap
@duration = 40
end

def dispose_damage
self.bitmap.dispose if self.bitmap != nil
end

def update
super
if @battler != nil
if @base_x != @battler.screen_x
@base_x = @battler.screen_x
self.x = 0
end
if @base_y != @battler.screen_y
@base_y = @battler.screen_y
self.y = 0
end
end
if @duration > 0
@duration -= 1
case @duration
when 38..39
@off_y -= 4
when 36..37
@off_y -= 2
when 34..35
@off_y += 2
when 28..33
@off_y += 4
end
self.y = 0
self.opacity = 256 - (12 - @duration) * 32
end
end

def y=(y)
super(y+@base_y+@off_y)
end

def x=(x)
super(x+@base_x+@off_x)
end
end
$damage = []

class Scene_Map
alias trickster_update update
def update
for damage in $damage
if damage.is_a?(Damage)
if damage.duration <= 0
damage.dispose
damage = nil
$damage.compact!
else
damage.update
end
end
end
trickster_update
end
end




Eventing

This Event System Requires 2 new Variables and one of self variables located iin the Self_Variables script (variable numbers 1,2, or 3)
You also need two self switches.

Now all you have to do is this:

Make three Pages. on the first make one of the self variables = to the hp of the monster. so on the first page:

First Page:

Autonomous movement: (up to you)
Options: Move Animation only. (unless you want a flying monster)
Trigger Options: Autorun
Page Options:
Self_Variable = enemy hp (any number)
Self_Switches[A] = ON



On Page 2 put this:

Autonomous movement: (up to you)
Conditions: Self_Switch[A] == ON
Options: Move Animation only. (unless you want a flying monster)
Trigger Options: Action Button
Page Options:
Show Animation (Player Animation to kill enemy)
new variable = player's level
new variable * HP
new variable / sp
new variable * 4
new variable += random 0.. 7

Script: @s = $game_variables[8]
$damage.push(Damage.new(@s,'player'))

Change SP: (any number)
Self Variable -= new_variable
Contional Branch : if move is less than or equal to 0
Self_Switches = on
Self_Switshes[A] = off
end
new variable = random (0...10)
Contional Branch: if new variable == 5
Show Animation (Enemy Attack Animation
new_variable2 = 600
new_variable2 / player's level
Change HP Allow Knockout. decrease by new_variable2
end



On Page 3:

Autonomous movement: Fixed
Conditions: Self_Switch == ON
Options: Move Animation only. (unless you want a flying monster)
Trigger Options: Autorun
Page Options:
Erase Event
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top