The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: Legacy on July 07, 2007, 10:35:44 PM

Title: Spliting EXP [RESOLVED]
Post by: Legacy on July 07, 2007, 10:35:44 PM
Normally the game runs it so even if you four people they all get the same amount of EXP. i want it so that it rewards doing it with less living people at the end of the battle (so going solo gives more exp, but if you have 4  ppl in your party, you only give 1/4 to each player). Is there a script or something that can do that? ;8
Title: Re: Spliting EXP
Post by: modern algebra on July 08, 2007, 01:11:05 AM
Yeah, easy. Just got to Scene_Battle 2 in the editor, go to somewhere around line 172 (inside method: start_phase5) and replace this line:

actor.exp += exp

with this:

actor.exp += exp/$game_party.actors.size

The entire start_phase5 method should look like this:

def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp/$game_party.actors.size
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end
Title: Re: Spliting EXP
Post by: Legacy on July 08, 2007, 05:04:04 AM
NICE! thx i've been looking for that for a while. You wouldn't happen to know how to add and remove party members (Manually by the player so they can choose to fight alone, with a certain party structure...ect.) but not only out of battle but in battle too.
Title: Re: Spliting EXP [RESOLVED]
Post by: Rune on July 08, 2007, 12:47:57 PM
This shoulda been in the scripts forum in my opinion :-\
Title: [RESOLVED] Re: Spliting EXP
Post by: modern algebra on July 08, 2007, 01:30:56 PM
Errm... that's true, but he probably didn't know it's best done by a script.

As for your second question, you'd need a script. It doesn't seem too difficult. I suggest you make a request in the Simple Script Shop (http://rmrk.net/index.php/topic,17670.0.html). If they refuse you, then I might be able to do it, but it'd probably be a little on the later side, as my list of things to do before it is:


In any case, it'd be a minimum of two weeks before I could get on it, so ask the nice people at the Script Shop
Title: Re: Spliting EXP [RESOLVED]
Post by: Rune on July 08, 2007, 01:56:00 PM
:-\ I dont think i'd be able to do that :-\

Maybe NAM could but dont get your hopes up too high
Title: Re: Spliting EXP [RESOLVED]
Post by: modern algebra on July 08, 2007, 04:52:11 PM
I think you could. It is essentially just a switch. You'd probably just need to set up a dummy array which holds all the actors, and use comparison between that and $game_party to draw the list. If you need to find how to add and remove members through scripts, check out the interpreter class and see how it is done.
Title: Re: Spliting EXP [RESOLVED]
Post by: Rune on July 08, 2007, 05:32:56 PM
...
help...

I dont know what half the stuff there is :tpg:
Title: Re: Spliting EXP [RESOLVED]
Post by: modern algebra on July 08, 2007, 07:18:51 PM
well, that would kind of be awkward anyway, so I'll tell you. To add an actor, just do this:

$game_party.add_actor (actor id)

and to remove:

$game_party.remove_actor (actor id)

So now, all you have to do is preserve the original $game_party.actors in an array (this is probably the most difficult part of the script, surprisingly), and then provide a selection based on this array (so the names of all in the party), and what occurs when you select each name can essentially be reduced to a comparison:

if actor in $game_party.actors, remove, if actor not in $game_party.actors, add.

That'd be my idea at least. You might need to adjust his menu script a little to switch dependence from $game_party.actors to your new array. If you decide to do it and run into any problems, don't hesitate to ask for advice.
Title: Re: Spliting EXP [RESOLVED]
Post by: Rune on July 08, 2007, 07:42:41 PM
I still dont understand much :-\