NuKa_BuBble
Member
I started this script; The lumberjack script; a few months ago and I stopped to work on cause I can't make it work. Someone can help me to finish it?
This one is the Karma Script. I don't know how to make a HUD and the defeat process. I maked it work one day but, I lossed the working version. Back to start. :grin:
Code:
################################################################################
# Lumberjack system #
# #
# By: NuKa_BuBble #
# Version: 1.0 #
# Started: 23/10/2011 #
# #
# You can find me on these websites: #
# http://gameface101.playogame.com/ #
# #
# Special thank: #
# mr_wiggles #
# G@MeF@Ce #
# #
# *** Must give credit *** #
# #
# #
################################################################################
# #
# Tree graphics are needed #
# #
################################################################################
# #
# Instructions #
# #
# First, you need to learn the job. $ljob = true #
# Second step, add in an event $ttype and a value in 1 to 10 #
# Call the script by using $game_party.perform_cut #
# Finally, do the second step but, set the value to 0 #
# #
# #
################################################################################
#------------------------------------------------------------------------------#
# #
# Class Game_Party #
# #
#------------------------------------------------------------------------------#
class Game_Party
alias :lumbering_init :initialize
def initialize
lumbering_init
# Lumberjack level
@llvl = 1
# Lumberjack experience ponts
@lxp = 0
# Energie amount gave to player
@ener = 100
@ener_max = 100
# Check what's the tree type
$ttype = 0
# Lumberjack job is learned
$ljob = false
# The old lumberjack level
@old_llvl = 0
# Amount of experience gain when you cut a tree
@lxp_gain = 0
# Experience require to reach the next lumbering level
@n_llvl = 0
# Used to compute the energie
@a = 10
@b = 5
# Used for the next lvl xp computing
@c = 15
# Check if the player have the required level to cut the type of tree
@cctt = (@llvl / 10).ceil
# Check if the player can cut
@cc = nil
# Check if the player is equip with a lumbering weapon
@lweapon_id = [6, 7]
# The number of logs gain, the logs ID and quality when you cut a tree
@lnumber = 0
@lquality = 0
@id = 0
@lid = $data_items[@id].id
# Tree cut. Use to check if a tree was just cutted
@tcut = false
end # End of initialize method
##########################################################################
# For any reference the variables, search them in the initialize method #
##########################################################################
#------------------------------------------------------#
# #
# Check what happen when the player lvl up #
# #
#------------------------------------------------------#
def check_llvl_up
if @lxp >= @n_llvl #If the xp are higher than the next llvl require xp
@llvl += 1 #lvl up
@a += 10 #Maximum energie + 10; See the energie computation before touch
end
if @old_llvl != @llvl #If your old_llvl is not equal to your llvl
next_llvl_xp_req #Call this method
compute_ener #Call this method
end
#If the llvl is located between 50 and 71, include, and if the player lvl up
if ((@llvl >= 50) && (@llvl <= 70)) && @old_llvl != @llvl
@b += 5 #Maximum energie - 5; See the energie computation before touch
end
end
#------------------------------------------------------#
# #
# Check if theres any problem with the lvl #
# #
#------------------------------------------------------#
def check_llvl
if @llvl < 1 #If the llvl is under 1
@llvl = 1 #Set the llvl to 1
elsif @llvl > 100 #If the llvl is higher than 100
@llvl = 100 #Set the llvl to 100
end
end
#------------------------------------------------------#
# #
# Compute the xp required to lvl up again #
# #
#------------------------------------------------------#
def next_llvl_xp_req
if @old_llvl != @llvl #If your precedent llvl is not equal to your llvl
@c * 1.75 #Variable C multiplied by 1.75
@llvl + @c = @n_llvl.floor #llvl + C are equal to the next lvl rounded down
@old_llvl = @llvl #Set the old level to the actual
end
end
#------------------------------------------------------#
# #
# Compute the player xp gained #
# #
#------------------------------------------------------#
def compute_lxp
#lnumber multiplied by lquality divided by 2
#multiplied by the ttype is equal to lxp_gain.
((@lnumber * @lquality)/2) * $ttype = @lxp_gain
@lxp += @lxp_gain #Add the balance to your xp
@lxp_gain = 0 #Set the lxp_gain to 0
@quality = 0 #Set the quality to 0
@lnumber = 0 #Set the lnumber to 0
end
#------------------------------------------------------#
# #
# Energie computation #
# #
#------------------------------------------------------#
def compute_ener
if (@llvl >= 50) && (@llvl <= 70) #If your llvl is between 50 and 70 include
@ener = (100 - b) + a #Set your energie to 100, substract B and add A
elsif @llvl >= 71 #Else if your llvl is higher than 71, include
@ener = a #Your energie equal to A; Not the original 100.
end
@max_ener = @ener #Your maximum energie is equal to your actual energie
end
#------------------------------------------------------#
# #
# Define a biased distribution #
# #
#------------------------------------------------------#
def random(array)
sum = array.inject {|sum, n| sum + n}
n = rand(sum)
array.each_with_index do |i, index|
return index if n < i
n -= i
end
end
#------------------------------------------------------#
# #
# Define the number and the quality of the gained wood #
# #
#------------------------------------------------------#
def lgain
#Call the method random with a sum of 600; Split the 6 to get the purcentage
@lnumber = random([6, 12, 15, 20, 30, 517])
case @lnumber #Work on the lnumber
when 0 #If the number is the first in the list
@lnumber = 10 #Set the lnumber to 10
@lquality = 10 #Set the lquality to 10
when 1 #If the number is the second in the list
@lnumber = 5 #....
@lquality = 5 #....
when 2 #....
@lnumber = 4 #....
@lquality = 4 #....
when 3 #....
@lnumber = 3 #....
@lquality = 3 #....
when 4 #....
@lnumber = 2 #....
@lquality = 2 #....
when 5 #....
@lnumber = 1 #....
@lquality = 1.5 #....
end
end
#------------------------------------------------------#
# #
# Define the condition to cut #
# #
#------------------------------------------------------#
def conditions
#If the player is equip with a lumberig weapon AND he learned the job AND
#his energie is higher than 0 AND if he can cut the tree type
if @actors[0].weapon_id == @lweapon_id
if $ljob == true
if @ener > 0
if @cctt >= $ttype
if $ttype != 0
@cc = true #The player can cut
end
end
end
end
else
@cc = false #Else, (s)he can't cut
end
end
#------------------------------------------------------#
# #
# Define if the player perform a cut #
# #
#------------------------------------------------------#
def cut
conditions #Call the conditions method
if @cc == true #If ttype is equal to 0 AND can cut
@tcut = true #The tree is cut
else
@tcut = false #Else, the tree is not cut
end
end
#------------------------------------------------------#
# #
# Define what happens when you cut #
# #
#------------------------------------------------------#
def perform_cut
#Point to the self switch C
key = [$game_map.map_id, self.id, "C"]
cut #Call the cut? method
if @tcut == true #If the player can cut
$game_self_switches[key] = true #Turn the self switch on
#-------------------#
if $ttype == 1 # If tree type is equal to 1
@id = 100 # ID in the database
elsif $ttype == 2
@id = 101
elsif $ttype == 3
@id = 102
elsif $ttype == 4
@id = 103
elsif $ttype == 5
@id = 104
elsif $ttype == 6
@id = 105
elsif $ttype == 7
@id = 106
elsif $ttype == 8
@id = 107
elsif $ttype == 9
@id = 108
elsif $ttype == 10
@id = 109
end
#-------------------#
lgain #Call the lgain method
compute_lxp #Call the compute_lxp method
$game_party.gain_item(@lid, @lnumber) #The player gain the item X * number
$game_variables[20] = @llvl #The variable 20 is equal to the llvl; To display it in a text
$game_variables[21] = @lxp #...
$game_variables[22] = @ener #...
$game_variables[23] = @n_llvl #...
$game_variables[24] = @max_ener #...
@ener -= 5 #You lost 5 energie when you cut
@lnumber = 0 #Reinitialize the lnumber gain
@lquality = 0 #Reinitialize the lquality gain
@id = 0 #Reinitialize the item id; See the lid variable
$ttype = 0 #Reinitialize the tree type
@tcut = false #Turn the tree cut off
end
update #Call the update method; Very important
end
end #End of the class
This one is the Karma Script. I don't know how to make a HUD and the defeat process. I maked it work one day but, I lossed the working version. Back to start. :grin:
Code:
################################################################################
# Karma points system #
# #
# By: NuKa_BuBble #
# Version: 1.0 #
# Info: I've rewrite the Moghunter Action Points Script to get a #
# Karma Script. This one can only be use in XAS 3.91 #
# [url=http://gameface101.playogame.com/]http://gameface101.playogame.com/[/url] #
# #
# #
# Based on the MOG AP System of XAS 3.91 #
# [url=http://www.xasabs.wordpress.com]http://www.xasabs.wordpress.com[/url] #
# #
# Must give credit to: Moghunter #
# #
# #
################################################################################
# #
# No Graphics needed #
# #
################################################################################
module NUKA
#Thats mean: Enemy Karma Gain
EKG = {
# A = ENEMY ID
# B = NUMBER OF KARMA POINTS
# A => B
2 => 2, # Slime, give 2 Karma Points
3 => -2 # Cogu, retire 2 Karma Points
}
#------ The HUD Settings -----#
HUD_POS = [500, 10] #The HUD position on the map
HUD_VISIBLE = 25 #The switch to disble the HUD
HUD_FADE = true
HUD_HEIGHT = 5000 #The HUD priority on screen; The HUD Height on screen
#--- Karma Points Settings ---#
KARMA_NAME = "Karma" #Pop-up display when you kill an enemy in the EKG list
KARMA_ID = 25 #The value of the Karma is stock in the variable 25
KARMA_HUD = 25
KARMA_TYPE = 1 #0 is add to the player; 1 is add to a variable; value of KARMA_ID
#-----------------------------#
end
#==============================================================================#
# #
# Karma section #
# #
#==============================================================================#
#--------------------------------------------------------------------#
# Game_Actor #
#--------------------------------------------------------------------#
class Game_Actor < Game_Battler
attr_accessor :Karma
#-----------------------#
# Setup #
#-----------------------#
alias karma_points_setup setup
def setup(actor_id)
karma_points_setup(actor_id)
@karma = 0
end
#-----------------------#
# Karma Points #
#-----------------------#
def karma
n = [[@karma, -9999999].max, 9999999].min
end
end
#--------------------------------------------------------------------#
# Game_Event #
#--------------------------------------------------------------------#
class Game_Event < Game_Character
#------------------------#
# Enemy defeat process #
#------------------------#
alias karma_edp defeat_process
def enemy_kill(enemy)
$game_party.gain_karma(enemy.karma)
karma_edp(enemy)
end
end
#--------------------------------------------------------------------#
# Game_Enemy #
#--------------------------------------------------------------------#
class Game_Enemy < Game_Battler
#-----------------------#
# Initialize #
#-----------------------#
alias karma_initialize initialize
def initialize(troop_id, member_index)
karma_initialize(troop_id, member_index)
@karma = 0
end
#-----------------------#
# Karma Points #
#-----------------------#
def karma
v = NUKA::EKG[@enemy_id]
n = v != nil ? v : v == nil ? 0 : 0
return n
end
end
#--------------------------------------------------------------------#
# Game_Party #
#--------------------------------------------------------------------#
class Game_Party
#-----------------------#
# Gain Karma #
#-----------------------#
def gain_karma(karma)
if NUKA::KARMA_TYPE == 1
$game_variables[NUKA::KARMA_ID] += karma
else
for i in 0...actor.size
actor = $game_party.actors[i]
actor.karma += karma
end #End of for
end #End of if
end #End of define
end #End of class