Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
NuKa_BuBble

Need help for woodcutting script

Question

1. I always get an error to this script.

2. I need a script part that can call this script.

3. I think something'll not work in the script (The self-switch).

4. If you see something'll not work, say me what :alright:

 

Someone can check for that?

 

 

################################################################################
#                            Wood cutting system                               #
#                                                                              #
#    By: NuKa_BuBble                                                           #
#    Version: 1.0                                                              #
#    Started: 29/08/2011                                                       #
#                                                                              #
#    You can find me on these websites:                                        #
#    http://gameface101.playogame.com/                                         #
#    http://www.rmxpunlimited.net                                              #
#                                                                              #
#                                                                              #
################################################################################
#                                                                              #
#                        No Graphics needed                                    #
#                                                                              #
################################################################################
#                                                                              #
#                              Instructions                                    #
#                                                                              #
#                  In an event, add this part of script                        #
#                      if the player learned the job                           #
#                        $wc_job_learn = true                                  #
#                                                                              #
#                        Call the script with                                  #
#                          $Woodcutting.new                                    #
#                                                                              #
################################################################################



#------------------------------------------------------------------------------#
#------------------------------- NUKA module ----------------------------------#
#------------------------------------------------------------------------------#

   module NUKA
#-------------Self Switch------------------------------------------------------#
     SELF_SWITCH = $game_self_switches
#-------------Woodcutting Stats------------------------------------------------#
     woodcutting_exp = 0
     woodcutting_level = 1
     energie_rem = 100
#-------------Other------------------------------------------------------------#
   can_gain_wc_exp = true
   $wc_job_learn = false

   end

#------------------------------------------------------------------------------#
#---------------------------- End of the module -------------------------------#
#------------------------------------------------------------------------------#




#------------------------------------------------------------------------------#
#-------------------------- Class Woodcutting ---------------------------------#
#------------------------------------------------------------------------------#
class Woodcutting

#------------------------------------------------------------------------------#
#                              Initialize                                      #
#------------------------------------------------------------------------------#
   def initialize
     @logs_number = 0

     @logs_ID = $game_party.actors[0].item_id

     @old_wc_lvl = 1
     @wc_xp_gain
     @wc_next_lvl
     @i = 15
     @random = false

   # If the logs type = to "A",
   #the amount of gain xp is multiplied by the logs number and divided by 2.
     @logs_type = {10, 5, 4, 3, 2, 1.5}
     @logs_type = 0
     logs_type_random = @logs_type

   # cctt means "Can cut tree type"
   # DO NOT TOUCH THIS PART OF CODE!
   # Set the tree type that can be cut in the "CASE BLOCK"
   @cctt = 1

    tree_type = {
   #(Value = tree_type) => item_ID
   #The value is use for the xp multiplication
   #Here, you add different type of tree for different logs.
     1 => 100,
     2 => 101,
     3 => 102,
     4 => 103,
     5 => 104,
     6 => 105,
     7 => 106,
     8 => 107,
     9 => 108,
     10 => 109
     }
     a = 10
     b = 5
     @can_cut = nil
#-------------The tools for woodcutting----------------------------------------#
     WOODCUTTING_WPN_ID 
     [6, 7]

   end #end of define "initialize"

#------------------------------------------------------------------------------#
#------Define woodcutting stats------------------------------------------------#
#------------------------------------------------------------------------------#

   #define the tree type
   def tree_type
   v = tree_type[@logs_ID]
   n = v != nil ? v : 0
   return n
   end

   #define the woodcutting lvl
   def woodcutting_lvl
     NUKA::woodcutting_level = woodcutting_lvl
     woodcutting_lvl = 1
   end

   #define the woodcutting xp
   def woodcutting_exp
     NUKA::woodcutting_exp = woodcutting_xp
     woodcutting_xp = 0
   end

   #define the woodcutting energie
   def energie_rem
     NUKA::energie_rem = energie_rem
     energie_rem = 100
   end

   def energie
       if woodcutting_lvl > 1
         if energie_rem > 100 + a
         energie_rem = 100 + a
         elsif energie_rem < 0
         energie_rem = 0
         end

         if woodcutting_lvl >= 50
         energie_rem = (100 - b) + a
         elsif woodcutting_lvl > 70
         energie_rem = a
         end

     elsif woodcutting_lvl == 1
       energie_rem = 100
       if energie_rem < 0
       energie_rem = 0
       end
     end
   end

#------------------------------------------------------------------------------#
#-----Define if the player can cut---------------------------------------------#
#------------------------------------------------------------------------------#

 def can_cut
# returns the result of the weapon equal to the correct id AND job_learn 
# AND energie_rem greater than 0 AND cctt is greater or equal to tree_type
# if ALL of these are TRUE, the result is TRUE, and therefore the player can_cut
 return ($game_party.actors[0].weapon_id == WOODCUTTING_WPN_ID && $wc_job_learn && energie_rem > 0 && @cctt >= tree_type)

 end #end of define "can_cut"

   def help
     if @can_cut == false
         if ($game_party.actors[0].weapon_id == WOODCUTTING_WPN_ID) == false
           print "You need to be equip with a woodcutting weapon."
         end

         if $wc_job_learn == false
           print "You've not learned the job."
         end

         if energie_rem == 0
           print "You don't have enought energie."
         end

         if (@cctt >= tree_type) == false
           print "You don't have the woodcutting level."
         end
       end
   end

#------------------------------------------------------------------------------#
#-----Define what appens if the player perform an action-----------------------#
#------------------------------------------------------------------------------#
   def cut_tree
     if cut_tree == true
       if NUKA::SELF_SWITCH["C"] != true
       NUKA::SELF_SWITCH[key] = "C"
       $game_party.actors[0].item_id = @logs_ID
       cut_tree = false
       end
     end
   end


#------------------------------------------------------------------------------#
#----Define the woodcutting lvl------------------------------------------------#
#------------------------------------------------------------------------------#

#----Compute the XP gain-------------------------------------------------------#
   def compute_wc_xp
    ((@logs_number * @logs_type_random)/2) * tree_type = @wc_xp_gain
    woodcutting_xp += @wc_xp_gain
    @wc_xp_gain = 0
    @logs_type = 0
    @logs_number = 0
   end
#----Compute the next lvl------------------------------------------------------#

   def wc_next_lvl
     if @old_wc_lvl != woodcutting_lvl
     @i * 1.75
       woodcutting_lvl + @i = @wc_next_lvl.integer
     end
   end
#----Compute the user lvl------------------------------------------------------#

   def comp_woodcutting_lvl
     if woodcutting_xp >= @wc_next_level
       woodcutting_lvl += 1
       a += 10
        if woodcutting_lvl >= 50 && woodcutting_lvl <= 71
         b += 5
       end
     end

     if @old_wc_lvl != woodcutting_lvl
       @old_wc_lvl = woodcutting_lvl
     end

   end # end of define comp_woodcutting_lvl

   def conditions

#---If the woodcutting lvl is between 1 and 100, ------------------------------#
#---you can gain woodcutting experience----------------------------------------#
       if woodcutting_lvl < 100 && woodcutting_lvl >= 1
         can_gain_wc_exp = true
       else
         return false
       end

#----If the woodcutting lvl is less or equal 0, set it to 1--------------------#
#----Else if the woodcutting lvl is more than to 100, set it to 100------------#
       if woodcutting_lvl <= 0
         woodcutting_lvl = 1
       elsif woodcutting_lvl > 100
         woodcutting_lvl = 100
       end
   end # end of define conditions method
#------------------------------------------------------------------------------#
#----Define what appens if the player lvl is equal to X------------------------#
#------------------------------------------------------------------------------#
def weighted_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

 if @random == true
   def gain
     if woodcutting_lvl >= 1 && woodcutting_lvl < 20
     @logs_number + (rand(10) + 1)
      $game_party.gain_item(tree_type, @log_number) 

     elsif woodcutting_lvl >= 20 && woodcutting_lvl < 40
     @logs_number + (rand(10) + 2)
      $game_party.gain_item(tree_type, @log_number) 

     elsif woodcutting_lvl >= 40 && woodcutting_lvl < 60
     @logs_number + (rand(10) + 3)
      $game_party.gain_item(tree_type, @log_number) 

     elsif woodcutting_lvl >= 60 && woodcutting_lvl < 80
     @logs_number + (rand(10) + 4)
      $game_party.gain_item(tree_type, @log_number) 

     elsif woodcutting_lvl >= 80 && woodcutting_lvl <= 100
     @logs_number + (rand(10) + 5)
      $game_party.gain_item(tree_type, @log_number) 
     end
   end # end of method gain

   def logs_type_random
     i = weighted_random([6, 12, 15, 20, 30, 517])
       case i
       when 0
         return 10
       when 1
         return 5
       when 2
         return 4
       when 3
         return 3
       when 4
         return 2
       when 5
         return 1.5
       end
     end
 end # end of method logs_type
   @random = false
 end # end of if @random
#-----------------------------CASE BLOCK---------------------------------------#
   if @can_cut == true
     # If the player woodcutting level is 1 to 9...
   case woodcutting_lvl
     when 1..9
     @cctt = 1
     cut_tree = true
     @random = true

     when 10..19
     @cctt = 2
     cut_tree = true
     @random = true

     when 20..29
     @cctt = 3
     cut_tree = true
     @random = true

     when 30..39
     @cctt = 4
     cut_tree = true
     @random = true

     when 40..49
     @cctt = 5
     cut_tree = true
     @random = true

     when 50..59
     @cctt = 6
     cut_tree = true
     @random = true

     when 60..69
     @cctt = 7
     cut_tree = true
     @random = true

     when 70..79
     @cctt = 8
     cut_tree = true
     @random = true

     when 80..89
     @cctt = 9
     cut_tree = true
     @random = true

     when 90..100
     @cctt = 10
     cut_tree = true
     @random = true
     end

   end #end of the if statement

#------------------------------------------------------------------------------#
#-----------------------End of the block and class-----------------------------#
#------------------------------------------------------------------------------#
end #class woodcutting end
$woodcutting = Woodcutting.new

 

 

 

This the most recent error.

646319Woodcutting.png

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...