help with custom scripts

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
ok heres the thing I found this script online for substance effects but I'm not sure how to put it in my game 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Link to script?


Most scripts tell you how to use them. To put it into your game, you should just have to copy it, create a new slot in your scripts under Materials, and paste it. Sometimes you might have to put it above or below certain other scripts if there could be dependencies or clashes, and sometimes scripts just don't work well together.


But other than that, you really haven't given us much to go on in order to help you.
 

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
here is the script they have posted 

#===============================================================================
# Substance Script
# Ver: 1.0
# Author: Day Ja Voo Games (Hunter Heidenreich)
# Date: July 18, 2013
#-------------------------------------------------------------------------------
# Description: A script that allows you to implement the effects of toxins
# such as poison in the air or even drugs and alcohol into your
# game. This can be done through tiles or through items that you
# may implement. So far, these effects only work on the main
# character, editing a hidden value that can be accessed through
# the menu.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Version History:
#
# Ver 1.0
# - Created Script
# - Added Item and Tile Customization
# - Added Intoxication Effects
# - Add SFX
# - Created Scene to View Values
#------------------------------------------------------------------------------
# Planned for Future Updates
# v1.1
# - Customizable Message Alert System
# - Death Cries Upon Death
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Instructions - Modify the Editable Region :)
#===============================================================================


#==================================Editable Region==============================
module DayJaVooGames
module Substance_FX
#==========================================================================
# Basic Toxin Information
MaximumAmountOfToxin = 1000 #The maximum amount of toxin a player can take
SoberPerStep = 1 #The amount of toxin lost per step
PointsPerAffliction = 100 #Amount of poision absorbed per affliction
AfflictionSFXName = "Attack1" #Sound Effect played on Affliction
AfflictionColor = Color.new(255, 0, 0) #Color the screen flashes
AfflictionBuffer = 30 #Buffer between afflictions
DieOnOD = true #Does player die when they hit max
MenuCommandText = "Substance Levels" #Menu option for view substance levels
SicknessEffectName = "Dry Cough-SoundBible.com-1957692509" # For Example: a Cough
#==========================================================================
# Terrain Tag Info
TerrainTagTrigger = true #Whether you want terrain to affect toxin
TerrainIDTrigger = 1 #What tag you give the toxic tile
#==========================================================================
# Scene Window Information
WarningWindowText1 = "No toxins in the body. \nFeeling great!"
WarningWindowText2 = "Feeling a litty woozy... \nMaybe I should stop what I'm doing."
WarningWindowText3 = "Now... now... I don't... \nI can't see straight..."
WarningWindowText4 = "I really need to rest. \nI don't think much more of this will do good."
WarningWindowText5 = "I can't take much more. \nI think I might die..."
end
end

#==================================End of Editable==============================


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
include DayJaVooGames::Substance_FX
#--------------------------------------------------------------------------
# * Public instance variables
#--------------------------------------------------------------------------
attr_accessor :toxic_level
attr_reader :max_toxins
#--------------------------------------------------------------------------
# * Intits everything
#--------------------------------------------------------------------------
alias dayjavoo_gameplayer_initialize_substancefx initialize
def initialize(actor_id)
dayjavoo_gameplayer_initialize_substancefx(actor_id)
@toxic_level = toxic_level
@toxic_level = 0 if !@toxic_level
@max_toxins = MaximumAmountOfToxin
end
end

#==============================================================================
# ** Substance_FX
#------------------------------------------------------------------------------
# This class triggers everything to do with substances.
#==============================================================================
class Substance_FX
include DayJaVooGames::Substance_FX
#--------------------------------------------------------------------------
# * Intits everything
#--------------------------------------------------------------------------
def initialize()
@se_buffer = 0
@se_limit = rand(5) + 1
end
#--------------------------------------------------------------------------
# * Basic update that applies to the map
#--------------------------------------------------------------------------
def update()
if TerrainTagTrigger
@current_tag = get_terrain_tag()
if @current_tag == TerrainIDTrigger
increase_toxic_level(true)
else
decrease_toxic_level()
end
else
decrease_toxic_level()
end
if Graphics.brightness < 150 && @se_buffer >= @se_limit
@se_buffer = 0
@se_limit = rand(5) + 1
RPG::SE.new(SicknessEffectName, 100, 100).play()
end
@se_buffer += 1
end
#--------------------------------------------------------------------------
# * (Planned) Message System Update
#--------------------------------------------------------------------------
def update_message()
if Graphics.brightness < 13
you_die()
return true
elsif Graphics.brightness < 53

return true
elsif Graphics.brightness < 128

return true
end
return false
end
#--------------------------------------------------------------------------
# * Increases toxic levels in system
#--------------------------------------------------------------------------
def increase_toxic_level(map, toxic = PointsPerAffliction)
$game_party.battle_members.each do |actor|
actor.toxic_level += toxic
end
if(map)
RPG::SE.new(AfflictionSFXName, 100, 100).play()
$game_map.screen.start_flash(AfflictionColor, 4)
end

end
#--------------------------------------------------------------------------
# * Decreases players toxic level
#--------------------------------------------------------------------------
def decrease_toxic_level(sober = SoberPerStep)
if $game_party.leader.toxic_level > 0
$game_party.battle_members.each do |actor|
actor.toxic_level -= sober if(actor.hp > 0)
end
end
end
#--------------------------------------------------------------------------
# * (Debug)Prints players toxic levels
#--------------------------------------------------------------------------
def print_toxic_levels()
msgbox_p($game_player.toxic_level)
end
#--------------------------------------------------------------------------
# * Reads the terrain tag
#--------------------------------------------------------------------------
def get_terrain_tag
return $game_map.terrain_tag($game_player.x, $game_player.y)
end
#--------------------------------------------------------------------------
# * Observes the brightness and updates
#--------------------------------------------------------------------------
def update_brightness()
@bringtness = (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i
Graphics.brightness = @bringtness
if Graphics.brightness < 200
$game_map.screen.start_shake(2, 2, 100)
elsif Graphics.brightness < 150
$game_map.screen.start_shake(8, 8, 100)
elsif Graphics.brightness < 100
$game_map.screen.start_shake(32, 20, 100)
elsif Graphics.brightness < 50
$game_map.screen.start_shake(50, 40, 100)
end
$game_party.members.each do |actor|
actor.toxic_level = actor.max_toxins if actor.toxic_level > actor.max_toxins
actor.hp = 0 if actor.toxic_level == actor.max_toxins
end
end
#--------------------------------------------------------------------------
# * Function called upon death
#--------------------------------------------------------------------------
def you_die()
if DieOnOD
$game_party.leader.hp = 0
i = 0
$game_party.battle_members.each do |actor|
if $game_party.leader.hp == 0
if actor.hp > 0
$game_party.swap_order($game_party.leader.index, actor.index)
end
end
end
else
$game_party.leader.hp = 1
end
end
end



#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
include DayJaVooGames::Substance_FX
#--------------------------------------------------------------------------
# * Inits the scene map
#--------------------------------------------------------------------------
alias dayjavoo_scenemap_initialize_substancefx initialize
def initialize
dayjavoo_scenemap_initialize_substancefx()
@substance_check = Substance_FX.new()
@substance_buff = 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias dayjavoo_scenemap_update_substancefx update
def update
dayjavoo_scenemap_update_substancefx()
if(Input.trigger?(:DOWN) || Input.trigger?(:RIGHT) || Input.trigger?(:UP) || Input.trigger?(:LEFT))
@substance_buff += 1
if @substance_buff >= AfflictionBuffer
@substance_check.update()
@substance_buff = 0
end
elsif(Input.press?(:DOWN) || Input.press?(:RIGHT) || Input.press?(:UP) || Input.press?(:LEFT))
@substance_buff += 1
if @substance_buff >= AfflictionBuffer
@substance_check.update()
@substance_buff = 0
end
end
@substance_check.update_message()
@substance_check.update_brightness()
end
end


#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
# This class performs common processing for the item screen and skill screen.
#==============================================================================

class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# * Starts scene item base processing
#--------------------------------------------------------------------------
alias dayjavoo_sceneitembase_start_substancefx start
def start
dayjavoo_sceneitembase_start_substancefx()
@substance_drink = Substance_FX.new()
@substance_drink.update_brightness()
@exit_scene = false
end
#--------------------------------------------------------------------------
# * Use Item on Actor
#--------------------------------------------------------------------------
def use_item_to_actors
item_target_actors.each do |target|
$data_items[item.id].note[/<Substance\s*FX :( \s*\d\d*\d*), (\d*)>/im]
if $2 && $2 != ""
if $2.to_i == 1
if $1 && $1 != ""
target.toxic_level -= $1.to_i
end
else
if $1 && $1 != ""
target.toxic_level += $1.to_i
end
end
end
@substance_drink.update_brightness()
@exit_scene = @substance_drink.update_message()
item.repeats.times { target.item_apply(user, item) }
end
end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
alias dayjavoo_scenemenu_createcommandwindow_substancefx create_command_window
def create_command_window
dayjavoo_scenemenu_createcommandwindow_substancefx()
@command_window.set_handler:)subsctance_fx, method:)command_substance))
end
#--------------------------------------------------------------------------
# * Starts the scene
#--------------------------------------------------------------------------
def command_substance
SceneManager.call(Scene_Substance)
end
end

#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================

class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Add Exit Game to Command List
#--------------------------------------------------------------------------
alias dayjavoo_windowmenucommand_addgameendcommand_substancefx add_game_end_command
def add_game_end_command
add_command(DayJaVooGames::Substance_FX::MenuCommandText, :subsctance_fx)
dayjavoo_windowmenucommand_addgameendcommand_substancefx()
end
end

#==============================================================================
# ** Scene_Substance
#------------------------------------------------------------------------------
# Class that holds scene info for the viewing substance levels
#==============================================================================
class Scene_Substance < Scene_Base
include DayJaVooGames::Substance_FX
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start()
super()
help_startup()
@substance_info = Window_SubstanceInfo.new()
@substance_info.x = 0
@substance_info. y = 72
@substance_info.open
@substance_info.openness = 255
end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
def post_start
super()
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super()
@actor = 0
@even = 0
@odd = 0
@divi = true
@substance_info.contents.clear
$game_party.battle_members.each do |actor|
@axe = @actor%2
if @actor%2==0
@divi = true
else
@divi = false
end
@substance_info.draw_face(actor.face_name, actor.face_index, (Graphics.width / 2) * @axe, (@even * 200), true) if @divi
@substance_info.draw_face(actor.face_name, actor.face_index, (Graphics.width / 2) * @axe, (@even * 200), true) if !@divi
@substance_info.draw_actor_name(actor, (Graphics.width / 2) * @axe, 100) if @actor < 2
@substance_info.draw_actor_name(actor, (Graphics.width / 2) * @axe, (@even * 300)) if @actor >= 2
@substance_info.draw_gauge((Graphics.width / 2) * @axe + 100, (@even * 300) + 70, 150, (actor.toxic_level.to_f / actor.max_toxins), Color.new(204, 153, 255), Color.new(102, 0, 102)) if @actor < 2
@substance_info.draw_gauge((Graphics.width / 2) * @axe + 100, (@even * 270), 150, (actor.toxic_level.to_f / actor.max_toxins), Color.new(204, 153, 255), Color.new(102, 0, 102)) if @actor >= 2
@substance_info.draw_text_substance_window((Graphics.width / 2) * @axe + 100, (@even * 300) + 30, ((((actor.toxic_level.to_f / actor.max_toxins).to_f) * 100).to_i).to_s + "%") if @actor < 2
@substance_info.draw_text_substance_window((Graphics.width / 2) * @axe + 100, (@even * 270) - 40, ((((actor.toxic_level.to_f / actor.max_toxins).to_f) * 100).to_i).to_s + "%") if @actor >= 2
@actor += 1
if @actor%2==0
@even += 1
else
@odd += 1
end
end
@substance_info.contents.fill_rect(0, 165, @substance_info.contents_width, 2, Color.new(255, 255, 255, 48))
update_help()
return_scene() if Input.trigger?(:B)
end
#--------------------------------------------------------------------------
# * Pre-Termination Processing
#--------------------------------------------------------------------------
def pre_terminate
super()
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
@substance_info.dispose if !@substance_info.disposed?()
@help_window.dispose if !@help_window.disposed?()
super()
end
def help_startup()
@help_window = Window_Help.new()
if (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 50
@help_window.set_text(WarningWindowText5)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 100
@help_window.set_text(WarningWindowText4)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 150
@help_window.set_text(WarningWindowText3)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 255
@help_window.set_text(WarningWindowText2)
else
@help_window.set_text(WarningWindowText1)
end
end
def update_help()
if (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 50
@help_window.set_text(WarningWindowText5)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 100
@help_window.set_text(WarningWindowText4)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 150
@help_window.set_text(WarningWindowText3)
elsif (255 * (1.0 - ($game_party.leader.toxic_level.to_f / $game_party.leader.max_toxins.to_f))).to_i < 255
@help_window.set_text(WarningWindowText2)
else
@help_window.set_text(WarningWindowText1)
end
end
end


#==============================================================================
# ** Window_SubstanceInfo
#------------------------------------------------------------------------------
# The Substance Info Window
#==============================================================================
class Window_SubstanceInfo < Window_Message
#--------------------------------------------------------------------------
# * Sets the font of the window
#--------------------------------------------------------------------------
def set_font(user_color)
contents.font.size = 18
contents.font.shadow = true
contents.font.out_color = user_color
end
#--------------------------------------------------------------------------
# * Draw Text with Control Characters
#--------------------------------------------------------------------------
def draw_text_ex(x, y, text)
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
#--------------------------------------------------------------------------
# * Sets the width of the window
#--------------------------------------------------------------------------
def window_width
return Graphics.width
end
#--------------------------------------------------------------------------
# * Sets the height of the window
#--------------------------------------------------------------------------
def window_height
return Graphics.height - 72
end
#--------------------------------------------------------------------------
# * Draw the text on the Info Window
#--------------------------------------------------------------------------
def draw_text_substance_window(x, y, text)
#set_font(user_color)
draw_text_ex(x, y, text)
end
#--------------------------------------------------------------------------
# * Wait After Output of One Character
#--------------------------------------------------------------------------
def wait_for_one_character
end
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Please re-edit your post - delete the script that's there, and post it again, but this time put it inside code tags, and put the whole lot inside spoiler tags.


Reason for the spoiler tags is that it's so big; reason for the code tags is that some of the code has been interpreted by the forum software and is not displaying as it's meant to; code tags also keeps the indenting which makes it easier to read. You will need to copy it again from the original source, not just copy what's already in your post, as the formatting has already been modified.


Also, is the script on a forum or something, with a bit of an explanation about how it works? If so, please just post a link to that, instead of pasting the script itself. A forum thread will usually have a more detailed explanation, as well as questions and answers from others who might have had issues.
 
Last edited by a moderator:

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
no idea how to put it in tags
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Don't double post - use Edit to add to your previous post instead.


So it looks like you just need to copy and paste the script into a new slot under Materials. Then follow the steps shown on that page to set everything up.
 

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
sorry about the double post. What about the tags. also is there a way to make a char use an item?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Hit the quote button on this post, and you will see what I mean with the tags:

paste your code here
When you do it yourself, you can leave out this bit: =auto:0

The forum just puts it in automatically - I don't know what it does, but it seems to work whether it's there or not.
 
Last edited by a moderator:

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
I still don't understand sorry 

Hit the quote button on this post, and you will see what I mean with the tags:

Code:
paste your code here
When you do it yourself, you can leave out this bit: =auto:0
The forum just puts it in automatically - I don't know what it does, but it seems to work whether it's there or not.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
I still don't understand sorry 
"Tag"s are special codewords that you write into your post to tell the forum software to display things differently.

We can't put them here for you to read, because then the forum software would act on them, hiding the tags and creating the different display (like the spoiler button)

But if you quote a post with a spoiler tag, then in the edit window you can see the original tag and how it was entered.

When you see that, then you have to write those tags manually into your post to create the effect.

Basically the Spoiler-opening tag (which would be [spoi.ler] but without the added dot) would go at the beginning of the text to be hidden, the spoiler-ending-tag ( which would be [/sp.oiler] with the dot removed) would go at the end of that text segment. Same would be for [co.de] and [/c.ode].

I had to add the dots into the tags to make them readable in a post - without those dots the forum would hide the tag but trigger its function.
 
Last edited by a moderator:

Evil

Newbie
Veteran
Joined
Jul 15, 2013
Messages
143
Reaction score
4
First Language
english
Primarily Uses
ok I understand what tags are but how and I supposed to know where they go with in the code
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,268
Reaction score
1,422
First Language
English
Primarily Uses
RMXP
Just before and just after. To illustrate I found an old snippet of mine:

Code:
class Module  def attr_sec_accessor(sym, default = 0)    attr_writer sym    attr_sec_reader sym, default  end   def attr_sec_reader(sym, default = 0)    sym = sym.id2name    string = "def #{sym} ;" +             "  @#{sym} = #{default}  if @#{sym}.nil? ;" +             "  @#{sym} ;" +             "end ;"    module_eval(string)  endend
This becomes:

class Module  def attr_sec_accessor(sym, default = 0)    attr_writer sym    attr_sec_reader sym, default  end   def attr_sec_reader(sym, default = 0)    sym = sym.id2name    string = "def #{sym} ;" +             "  @#{sym} = #{default}  if @#{sym}.nil? ;" +             "  @#{sym} ;" +             "end ;"    module_eval(string)  endendBeware of using preview post multiple times. The forum may mess up the spacing as you can see in my first code tag. (Yes, I did it by having [c ode][c ode]

As for why you should do it? Aside from it looking horrible scripters are usually reluctant to help.

I personally ignore posts that do not have proper code tags.





)
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top