Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Easy "Random Troops in Battle"-Script
54tan666
post Aug 9 2011, 04:44 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 9
Type: None
RM Skill: Beginner




Functions:
- defines a "trigger"-troop which activates the script when the battle starts
- defines which troops appear when the script has been activated
- turn the script off by using switches
CODE
module ENE
Mi_Troop = {
    #Example
    1 => 3     # a => b    a = "trigger-troop"     b = the following troops which shall appear (in the example troop 1 to troop 3) *look at the picture
  }
  SwitchTroopOff = 1    #with that switch you (de)aktivate the script (false/off = script activated)
end

Attached File  Unbenannt.png ( 113.77K ) Number of downloads: 21

Copy that and paste it above main

CODE
  def setup(troop_id)
    if ENE::Mi_Troop.has_key?(troop_id) and $game_switches[ENE::SwitchTroopOff] == false
      t_id = (rand(ENE::Mi_Troop[troop_id]) + troop_id)
    else
      t_id = troop_id
    end
    # Set array of enemies who are set as troops
    @enemies = []
    troop = $data_troops[t_id]
    for i in 0...troop.members.size
      enemy = $data_enemies[troop.members[i].enemy_id]
      if enemy != nil
        @enemies.push(Game_Enemy.new(t_id, i))
      end
    end
  end


This you have to copy and replace it in Game_Troops with the method "setup(troop_id)" on line 41.


-------------------------------------------
Thats my first little selfmade "scrpt" i'm posting here and i know, my description is very bad. Thats because im from swiss and therefore im not so good in english.
Plz comment if you have any questions or you like it (or dont like it.)
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Aug 12 2011, 01:13 AM
Post #2


Level 50
Group Icon

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




Welcome to the wonderful world of scripting smile.gif

If you tweak that second section of code to:

CODE
class Game_Troops
  def setup(troop_id)
    if ENE::Mi_Troop.has_key?(troop_id) and $game_switches[ENE::SwitchTroopOff] == false
      t_id = (rand(ENE::Mi_Troop[troop_id]) + troop_id)
    else
      t_id = troop_id
    end
    # Set array of enemies who are set as troops
    @enemies = []
    troop = $data_troops[t_id]
    for i in 0...troop.members.size
      enemy = $data_enemies[troop.members[i].enemy_id]
      if enemy != nil
        @enemies.push(Game_Enemy.new(t_id, i))
      end
    end
  end
end


Then you can paste it above main, with that same bit of customisation code you have in the first codebox.

Otherwise, thanks for submitting, it looks useful smile.gif


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 01:40 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker