Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Enemy Elements, Allows enemies to have elements changing their stats.
Thallion
post Nov 14 2012, 01:28 PM
Post #1


Level 5
Group Icon

Group: Member
Posts: 68
Type: Scripter
RM Skill: Skilled
Rev Points: 10




Enemy Elements
Authors: ThallionDarkshine
Version: 0.1
Type: Enemy Stat Add-on
Key Term: Enemy Add-on


Introduction

This script adds some variety to your random battles. You can define different "elements" for enemies, each of which can change different stats such as MaxHP, MaxSP, Strength, Dexterity, and many more. Then, you can give each enemy a different set of possible "elements" that the script will randomly choose from to apply. Thus, you could make weaker enemies with the "element" of minion, as I did in the script.

Features


Spices up random battles.
You don't have to give any enemy an "element" if you don't want to.
Use an unlimited number of "elements".
Use combinations of elements.


Screenshots

You can't really capture stat changes in a screenshot.

Demo

None as of yet.

Script

Script
CODE
class Game_Enemy
  ELEMENTS = {
    :minion => [[:maxhp, -50], [:atk, -25], [:maxsp, -63], [:exp, -50], [:gold, -50]],
    :brute => [[:maxhp, 12], [:atk, 3], [:maxsp, -21], [:exp, 4], [:gold, 4], [:dex, -9], [:agi, -8], [:mdef, -14]],
  }
  
  def self.elements(id)
    return case id
           when 0 then []
           else []
           end
  end

  alias tdks_elmnt_init initialize
  def initialize(troop_id, member_index)
    tdks_elmnt_init(troop_id, member_index)
    elements = Game_Enemy.elements(@enemy_id)
    @elements = elements.length > 0 ? elements[rand(elements.length)] : nil
    @atk_mod=@pdef_mod=@mdef_mod=@str_mod=@dex_mod=@agi_mod=@int_mod=@maxhp_mod
=@maxsp_mod=@eva_mod=@exp_mod=@gold_mod=100
    @elements.each{|element|Game_Enemy::ELEMENTS[element].each{|i|instance_variable_set("@#{i[0]}_mod",i[1]+instance_variable_get("@#{i[0]}_mod"))}if Game_Enemy::ELEMENTS.keys.include?(element)}if @elements
    @hp = maxhp
    @sp = maxsp
  end
  
  def base_maxhp
    return $data_enemies[@enemy_id].maxhp * @maxhp_mod / 100
  end
  
  def base_maxsp
    return $data_enemies[@enemy_id].maxsp * @maxsp_mod / 100
  end
  
  def base_str
    return $data_enemies[@enemy_id].str * @str_mod / 100
  end
  
  def base_dex
    return $data_enemies[@enemy_id].dex * @dex_mod / 100
  end
  
  def base_agi
    return $data_enemies[@enemy_id].agi * @agi_mod / 100
  end
  
  def base_int
    return $data_enemies[@enemy_id].int * @int_mod / 100
  end
  
  def base_atk
    return $data_enemies[@enemy_id].atk * @atk_mod / 100
  end
  
  def base_pdef
    return $data_enemies[@enemy_id].pdef * @pdef_mod / 100
  end
  
  def base_mdef
    return $data_enemies[@enemy_id].mdef * @mdef_mod / 100
  end
  
  def base_eva
    return $data_enemies[@enemy_id].eva * @eva_mod / 100
  end
  
  def exp
    return $data_enemies[@enemy_id].exp * @exp_mod / 100
  end
  
  def gold
    return $data_enemies[@enemy_id].gold * @gold_mod / 100
  end
end


Instructions

To configure the script, go to the line 2.
Add any elements you want into the hash, using the format:
CODE
ELEMENT_NAME_AS_SYMBOL (that means it starts with ":") => [[STAT_NAME_AS_SYMBOL, PERCENT_CHANGE], [STAT_NAME_AS_SYMBOL, PERCENT_CHANGE]]

The different stats you can change are:
MaxHP -
CODE
:maxhp

MaxSP -
CODE
:maxsp

Strength -
CODE
:str

Dexterity -
CODE
:dex

Agility -
CODE
:agi

Intelligence -
CODE
:int

Attack -
CODE
:atk

Physical Defense -
CODE
:pdef

Magic Defence -
CODE
:mdef

Evasion -
CODE
:eva

Experience -
CODE
:exp

Gold Drop -
CODE
:gold


To make different enemies have a possibility of having different elements, go to line 7 of the script.
Add this to add a new enemy that has elements:
CODE
when ENEMY_ID then [[ELEMENT1_SET1, ELEMENT2_SET1], [ELEMENT1_SET2, ELEMENT2_SET2, ELEMENT2_SET3]]

Add as many element sets and elements as you want.

Compatibility

Probably compatible with everything except maybe enemy leveling scripts.

Credits and Thanks


ThallionDarkshine


Author's Notes

Nothing
--------------------------------------------------------------------------------

This post has been edited by Thallion: Nov 14 2012, 01:51 PM
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Jens of Zanicuud
post Nov 18 2012, 09:09 AM
Post #2


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




In practice, if you set, for example, :maxhp = -25 you are setting the monster's maxhp to 75%?
I'm not too much familiar with the instance_variable_get/set methods (to be honest, I didn't know they existed)...
Anyway, nice addon.
I feel it could be pretty useful smile.gif

To improve compatibility, you should do something like this:

CODE
#====================================================
# ** aliases
#====================================================
alias old_maxhp base_maxhp
alias old_maxsp base_maxsp
alias old_base_str base_str
alias old_base_int base_int
alias old_base_agi base_agi
alias old_base_dex base_dex
alias old_base_atk base_atk
alias old_base_pdef base_pdef
alias old_base_mdef base_mdef
alias old_base_eva base_eva
alias old_exp exp
alias old_gold gold

def base_maxhp
    return old_maxhp * @maxhp_mod / 100
  end
  
  def base_maxsp
    return old_maxsp * @maxsp_mod / 100
  end
  
  def base_str
    return old_base_str * @str_mod / 100
  end
  
  def base_dex
    return old_base_dex * @dex_mod / 100
  end
  
  def base_agi
    return old_base_agi* @agi_mod / 100
  end
  
  def base_int
    return old_base_int * @int_mod / 100
  end
  
  def base_atk
    return old_base_atk * @atk_mod / 100
  end
  
  def base_pdef
    return old_base_pdef * @pdef_mod / 100
  end
  
  def base_mdef
    return old_base_mdef * @mdef_mod / 100
  end
  
  def base_eva
    return old_base_eva * @eva_mod / 100
  end
  
  def exp
    return old_exp * @exp_mod / 100
  end
  
  def gold
    return old_gold * @gold_mod / 100
  end


If you replace the correct section of the script with this snippet, you should get rid of every compatibility issue (aliases are the most powerful ally you have while looking for compatibility).

Jens


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   

Posts in this topic


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: 21st May 2013 - 05:42 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker