Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Level Averager, Avergages levels :)
Night5h4d3
post Oct 27 2008, 07:18 AM
Post #1


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Disclamer, please take the time to read
This is just a little script I made at the request of someone, it wasnt supposed to be released
until that someone was almost finished with the game it was going with...
(sorry, but i need to make my RGSS skills known)
Perhaps you've played a RPG such as Final Fantasy: Tactics Advance, you might of noticed that
the people that want to join your party are the average level as your party, well, this script does
just that. smile.gif
I ask that you DO NOT DISTRIBUTE THIS TO OTHER SITES WITHOUT MY PERMISION, AS I WILL BE POSTING IT TO SOME SOON.
Don't forget to give credit! happy.gif


Important notes on the script
- THIS SCRIPT IS NOT TESTED WITH SDK OR MACL

- This script was made by me, and it basicly modifies game_actor, if you see someone with another name
than Enix2, Efever2, post this script, let me know.

- I am currently working on another script that will work with this script, so when it's out, (and if you want to use it)
place it above this script, set your first switch on, to change which switch it looks for, find if $game_switches[1] == true

and set the number in the brackets to your desired switch

- dont set $USE_ADVANCED_NAMES to true UNLESS you have the other script

- This script modifies Game_Actor

- THIS SCRIPT HAS NOT BEEN TESTED WITH A LARGE PARTY SCRIPT, BUT IF YOU WANT ME TO MAKE IT COMPATABLE WITH ONE, LET ME KNOW OF

THE LARGE PARTY SCRIPT AND I'LL TRY

Setup

1) PLACE ANYWHERE ABOVE MAIN AND BELOW OTHER CUSTOM SCRIPTS

2) to activate, turn the switch on (switch number is in [] on line 59 of the script)

3) to use this script, the switch must be on. make an event that adds a party member, and make sure 'initialize' is checked.

(screenshot1)

How It Works
If you have 2 party members, and want to add a third using this system, it takes the level of the first, and the second party

member, adds those 2 numbers together, and divides by the current party size,(Eg: P1 is level 19, and P2 is level 40, 19+40=59;

59/2 = 29.5)in the example i chose numbers that result in a floating average(has a decimal point) its good to note that RGSS

ALLWAYS, i repeat, ALLWAYS ROUNDS DOWN, it doesnt matter if the result is 29.999999999 RMXP will ALLWAYS return 29.
Here's a clearer example:
Arshes lv 10
Basil lv 18
Gloria lv 37

Total lv 65
(3 party mebers, so divide by 3)
Average lv 21.66666667
Rounded lv 21

Gloria lv 21

ScreenShots
only the one telling you how to use it, kinda hard to display this script :0


Level Averager

# Level Averager
# Writen by Enix2
# 09/20/08
# v. 5.7
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
if $USE_ADVANCED_NAMES == true
Advanced_Name_Generator.new
@name = $Name
else
@name = actor.name
end
@character_name = actor.character_name
@character_hue = actor.character_hue
@battler_name = actor.battler_name
@battler_hue = actor.battler_hue
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
if $game_switches[1] == true
if $game_party.actors.size == 1
actor1 = $game_party.actors[0]
actor_level1 = actor1.level
$addition_one = actor_level1
$END_RESULT = $addition_one / 1
@level = $END_RESULT
elsif $game_party.actors.size == 2
actor1 = $game_party.actors[0]
actor_level1 = actor1.level
actor2 = $game_party.actors[1]
actor_level2 = actor2.level
$addition_two = actor_level1 + actor_level2
$END_RESULT = $addition_two / 2
@level = $END_RESULT
elsif $game_party.actors.size == 3
actor1 = $game_party.actors[0]
actor_level1 = actor1.level
actor2 = $game_party.actors[1]
actor_level2 = actor2.level
$addition_two = actor_level1 + actor_level2
actor3 = $game_party.actors[2]
actor_level3 = actor3.level
$addition_three = $addition_two + actor_level3
$END_RESULT = $addition_three / 3
@level = $END_RESULT
else
@level = actor.initial_level
end
else
@level = actor.initial_level
end
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
@hp = maxhp
@sp = maxsp
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
# Learn skill
for i in 1..@level
for j in $data_classes[@class_id].learnings
if j.level == i
learn_skill(j.skill_id)
end
end
end
# Update auto state
update_auto_state(nil, $data_armors[@armor1_id])
update_auto_state(nil, $data_armors[@armor2_id])
update_auto_state(nil, $data_armors[@armor3_id])
update_auto_state(nil, $data_armors[@armor4_id])
end
end


Demo, for those of you who dont want to copy/paste scripts
http://files.filefront.com/Level+Averager+...;/fileinfo.html

Bugs
there are currently no known bugs that havent been resolved, If you find a bug, post it to the site at which you
found this script, if i dont reply within 2 weeks, then i did not post that script, and i am asking that you
report that topic, because I specificly said not to distribute it without my permission.

EDIT- only the script within the spoiler will be cut down


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies (1 - 8)
BigEd781
post Oct 27 2008, 09:13 AM
Post #2


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




There is a whole lot of unnecessary code in there. This will cause compatibility problems with other scripts because you don't alias any methods and redefine many. I would strip out all the cruft and just add what you need in order for the script to work.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Oct 27 2008, 09:48 AM
Post #3


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Thanks for the notice biged, i was going to do that but forgot all about it, i've fixed it within the spoilers, but i'm too lazy to fix it in the demo and re-upload it thumbsup.gif


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Blizzard
post Oct 28 2008, 04:25 AM
Post #4


Where am I?
Group Icon

Group: Revolutionary
Posts: 613
Type: Scripter
RM Skill: Masterful




That is... a joke script, right?



Mine works actually way better since it takes the average EXP amount (Sydon is initially level 1, BTW). =/ I will never understand why people create scripts for things that can be done with events so easily. Or they could post at least a very short script.

CODE
EXP_OFF = 1

class Game_Actor
  
  alias setup_exp_divider_later setup
  def setup(actor_id)
    setup_exp_divider_later(actor_id)
    return if $game_switches[EXP_OFF]
    exp = 0
    $game_party.actors.each {|actor| exp += actor.exp}
    self.exp += exp / $game_party.actors.size
  end
  
end


__________________________


Please keep in mind that I have retired from RMXP and that I am not active here anymore! If you can't get any support for my scripts here, try at Chaos Project.
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Oct 28 2008, 08:45 AM
Post #5


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




While that may be true, you have to know how many people are in the party at that time, this script was also created as a kindof 'plug-and-play' keeping the amounts of events to a minimum, in-turn, allowing for faster processing.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Blizzard
post Oct 28 2008, 10:07 AM
Post #6


Where am I?
Group Icon

Group: Revolutionary
Posts: 613
Type: Scripter
RM Skill: Masterful




I agree with the plug-and-play argument (even though you can do something similar with a common event since you can assign the number of party members to a variable with one event command, not script call command), but the script code I gave does the same thing in way less lines. It's also compatible with any other script that modifies Game_Actor (presuming the other script aliases Game_Actor#setup or is below it), any number of party members (aka any party size), SDK, MACL and Blizz-ABS. I don't even see any reason that it shouldn't work with that custom script you made for names without any change of the code.


__________________________


Please keep in mind that I have retired from RMXP and that I am not active here anymore! If you can't get any support for my scripts here, try at Chaos Project.
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Oct 28 2008, 11:00 AM
Post #7


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




okay, i see your point, and i'm not gonna argue which way is the best, i threw this script together late at night thinking that it would help people who wanted to create games w/ the mercenary system like that of FF:TA.
(BTW: blizzard, do you know much about win32 api scripts? i was hoping to stretch my rgss knowledge out of the ruby boundaries)


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Blizzard
post Oct 28 2008, 12:09 PM
Post #8


Where am I?
Group Icon

Group: Revolutionary
Posts: 613
Type: Scripter
RM Skill: Masterful




Sure, no problem. Feel free to integrate that code in your script if you want. smile.gif

WinAPI is pretty much generic. You just need to know how to call a dll's functions and that's already it. Example:

CODE
state = Win32API.new('user32', 'GetKeyState', ['i'], 'i')
state.call(1)


This would call "user32.dll", the function "GetKeyState" getting one argument as integer and returning an integer. When you use the second statement that function will be actually called. It's like a wrapper. You create an instance of an object that has a method defined which is called with "call(arguments)". As I said, it's very simple. If I remember right, l is used for "long" variables, p for "pointers" and c for "characters", but I'm not entirely sure, I always have to look it up each time since I rarely use it. When I do something in a different language, I usually use the same language to call the dll. i.e. C++ created dll in another C++ program or a C# program, etc.


__________________________


Please keep in mind that I have retired from RMXP and that I am not active here anymore! If you can't get any support for my scripts here, try at Chaos Project.
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Oct 28 2008, 02:54 PM
Post #9


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




thanks a bunch, i slightly understand C++, but win32 api escaped me (why Bill? WHY!?!)


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 08:13 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker