07-26-2005, 01:00 PM
Affection Script
Beta
by RPG Fan
Jul 26 2005
New script above Main
UPDATE
Bug where affections aren't saved is fixed. Actual loading of affection data is dependent on Switch ID 1
Instructions:
Direct Editing:
Under def initialize is a variable named @friends. Set this to ONE LESS than the number of character's to have affection ratings.
(For example to have 5 friends you'd set it to 4 (0, 1, 2, 3, 4) becuase 0 counts as an ID)
Using:
Adding/Subtracting freindship ratings.
Use a call script:
id: The id representing the friend to add/subtract to/from (putting nil will add to all)
amount: The amount to add/subtract.
Finding your top affection (Soulmate)
Call script:
That will store the ID of your soulmate in the variable @soulmate.
Storing the affections and current soulmate in $game_variables
Call Script:
The value of var is the ID of the variable where affection ID 0 will be held. ID 1, 2, 3 etc. as well as you're current
soulmate (which will automactically Calculated) will be stored the variables after the one that was just added.
Reset all affection to 0:
Call script
This resets all affection and you current soulmate.
That's it.
Beta
by RPG Fan
Jul 26 2005
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
New script above Main
UPDATE
Bug where affections aren't saved is fixed. Actual loading of affection data is dependent on Switch ID 1
Code:
#================================
# Script Affection Begin (R2 By RPG Fan)
#================================
#================================
# Class Affection Begin
#================================
class Affection
#--------------------------------------
attr_accessor :affection # Makes sure variables can be changed
attr_accessor :soulmate
attr_reader :friends # Read-only Variable
attr_accessor :soulmate_affection
attr_accessor :amount
#--------------------------------------
# Initialize variables and array
#--------------------------------------
def initialize
@soulmate = 0
@friends = 8
@affection = Array.new(@friends)
@soulmate_affection = 0
@amount = 0
for i in 0..@friends
@affection[i] = 0
end
end
#--------------------------------------
# Affection Increase
#--------------------------------------
def increase(id,amount)
@amount = amount
#---------------------------------
# Check if id is nil and add
# affection.
#---------------------------------
if id == nil
for i in 0..@friends
@affection[i] += @amount
end
else
@affection[id] += @amount
end
end
#--------------------------------------
# Affection Decrease
#--------------------------------------
def decrease(id,amount)
#----------------------------------------------------
# Go back to increase by a negative number
#----------------------------------------------------
amount *= -1
increase(id,amount)
end
#--------------------------------------
# Store into $game_variables
#--------------------------------------
def store(var)
for i in 0..@friends
$game_variables[var] = @affection[i]
var += 1
end
find
$game_variables[var] = @soulmate
end
#-------------------------------------
# Find Soulmate
#-------------------------------------
def find
for i in 0..@friends
if @affection[i] > @soulmate_affection
@soulmate = i += 1
@soulmate_affection = @affection[i]
end
end
end
#--------------------------------------
# Reset all affection
#--------------------------------------
def reset
@affection.clear
@soulmate_affection = 0
@soulmate = 0
end
end
#================================
# Class Affection End
#================================
#================================
# Class Scene_Title addon Begin
#================================
class Scene_Title
#--------------------------------------------------------
alias affection_new_game command_new_game
#--------------------------------------------------------
def command_new_game
affection_new_game
$affection = Affection.new
end
end
#================================
# Class Scene_Title addon End
#================================
#================================
# Class Scene_Save addon Begin
#================================
class Scene_Save
alias affection_save_data write_save_data
def write_save_data(file)
affection_save_data(file)
Marshal.dump($affection, file)
end
end
#================================
# Class Scene_Save addon End
#================================
#================================
# Class Scene_Load addon Begin
#================================
class Scene_Load
alias affection_read_data read_save_data
def read_save_data(file)
affection_read_data(file)
if $game_switches[1] == true
$affection = Marshal.load(file)
else
$affection = Affection.new
end
end
end
#================================
# Class Scene_Load addon End
#================================
#================================
# Script Affection End
#================================
Instructions:
Direct Editing:
Under def initialize is a variable named @friends. Set this to ONE LESS than the number of character's to have affection ratings.
(For example to have 5 friends you'd set it to 4 (0, 1, 2, 3, 4) becuase 0 counts as an ID)
Using:
Adding/Subtracting freindship ratings.
Use a call script:
Code:
$affection.increase(id,amount) # For Adding
$affection.decrease(id,amount) # For Subtracting
id: The id representing the friend to add/subtract to/from (putting nil will add to all)
amount: The amount to add/subtract.
Finding your top affection (Soulmate)
Call script:
Code:
$affection.find
That will store the ID of your soulmate in the variable @soulmate.
Storing the affections and current soulmate in $game_variables
Call Script:
Code:
$affection.store(var)
The value of var is the ID of the variable where affection ID 0 will be held. ID 1, 2, 3 etc. as well as you're current
soulmate (which will automactically Calculated) will be stored the variables after the one that was just added.
Reset all affection to 0:
Call script
Code:
$affection.reset
This resets all affection and you current soulmate.
That's it.