Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Affection Script
#1
Affection Script
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.


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.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Emotion Script Ánemus 0 2,162 08-29-2008, 01:00 PM
Last Post: Ánemus
  Beran's iPod script Sniper308 0 2,572 08-09-2008, 01:00 PM
Last Post: Sniper308
  NeoABS & NeoSABS ()enemy processes script azrith001 0 2,334 04-04-2008, 01:00 PM
Last Post: azrith001
  Blur Effect Script Hadriel 0 2,529 01-30-2008, 01:00 PM
Last Post: Hadriel
  Warp Script Sheol 0 2,529 12-28-2007, 01:00 PM
Last Post: Sheol
  AIM Script Pack vgvgf 0 2,805 09-13-2007, 01:00 PM
Last Post: vgvgf
  Audio Encryption Script InfiniteSpawn 0 2,213 05-09-2007, 01:00 PM
Last Post: InfiniteSpawn
  Credits Script Remake avatarmonkeykirby 0 2,228 03-10-2007, 01:00 PM
Last Post: avatarmonkeykirby
  Leon Blade's Percent Script Leon Blade 0 2,223 03-05-2007, 01:00 PM
Last Post: Leon Blade
  Cogwheels original pixelmovement script!!! mechacrash 0 2,153 01-14-2007, 01:00 PM
Last Post: mechacrash



Users browsing this thread: