Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Submission: Domain Effects, by Prexus
Prexus
post Oct 15 2005, 03:16 AM
Post #1


Level 3
Group Icon

Group: Member
Posts: 31
Type: Event Designer
RM Skill: Masterful




Place this in a new script above main and read the instructions.

All the description of what this does and what it can do are in the comments.

Please, do not ask for screenshots. They aren't applicable to this code. Additionally, there is a demo available at the bottom of the page.

Updated Friday July 29th;
Fire now checks for the party being dead and plays an SE when people die.
Thanks to MeisMe for the fix ^^

CODE
#-------------------------------------------------------------------------------
# Domain Effects
#-------------------------------------------------------------------------------
# Made By Prexus
# Made On Thursday July 28th
# http://prexus.rmxponline.com/
# All Rights Reserved.
#-------------------------------------------------------------------------------
# -Information-
# Domain effects are things that occur under certain circumstances. Things such
# as exhaustion due to humidity, stupidity due to a mind-draining enchantment,
# and the like.
# This script utilizes flags in map names to create domain effects.
# By default, these flags exist:
# [Fire]
# [Cold]
# [Poison]
# [Cure]
# But they are by no means the only ones you can have. It just requires some
# simple coding to create new effects. These, however, have been made to be
# customizable for your own benefit incase you cannot create your own.
#
# -Default Flags-
# Fire
# Effect: This simulates an area which is under extreme heat conditions. Its effect
# in RMXP is constant damage over time.
# Factors: If armor has Fire Protection (the fire attribute) the character wearing
# it will not take damage. It can be in any slot (head/body/shield/accessory)
#
# Cold
# Effect: This simulates an area which is extremely cold and frigid. Its effect in
# RMXP is a slowing of movement speed.
# Factors: Movement speed is slowed by 1 for each character who does not have
# armor which protects from cold. So, if nobody has cold resistant armor, the
# speed will be reduced to almost frozen, whereas if only 1 out of 4 characters
# has no cold resistant armor, the speed decrease won't be soo bad.
#
# Poison
# Effect: This simulates coming under a bad state of being due to inhaling a
# toxic gas. Its effect in RMXP is, depending on proximity to the source, a chance
# to become afflicted with Poison.
# Factors: Proximity to the source will affect your chances of becoming poisoned.
#
# Cure
# Effect: Funnily enough, here is a GOOD domain effect. Its effect in RMXP is a
# heal every so often and a removal of all status effects, including death.
# Factors: Its a GOOD thing. No factors.
# -End Default Flags-
#
# Each flag has its own parameters,
#
# Directly below this are parameters to customize certain aspects of the system.

$character_change = true

# ^ Change this to true if you want it so it displays the first
# ALIVE actor in your party when walking around on the map.

$window_show = true

# ^ Change this to be true if you want to see the Domain Effect window in
# the top left hand of the screen.
# At any point in time you can put "$window_show = false" or "$window_show = true" into
# a Call Script to hide/show it.

$window_text = "outline"

# ^ This decides how to show the text in the window. It can be set to the
# following:
# "none" for just text
# "shadow" for a black shadow
# "outline" for a black outline

$window_thickness = 1

# ^ This is the thickness of a shadow or outline. It doesn't matter what this
# says if text is set to "none"

class Game_Player < Game_Character
alias domeff_g_player_refresh refresh
def refresh
domeff_g_player_refresh
if $character_change == true
for i in 0...$game_party.actors.size
if $game_party.actors[i] != nil
actor = $game_party.actors[i]
if actor.hp > 0
@character_name = actor.character_name
@character_hue = actor.character_hue
@opacity = 255
@blend_type = 0
return
end
end
end
end
end
end

class String # By Astro_Mech
def find(s1, s2)
return "None" unless self.include?(s1)
sz = s1.length
a = []
str = ""
index = 0
for i in self.split(//)
index += 1
a.push(i)
if a.join[index-sz, sz] == s1
break
end
end
a.clear
sz = s2.length
newindex = 0
for i in self.split(//)[index, self.size-1]
newindex += 1
a.push(i)
if a.join[newindex-sz, sz] == s2
for i in 0...sz
a.pop
end
str = a.join
break
end
end
return str
end
end

class Game_Map # By Astro_Mech
alias domeff_g_map_refresh refresh
def refresh
domeff_g_map_refresh
if $scene.is_a?(Scene_Map)
if $scene.domain_window != nil
$scene.domain_window.refresh
end
end
end
def get_info
map_data = load_data("Data/MapInfos.rxdata")[@map_id]
return map_data.name.find("[", "]").to_s
end
end

class Interpreter
def command_355
script = @list[@index].parameters[0] + " n"
loop do
if @list[@index+1].code == 655
script += @list[@index+1].parameters[0] + " n"
else
break
end
@index += 1
end
script += "return"
result = eval(script)
if result == false
return false
end
return true
end
end

class Window_Domain < Window_Base
attr_accessor :old_chance
def initialize
super(-16, -16, 240, 112)
self.contents = Bitmap.new(width-32, height-32)
self.opacity = 0
@old_chance = 0
refresh
end
def refresh
self.contents.clear
if $window_text == "shadow"
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(7 + $window_thickness, 7 + $window_thickness, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
elsif $window_text == "outline"
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(7 + $window_thickness, 7 + $window_thickness, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
self.contents.draw_text(7 + $window_thickness, 7 - $window_thickness, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
self.contents.draw_text(7 - $window_thickness, 7 + $window_thickness, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
self.contents.draw_text(7 - $window_thickness, 7 - $window_thickness, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
end
self.contents.font.color = normal_color
self.contents.draw_text(7, 7, self.contents.width-8, 32, "Domain: " + $game_map.get_info.to_s)
case $game_map.get_info.upcase
when "POISON"
if $scene.is_a?(Scene_Map)
chance = $scene.chance.to_s
else
chance = "Unknown"
end
if $window_text == "shadow"
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(7 + $window_thickness, 39 + $window_thickness, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
elsif $window_text == "outline"
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(7 + $window_thickness, 39 + $window_thickness, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
self.contents.draw_text(7 + $window_thickness, 39 - $window_thickness, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
self.contents.draw_text(7 - $window_thickness, 39 + $window_thickness, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
self.contents.draw_text(7 - $window_thickness, 39 - $window_thickness, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
end
self.contents.font.color = normal_color
self.contents.draw_text(7, 39, self.contents.width-8, 32, "Affliction Rate: " + chance.to_s + "%")
end
end
def update
if $scene.is_a?(Scene_Map)
if $scene.chance.to_i != @old_chance.to_i and $game_map.get_info.upcase == "POISON"
refresh
@old_chance = $scene.chance
end
end
end
end

class Scene_Map
alias domeff_s_map_transfer_player transfer_player
def transfer_player
domeff_s_map_transfer_player
if @domain_window != nil
@domain_window.refresh
end
end
end

# -- For [FIRE] --
# Info:
# Fire is a damage over time effect. It can be changed to mean other things, but
# as it is, it synthesizes a situation where extreme heat is taking its toll on
# the party's bodies. This causes the skin and such to bubble and burst, harming
# the members of the party. Fire resistant armor will defend against this.
#
# Option can be set to direct or percentage.
# - Direct will decrease the amount of HP by the value in Damage
# - Percentage will decrease the HP by the percentage in damage.
# Lethal will decide whether or not the damage can kill.
# - true will make it able to kill
# - false will make sure the HP is set to 1 rather than kill
# Damage can be set to a value that corresponds with Direct
# Protection can be set to the element ID of Fire.
#
# Definables::

$fire_option = "percentage" # Set to either "direct" or "percentage".
$fire_lethal = true # Set to true if you want it to be able to kill and false if not.
$fire_damage = 10 # Set to the value of damage.
$fire_protection = 1 # Set to the element ID of Fire.

# ::End

# -- For [CURE] --
# Info:
# Sometimes the Gods intervene and create a holy place where one has his wounds
# tended to by invisible angels. Over time, one can recover all his strength.
#
# Definables::

$cure_option = "direct" # Set to either "direct" or "percentage"
$cure_heal = 10 # Set to the value of healing
$cure_states = true # Set to true if you want cure domains to recover status effects including death.

# ::End

# -- For [POISON] --
# Info:
# Toxic gases can inflict a bad state of being through a variety of means. One
# such method is being through inhaling the toxic gas. This synthesizes this
# situation by checking a certain range around the player for tiles with an ID,
# these tiles representing tiles where toxic gases would be emitted from.
# In a situation where one is pretty distant from the source, the chance of
# being afflicted with a bad state of being is minimal however when one is close
# to the source, or close to many sources, the chances are much greater.
#
# Definables::

$poison_range = 2 # Set to the amount of squares from which one can inhale toxins.
$poison_tileID = 1 # Set to the Terrain Tag ID of toxic sources.
$poison_id = 3 # Set to the ID of Poison in the Status tab of the database.
$poison_chance = 5 # Set this to the percentage chance of inflicting..

# Note about Chance, make it lower if the range is higher.
# ::End

# -- For [COLD] --
# Info:
# Cold is a slowing effect. When matter becomes cold, the molecules slow down.
# This causes a lapse in reaction time and speed.
#
# Protection can be set to the element ID of Ice/Cold.
#
# Definables::

$cold_protection = 2 # Set to the element ID of Ice/Cold.

# ::End

class Scene_Map
attr_accessor :domain_window
attr_accessor :chance
alias domeff_s_map_main main
alias domeff_s_map_update update
def main
@domain_window = Window_Domain.new
@map_counter = 0
@chance = 0
domeff_s_map_main
@domain_window.dispose
end
def update
domeff_s_map_update
if @domain_window.visible
@domain_window.update
end
@domain_window.visible = $window_show
map_type = $game_map.get_info.upcase
case map_type
when "FIRE"
if @map_counter > 20
@map_counter = 0
$game_screen.start_flash(Color.new(255,0,0,128), 10)
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
# Shield Protection
armor = $data_armors[actor.armor1_id]
if armor != nil
next if armor.guard_element_set.include?($fire_protection)
end
# Head Protection
armor = $data_armors[actor.armor2_id]
if armor != nil
next if armor.guard_element_set.include?($fire_protection)
end
# Armor Protection
armor = $data_armors[actor.armor3_id]
if armor != nil
next if armor.guard_element_set.include?($fire_protection)
end
# Accessory Protection
armor = $data_armors[actor.armor4_id]
if armor != nil
next if armor.guard_element_set.include?($fire_protection)
end
if $fire_option.upcase == "DIRECT"
if $fire_lethal == true
next if actor.hp == 0
actor.hp -= $fire_damage
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
$game_temp.gameover = $game_party.all_dead?
end
else
if (actor.hp - $fire_damage) <= 0
actor.hp = 1
end
end
elsif $fire_option.upcase == "PERCENTAGE"
if $fire_lethal == true
next if actor.hp == 0
actor.hp -= (actor.maxhp / $fire_damage).floor
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
$game_temp.gameover = $game_party.all_dead?
end
else
if (actor.hp -= (actor.maxhp / $fire_damage).floor) <= 0
actor.hp = 1
end
end
end
end
$game_map.need_refresh
$game_player.refresh
else
@map_counter += 1
end
when "CURE"
if @map_counter > 20
@map_counter = 0
$game_screen.start_flash(Color.new(255,255,255,128), 5)
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if $cure_option.upcase == "DIRECT"
actor.hp += $cure_heal
elsif $cure_option.upcase == "PERCENTAGE"
actor.hp += (actor.maxhp / $cure_heal).floor
end
if $cure_states
for k in actor.states.clone
actor.remove_state(k)
end
end
end
$game_map.need_refresh
$game_player.refresh
else
@map_counter += 1
end
when "POISON"
if @map_counter > 20
@map_counter = 0
check_poison
else
@map_counter += 1
end
end
end
def check_poison
@chance = 0
range = $poison_range
if $game_map.terrain_tag($game_player.x, $game_player.y) == $poison_tileID
@chance += 100
end
for i in 1..range
if $game_map.terrain_tag($game_player.x + i, $game_player.y) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x - i, $game_player.y) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x, $game_player.y + i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x, $game_player.y - i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x + i, $game_player.y + i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x - i, $game_player.y - i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x - i, $game_player.y + i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
if $game_map.terrain_tag($game_player.x + i, $game_player.y - i) == $poison_tileID
@chance += $poison_chance * (range + 1 - i)
end
end
if @chance > (rand(100) + 1)
for i in 0..$game_party.actors.size
if $game_party.actors[i] != nil
$game_party.actors[i].add_state($poison_id)
end
end
end
end
end

class Game_Character
alias domeff_g_character_initialize initialize
alias domeff_g_character_update update
def initialize
domeff_g_character_initialize
@default_speed = 4
@default_frequency = 6
end
def update
if self.is_a?(Game_Player)
@move_speed = @default_speed
@move_frequency = @default_frequency
map_type = $game_map.get_info.upcase
case map_type
when "COLD"
for i in 0..$game_party.actors.size
actor = $game_party.actors[i]
if actor != nil
# Shield Protection
armor = $data_armors[actor.armor1_id]
if armor != nil
next if armor.guard_element_set.include?($cold_protection)
end
# Head Protection
armor = $data_armors[actor.armor2_id]
if armor != nil
next if armor.guard_element_set.include?($cold_protection)
end
# Armor Protection
armor = $data_armors[actor.armor3_id]
if armor != nil
next if armor.guard_element_set.include?($cold_protection)
end
# Accessory Protection
armor = $data_armors[actor.armor4_id]
if armor != nil
next if armor.guard_element_set.include?($cold_protection)
end
@move_speed -= 1
@move_frequency -= 1
end
end
end
end
domeff_g_character_update
end
end


The Demo
Domain Effects Demo (May Be Slightly out of date.)
Reason for edit: Removed all the random ?'s (by Night_Runner)


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 06:59 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker