Published on July 7, 2011
#So far this script will return the damage value of any normal attack or specified spell utilizing formulas which contain variables(which are ever-changing stats of both the Hero and Enemies). This script serves to support, at minimum, the damage calculation, X/Y positioning, and keyboard input portions of this game. #RGSS is the scripting language used. RGSS is based on Ruby. #Hash marks(#) represent comments for the text following on that line; these lines serve only as reminders. They are #notes. class Enemy_Attributes attr_accessor :id_A # Actor ID attr_accessor :id_E # Enemy ID attr_accessor :x_E # Enemy map x-coordinate (logical) attr_accessor :y_E # Enemy map y-coordinate (logical) attr_accessor :real_x_E # Enemy map x-coordinate (real * 128) attr_accessor :real_y_E # Enemy map y-coordinate (real * 128) attr_accessor :tile_id_E # Enemy tile ID (invalid if 0) attr_accessor :character_name_E # Enemy character file name attr_accessor :character_hue_E # Enemy character hue attr_accessor :opacity_E # Enemy opacity level attr_accessor :blend_type_E # Enemy blending method attr_accessor :direction_E # Enemy direction attr_accessor :pattern_E # Enemy pattern attr_accessor :move_route_forcing_E # Enemy forced move route flag attr_accessor :through_E # Enemy through def initialize (id_E) #~~Gather's Enemy Stats~~# #-------------------------------------------------------------------------- # * Set Variable "@enemy_id" to the Attribute Reciever's value. #-------------------------------------------------------------------------- @enemy_id = id_E #-------------------------------------------------------------------------- # * Set Variable "@enemy_name" to Enemy Name #-------------------------------------------------------------------------- @enemy_name = $data_enemies[@enemy_id].name #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_maxhp" to Enemy Basic Maximum HP #-------------------------------------------------------------------------- @enemy_base_maxhp = $data_enemies[@enemy_id].maxhp #-----------------------/-8+--------------------------------------------------- # * Set Variable "@enemy_base_maxsp" to Enemy Basic Maximum SP #-------------------------------------------------------------------------- @enemy_base_maxsp = $data_enemies[@enemy_id].maxsp #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_str" to Enemy Basic Strength #-------------------------------------------------------------------------- @enemy_base_str = $data_enemies[@enemy_id].str #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_dex" to Enemy Basic Dexterity #-------------------------------------------------------------------------- @enemy_base_dex = $data_enemies[@enemy_id].dex #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_agi" to Enemy Basic Agility #-------------------------------------------------------------------------- @enemy_base_agi = $data_enemies[@enemy_id].agi #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_int" to Enemy Basic Intelligence #-------------------------------------------------------------------------- @enemy_base_int = $data_enemies[@enemy_id].int #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_atk" to Enemy Basic Attack Power #-------------------------------------------------------------------------- @enemy_base_atk = $data_enemies[@enemy_id].atk #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_pdef" to Enemy Basic Physical Defense #-------------------------------------------------------------------------- @enemy_base_pdef = $data_enemies[@enemy_id].pdef #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_mdef" to Enemy Basic Magic Defense #-------------------------------------------------------------------------- @enemy_base_mdef = $data_enemies[@enemy_id].mdef #-------------------------------------------------------------------------- # * Set Variable "@enemy_base_eva" to Enemy Basic Evasion #-------------------------------------------------------------------------- @enemy_base_eva = $data_enemies[@enemy_id].eva #Jump to "def actor_stats" method. actor_stats end def actor_stats @active_battler = 1 #-------------------------------------------------------------------------- # * Set Variable "@enemy_id" to Enemy ID #-------------------------------------------------------------------------- @active_battler_id = $game_actors[@active_battler].id #-------------------------------------------------------------------------- # * Set Variable "@enemy_name" to Enemy Name #-------------------------------------------------------------------------- @active_battler_name = $game_actors[@active_battler].name #-------------------------------------------------------------------------- # * Set Variable "@active_battler_maxhp" to Enemy Basic Maximum HP #-------------------------------------------------------------------------- @active_battler_maxhp = $game_actors[@active_battler].maxhp #-------------------------------------------------------------------------- # * Set Variable "@active_battler_maxsp" to Enemy Basic Maximum SP #-------------------------------------------------------------------------- @active_battler_maxsp = $game_actors[@active_battler].maxsp #-------------------------------------------------------------------------- # * Set Variable "@active_battler_str" to Enemy Basic Strength #-------------------------------------------------------------------------- @active_battler_str = $game_actors[@active_battler].str #-------------------------------------------------------------------------- # * Set Variable "@active_battler_dex" to Enemy Basic Dexterity #-------------------------------------------------------------------------- @active_battler_dex = $game_actors[@active_battler].dex #-------------------------------------------------------------------------- # * Set Variable "@active_battler_agi" to Enemy Basic Agility #-------------------------------------------------------------------------- @active_battler_agi = $game_actors[@active_battler].agi #-------------------------------------------------------------------------- # * Set Variable "@active_battler_int" to Enemy Basic Intelligence #-------------------------------------------------------------------------- @active_battler_int = $game_actors[@active_battler].int #-------------------------------------------------------------------------- # * Set Variable "@active_battler_atk" to Enemy Basic Attack Power #-------------------------------------------------------------------------- @active_battler_atk = $game_actors[@active_battler].atk #-------------------------------------------------------------------------- # * Set Variable "@active_battler_def" to Enemy Basic Physical Defense #-------------------------------------------------------------------------- @active_battler_pdef = $game_actors[@active_battler].pdef #-------------------------------------------------------------------------- # * Set Variable "@active_battler_mdef" to Enemy Basic Magic Defense #-------------------------------------------------------------------------- @active_battler_mdef = $game_actors[@active_battler].mdef #-------------------------------------------------------------------------- # * Set Variable "@active_battler_eva" to Enemy Basic Evasion #-------------------------------------------------------------------------- @active_battler_eva = $game_actors[@active_battler].eva input_trigger_check end #-------------------------------------------------------------------------- # * Look for Input Trigger #-------------------------------------------------------------------------- def input_trigger_check if Input.trigger?(Keys::A) @active_skill_id = 76 skill_calculate elsif Input.trigger?(Keys::S) @active_skill_id = 53 skill_calculate elsif Input.trigger?(Keys::D) @active_skill_id = 46 skill_calculate elsif Input.trigger?(Keys::SPACE) @active_skill_id = 1 crit_chance end end #-------------------------------------------------------------------------- # * Crit Chance #-------------------------------------------------------------------------- def crit_chance @normal_attacks_crit_chance = 4 * @active_battler_dex / @enemy_base_agi @skill_crit_chance = 0 @item_crit_chance = 0 random_1_100 = rand(1-100) if random_1_100 @crit = true normal_attack_calculate end end #-------------------------------------------------------------------------- # * Normal Attacks #-------------------------------------------------------------------------- def normal_attack_calculate #FORCE FORMULA - for Normal Attacks @normal_attack_force = @active_battler_atk - (@enemy_base_pdef / 2) #MULTIPLIER FORMULA - for Normal Attacks @normal_attack_multiplier = 20 + @active_battler_str #VARIANCE PERCENTAGE TO INTEGER VALUE - for Normal Attacks @normal_attack_variance = 15.0 normal_attack_damage_range end #-------------------------------------------------------------------------- # * Skills #-------------------------------------------------------------------------- def skill_calculate #Gather attributes about the skill being used; name, power, atk-f, etc. @skill_name = $data_skills[@active_skill_id].name @skill_force = $data_skills[@active_skill_id].power @skill_atk_f = $data_skills[@active_skill_id].atk_f @skill_pdef_f = $data_skills[@active_skill_id].pdef_f @skill_mdef_f = $data_skills[@active_skill_id].mdef_f @skill_str_f = $data_skills[@active_skill_id].str_f @skill_dex_f = $data_skills[@active_skill_id].dex_f @skill_agi_f = $data_skills[@active_skill_id].agi_f @skill_int_f = $data_skills[@active_skill_id].int_f @skill_variance = $data_skills[@active_skill_id].variance #MULTIPLIER FORMULA - for Skills @skill_multiplier = 20 + #Calculates the multiplier value of the skill (@active_battler_str * @skill_str_f / 100) + (@active_battler_dex * @skill_dex_f / 100) + (@active_battler_agi * @skill_agi_f / 100) + (@active_battler_int * @skill_int_f / 100) #VARIANCE PERCENTAGE VALUE- for Skills @skill_variance = @skill_variance #Damage Dealing Skill Used if @skill_force > 0 print "Used " + @skill_name #FORCE FORMULA - for Damaging Skills @skill_power = @skill_force + (@active_battler_atk * @skill_atk_f / 100) - (@enemy_base_pdef * @skill_pdef_f / 200) - (@enemy_base_mdef * @skill_mdef_f / 200) skills_damage_range #Jump to Skill Damage Calculation method #Healing Skill Used elsif @skill_force #FORCE FORMULA - for Healing Skills @skill_power = @skill_force print "Used " + @skill_name skills_healing_range #Jump to Skill Healing Calculation method #State Skill Used elsif @skill_force == 0 print "Used " + @skill_name #No value provided for Skill Used elsif @skill_force == nil print "No value provided for the skill" end end #-------------------------------------------------------------------------- # * Normal Attacks Damage Range Determination #-------------------------------------------------------------------------- def normal_attack_damage_range #FINDING THE INTEGER VALUE BASED ON THE VARIANCE PERCENTAGE - for Normal Attacks @normal_attack_variance_intiger = @normal_attack_force * @normal_attack_multiplier / 20 * (@normal_attack_variance / 100) #Determine the minimum and maximum damage range. @min_damage = @normal_attack_force * @normal_attack_multiplier / 20 - @normal_attack_variance_intiger.round @max_damage = @normal_attack_force * @normal_attack_multiplier / 20 + @normal_attack_variance_intiger.round normal_attack_final_damage end #-------------------------------------------------------------------------- # * Normal Attacks Final Damage #-------------------------------------------------------------------------- #Determine the final damage utilizing the minimum & maximum range. def normal_attack_final_damage @normal_attack_final_damage = rand(@min_damage-@max_damage)+@min_damage*2/2 print @normal_attack_final_damage.to_s end #-------------------------------------------------------------------------- # * Skills Damage Range Determination #-------------------------------------------------------------------------- def skills_damage_range end #-------------------------------------------------------------------------- # * Skills Healing Range Determination #-------------------------------------------------------------------------- def skills_healing_range #Incomplete print "healing_range" end def say # For Debugging purposes # print @enemy_name, "'s Basic Max HP = ", @enemy_base_maxhp # print @enemy_name, "'s Basic Max SP = ", @enemy_base_maxsp # print @enemy_name, "'s Basic STR = ", @enemy_base_str # print @enemy_name, "'s Basic DEX = ", @enemy_base_dex # print @enemy_name, "'s Basic AGI = ", @enemy_base_agi # print @enemy_name, "'s Basic INT = ", @enemy_base_int # print @enemy_name, "'s Basic PDEF = ", @enemy_base_pdef # print @enemy_name, "'s Basic MDEF = ", @enemy_base_mdef # print @enemy_name, "'s Basic EVA = ", @enemy_base_eva end end
The above is code that I published on July 7, 2011. The script has long since been abandoned, but hopefully you are able to judge my skill level as it was on that date, and be able to recommend to me the next step I should take as a programmer. Should I jump into C#, or do you strongly urge me to learn something more simple, first?
Among many other reasons, the one major reason I want to learn C# is to create games using XNA.