Lumberjack script & Karma Script

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?

  1. ################################################################################
  2. #                            Lumberjack system                                 #
  3. #                                                                              #
  4. #    By: NuKa_BuBble                                                           #
  5. #    Version: 1.0                                                              #
  6. #    Started: 23/10/2011                                                       #
  7. #                                                                              #
  8. #    You can find me on these websites:                                        #
  9. #    http://gameface101.playogame.com/                                         #
  10. #                                                                              #
  11. #    Special thank:                                                            #
  12. #    mr_wiggles                                                                #
  13. #    G@MeF@Ce                                                                  #
  14. #                                                                              #
  15. #    *** Must give credit ***                                                  #
  16. #                                                                              #
  17. #                                                                              #
  18. ################################################################################
  19. #                                                                              #
  20. #                      Tree graphics are needed                                #
  21. #                                                                              #
  22. ################################################################################
  23. #                                                                              #
  24. #                              Instructions                                    #
  25. #                                                                              #
  26. # First, you need to learn the job. $ljob = true                               #
  27. # Second step, add in an event $ttype and a value in 1 to 10                   #
  28. # Call the script by using $game_party.perform_cut                             #
  29. # Finally, do the second step but, set the value to 0                          #
  30. #                                                                              #
  31. #                                                                              #
  32. ################################################################################
  33.  
  34.  
  35. #------------------------------------------------------------------------------#
  36. #                                                                              #
  37. #    Class Game_Party                                                          #
  38. #                                                                              #
  39. #------------------------------------------------------------------------------#
  40. class Game_Party
  41.   alias :lumbering_init :initialize
  42.   def initialize
  43.     lumbering_init
  44.     # Lumberjack level
  45.     @llvl = 1
  46.     # Lumberjack experience ponts
  47.     @lxp = 0
  48.     # Energie amount gave to player
  49.     @ener = 100
  50.     @ener_max = 100
  51.     # Check what's the tree type
  52.     $ttype = 0
  53.     # Lumberjack job is learned
  54.     $ljob = false
  55.     # The old lumberjack level
  56.     @old_llvl = 0
  57.     # Amount of experience gain when you cut a tree
  58.     @lxp_gain = 0
  59.     # Experience require to reach the next lumbering level
  60.     @n_llvl = 0
  61.     # Used to compute the energie
  62.     @a = 10
  63.     @b = 5
  64.     # Used for the next lvl xp computing
  65.     @c = 15
  66.     # Check if the player have the required level to cut the type of tree
  67.     @cctt = (@llvl / 10).ceil
  68.     # Check if the player can cut
  69.     @cc = nil
  70.     # Check if the player is equip with a lumbering weapon
  71.     @lweapon_id = [6, 7]
  72.     # The number of logs gain, the logs ID and quality when you cut a tree
  73.     @lnumber = 0
  74.     @lquality = 0
  75.     @id = 0
  76.     @lid = $data_items[@id].id
  77.     # Tree cut. Use to check if a tree was just cutted
  78.     @tcut = false
  79.   end # End of initialize method
  80.  
  81. ##########################################################################
  82. #  For any reference the variables, search them in the initialize method #
  83. ##########################################################################
  84.  
  85. #------------------------------------------------------#
  86. #                                                      #
  87. #        Check what happen when the player lvl up      #
  88. #                                                      #
  89. #------------------------------------------------------#
  90.   def check_llvl_up
  91.     if @lxp >= @n_llvl #If the xp are higher than the next llvl require xp
  92.       @llvl += 1 #lvl up
  93.       @a += 10 #Maximum energie + 10; See the energie computation before touch
  94.     end
  95.     if @old_llvl != @llvl #If your old_llvl is not equal to your llvl
  96.       next_llvl_xp_req #Call this method
  97.       compute_ener #Call this method
  98.     end
  99.     #If the llvl is located between 50 and 71, include, and if the player lvl up
  100.     if ((@llvl >= 50) && (@llvl <= 70)) && @old_llvl != @llvl
  101.       @b += 5 #Maximum energie - 5; See the energie computation before touch
  102.     end
  103.   end
  104.  
  105. #------------------------------------------------------#
  106. #                                                      #
  107. #       Check if theres any problem with the lvl       #
  108. #                                                      #
  109. #------------------------------------------------------#
  110.   def check_llvl
  111.     if @llvl < 1 #If the llvl is under 1
  112.       @llvl = 1 #Set the llvl to 1
  113.     elsif @llvl > 100 #If the llvl is higher than 100
  114.       @llvl = 100 #Set the llvl to 100
  115.     end
  116.   end
  117.    
  118. #------------------------------------------------------#
  119. #                                                      #
  120. #       Compute the xp required to lvl up again        #
  121. #                                                      #
  122. #------------------------------------------------------#
  123.   def next_llvl_xp_req
  124.     if @old_llvl != @llvl #If your precedent llvl is not equal to your llvl
  125.       @c * 1.75 #Variable C multiplied by 1.75
  126.       @llvl + @c = @n_llvl.floor #llvl + C are equal to the next lvl rounded down
  127.       @old_llvl = @llvl #Set the old level to the actual
  128.     end
  129.   end
  130.  
  131. #------------------------------------------------------#
  132. #                                                      #
  133. #           Compute the player xp gained               #
  134. #                                                      #
  135. #------------------------------------------------------#
  136.   def compute_lxp
  137.     #lnumber multiplied by lquality divided by 2
  138.     #multiplied by the ttype is equal to lxp_gain.
  139.     ((@lnumber * @lquality)/2) * $ttype = @lxp_gain
  140.     @lxp += @lxp_gain #Add the balance to your xp
  141.     @lxp_gain = 0 #Set the lxp_gain to 0
  142.     @quality = 0 #Set the quality to 0
  143.     @lnumber = 0 #Set the lnumber to 0
  144.   end
  145.  
  146. #------------------------------------------------------#
  147. #                                                      #
  148. #      Energie computation                             #
  149. #                                                      #
  150. #------------------------------------------------------#
  151.   def compute_ener
  152.     if (@llvl >= 50) && (@llvl <= 70) #If your llvl is between 50 and 70 include
  153.       @ener = (100 - b) + a #Set your energie to 100, substract B and add A
  154.     elsif @llvl >= 71 #Else if your llvl is higher than 71, include
  155.       @ener = a #Your energie equal to A; Not the original 100.
  156.     end
  157.     @max_ener = @ener #Your maximum energie is equal to your actual energie
  158.   end
  159.  
  160. #------------------------------------------------------#
  161. #                                                      #
  162. #       Define a biased distribution                   #
  163. #                                                      #
  164. #------------------------------------------------------#
  165.   def random(array)
  166.     sum = array.inject {|sum, n| sum + n}
  167.     n = rand(sum)
  168.     array.each_with_index do |i, index|
  169.     return index if n < i
  170.     n -= i
  171.     end
  172.   end
  173.  
  174. #------------------------------------------------------#
  175. #                                                      #
  176. # Define the number and the quality of the gained wood #
  177. #                                                      #
  178. #------------------------------------------------------#
  179.   def lgain
  180.   #Call the method random with a sum of 600; Split the 6 to get the purcentage
  181.     @lnumber = random([6, 12, 15, 20, 30, 517])
  182.     case @lnumber #Work on the lnumber
  183.       when 0 #If the number is the first in the list
  184.         @lnumber = 10 #Set the lnumber to 10
  185.         @lquality = 10 #Set the lquality to 10
  186.       when 1 #If the number is the second in the list
  187.         @lnumber = 5 #....
  188.         @lquality = 5 #....
  189.       when 2 #....
  190.         @lnumber = 4 #....
  191.         @lquality = 4 #....
  192.       when 3 #....
  193.         @lnumber = 3 #....
  194.         @lquality = 3 #....
  195.       when 4 #....
  196.         @lnumber = 2 #....
  197.         @lquality = 2 #....
  198.       when 5 #....
  199.         @lnumber = 1 #....
  200.         @lquality = 1.5 #....
  201.     end
  202.   end
  203.  
  204. #------------------------------------------------------#
  205. #                                                      #
  206. #  Define the condition to cut                         #
  207. #                                                      #
  208. #------------------------------------------------------#
  209.   def conditions
  210.     #If the player is equip with a lumberig weapon AND he learned the job AND
  211.     #his energie is higher than 0 AND if he can cut the tree type
  212.     if @actors[0].weapon_id == @lweapon_id
  213.       if $ljob == true
  214.         if @ener > 0
  215.           if @cctt >= $ttype
  216.             if $ttype != 0
  217.               @cc = true #The player can cut
  218.             end
  219.           end
  220.         end
  221.       end
  222.    
  223.     else
  224.       @cc = false #Else, (s)he can't cut
  225.     end
  226.   end
  227.    
  228. #------------------------------------------------------#
  229. #                                                      #
  230. #   Define if the player perform a cut                 #
  231. #                                                      #
  232. #------------------------------------------------------#
  233.   def cut
  234.     conditions #Call the conditions method
  235.     if @cc == true #If ttype is equal to 0 AND can cut
  236.       @tcut = true #The tree is cut
  237.     else
  238.       @tcut = false #Else, the tree is not cut
  239.     end
  240.   end
  241.  
  242. #------------------------------------------------------#
  243. #                                                      #
  244. #  Define what happens when you cut                    #
  245. #                                                      #
  246. #------------------------------------------------------#
  247.   def perform_cut
  248.     #Point to the self switch C
  249.     key = [$game_map.map_id, self.id, "C"]
  250.     cut #Call the cut? method
  251.       if @tcut == true #If the player can cut
  252.       $game_self_switches[key] = true #Turn the self switch on
  253.       #-------------------#
  254.         if $ttype == 1 # If tree type is equal to 1
  255.           @id = 100 # ID in the database
  256.         elsif $ttype == 2
  257.           @id = 101
  258.         elsif $ttype == 3
  259.           @id = 102
  260.         elsif $ttype == 4
  261.           @id = 103
  262.         elsif $ttype == 5
  263.           @id = 104
  264.         elsif $ttype == 6
  265.           @id = 105
  266.         elsif $ttype == 7
  267.           @id = 106
  268.         elsif $ttype == 8
  269.           @id = 107
  270.         elsif $ttype == 9
  271.           @id = 108
  272.         elsif $ttype == 10
  273.           @id = 109
  274.         end
  275.       #-------------------#
  276.       lgain #Call the lgain method
  277.       compute_lxp #Call the compute_lxp method
  278.         $game_party.gain_item(@lid, @lnumber) #The player gain the item X * number
  279.         $game_variables[20] = @llvl #The variable 20 is equal to the llvl; To display it in a text
  280.         $game_variables[21] = @lxp #...
  281.         $game_variables[22] = @ener #...
  282.         $game_variables[23] = @n_llvl #...
  283.         $game_variables[24] = @max_ener #...
  284.         @ener -= 5 #You lost 5 energie when you cut
  285.         @lnumber = 0 #Reinitialize the lnumber gain
  286.         @lquality = 0 #Reinitialize the lquality gain
  287.         @id = 0 #Reinitialize the item id; See the lid variable
  288.         $ttype = 0 #Reinitialize the tree type
  289.       @tcut = false #Turn the tree cut off
  290.       end
  291.     update #Call the update method; Very important
  292.   end
  293.  
  294. end #End of the class
Expand to see the code.


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:

  1. ################################################################################
  2. #                            Karma points system                               #
  3. #                                                                              #
  4. #   By: NuKa_BuBble                                                            #
  5. #   Version: 1.0                                                               #
  6. #   Info: I've rewrite the Moghunter Action Points Script to get a             #
  7. #   Karma Script. This one can only be use in XAS 3.91                         #
  8. #   http://gameface101.playogame.com/                                          #
  9. #                                                                              #
  10. #                                                                              #
  11. #   Based on the MOG AP System of XAS 3.91                                     #
  12. #   http://www.xasabs.wordpress.com                                            #
  13. #                                                                              #
  14. #   Must give credit to: Moghunter                                             #
  15. #                                                                              #
  16. #                                                                              #
  17. ################################################################################
  18. #                                                                              #
  19. #                        No Graphics needed                                    #
  20. #                                                                              #
  21. ################################################################################
  22.  
  23.  
  24. module NUKA
  25.  
  26. #Thats mean: Enemy Karma Gain
  27. EKG = {
  28. # A = ENEMY ID
  29. # B = NUMBER OF KARMA POINTS
  30. # A => B
  31. 2 => 2,  # Slime, give 2 Karma Points
  32. 3 => -2  # Cogu, retire 2 Karma Points
  33. }
  34. #------ The HUD Settings -----#
  35. HUD_POS = [500, 10] #The HUD position on the map
  36. HUD_VISIBLE = 25 #The switch to disble the HUD
  37. HUD_FADE = true
  38. HUD_HEIGHT = 5000 #The HUD priority on screen; The HUD Height on screen
  39. #--- Karma Points Settings ---#
  40. KARMA_NAME = "Karma" #Pop-up display when you kill an enemy in the EKG list
  41. KARMA_ID = 25 #The value of the Karma is stock in the variable 25
  42. KARMA_HUD = 25
  43. KARMA_TYPE = 1 #0 is add to the player; 1 is add to a variable; value of KARMA_ID
  44. #-----------------------------#
  45.  
  46. end
  47.  
  48. #==============================================================================#
  49. #                                                                              #
  50. #      Karma section                                                           #
  51. #                                                                              #
  52. #==============================================================================#
  53.  
  54. #--------------------------------------------------------------------#
  55. #    Game_Actor                                                      #
  56. #--------------------------------------------------------------------#
  57. class Game_Actor < Game_Battler
  58.   attr_accessor :Karma
  59.  
  60.   #-----------------------#
  61.   #         Setup         #
  62.   #-----------------------#
  63.   alias karma_points_setup setup
  64.   def setup(actor_id)
  65.     karma_points_setup(actor_id)
  66.     @karma = 0
  67.   end
  68.  
  69.   #-----------------------#
  70.   #      Karma Points     #
  71.   #-----------------------#
  72.   def karma
  73.     n = [[@karma, -9999999].max, 9999999].min
  74.   end
  75. end
  76.  
  77. #--------------------------------------------------------------------#
  78. #    Game_Event                                                      #
  79. #--------------------------------------------------------------------#
  80. class Game_Event < Game_Character
  81.  
  82.   #------------------------#
  83.   #  Enemy defeat process  #
  84.   #------------------------#
  85.   alias karma_edp defeat_process
  86.   def enemy_kill(enemy)
  87.     $game_party.gain_karma(enemy.karma)
  88.     karma_edp(enemy)
  89.   end
  90. end
  91.  
  92. #--------------------------------------------------------------------#
  93. #    Game_Enemy                                                      #
  94. #--------------------------------------------------------------------#
  95. class Game_Enemy < Game_Battler
  96.   #-----------------------#
  97.   #      Initialize       #
  98.   #-----------------------#
  99.   alias karma_initialize initialize
  100.   def initialize(troop_id, member_index)
  101.     karma_initialize(troop_id, member_index)
  102.     @karma = 0
  103.   end
  104.  
  105.   #-----------------------#
  106.   #      Karma Points     #
  107.   #-----------------------#
  108.   def karma
  109.       v = NUKA::EKG[@enemy_id]
  110.       n = v != nil ? v : v == nil ? 0 : 0
  111.       return n    
  112.     end
  113.   end
  114.  
  115. #--------------------------------------------------------------------#
  116. #    Game_Party                                                      #
  117. #--------------------------------------------------------------------#
  118. class Game_Party
  119.  
  120.   #-----------------------#
  121.   #      Gain Karma       #
  122.   #-----------------------#
  123.     def gain_karma(karma)
  124.       if NUKA::KARMA_TYPE == 1
  125.          $game_variables[NUKA::KARMA_ID] += karma
  126.       else
  127.         for i in 0...actor.size
  128.           actor = $game_party.actors[i]
  129.           actor.karma += karma
  130.         end #End of for
  131.       end #End of if
  132.     end #End of define
  133. end #End of class
Expand to see the code.
What's the problem with the scrips? What happens? Why is it not working?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75988