RPGVX.net

  RPG-Maker VX => VX Skripte [Fertiger Code] => Thema gestartet von: Kyoshiro am Februar 01, 2009, 15:43:19

Titel: Auto Enemy Setup
Beitrag von: Kyoshiro am Februar 01, 2009, 15:43:19
Ich treibe mich ja auch auf einer ganzen Reihe VX-Seiten rum und dort habe ich dieses nette Script gefunden, dass es einfacher macht Gegner zu machen, da sie den Helden in der Gruppe angepasst werden.

Auto Enemy Setup V 2.5
autor: Snowy Shooting Star or aka snstar2006

=begin
================================================================================
How to use:
1. Setting of enemy level

type this in the memo space for enemy

[level n]

e.g.: [level 25]
where n is the level of the enemy

2. Evemy level is the same as that of the players

type this in the memo space for enemy

[player_level]

the enemy level is calculated with avg party level

3. Enemy level is hi-er or lo-er

type this in the memo space for enemy

[strength X]

e.g.: [strength weaker]
X is the string set in the hash below, you can change it urself.

when this flag is set only by itself, the strength is calculated with
party avg level. If it is used with level flag, then the strength is
calculated with the set level.
kindly refer to the example below.

4. Enemy type
type this in the memo space for enemy

[type X]

e.g.: [type wizard]
X is the type set in the hash below, you can change it urself.

5. Experience Coefficient
EXPERIENCE is for the setting of common enemies
0.1 means that the exp earned is tenth of the avg needed exp
for next level of the entire party
BOSS_EXP is for Boss enemies
3 means to multiply by 3 after calculating exp pts.

6. How to set the Hash?
ENEMY_TYPE hash
the string part is the type, change it all you want
the number part is the code, DO NOT CHANGE IT

STRENGTH hash
the string part is the strength name
the number part is the difference to the avg party level

e.g. "weaker" => -3

means when an enemy is set to be "weaker", the level of the enemy is
avg party level -3

Example:
character 1 level 3
character 2 level 4
character 3 level 8
character 4 level 6
enemy 1 is set to be [strength weaker]
enemy 2 is set to be [strength string] [level 1]

the the level of enemy 1 is
(3+4+8+6)/4 = 5.25 <= round to int 5
5 - 2 = 3 <= enemy level 3

the the level of enemy 2 is
1 + 3 = 4 <= enemy level 4

just note that when level is less than or equal to 0,
it will be automatically corrected to 1
If a key cannot be found in hash, then by default the enemy will
be set to be same of the avg party level

Miscenllaneous Recommendation:
I suggest you use the level flag to create normal enemies
by setting (fake) absolute level, enemies that remain weak even when
the party level has raised.

Boss enemies can be directly be set to be Boss type, yet its stats will be
kinda uncharacterized, if for eg you want to make a wizard type boss,
then you can use the method stated below:

Use the second and strength flag or the player level flag
by setting relative level enemies that grow as the players grow.
when strength is set as weak, although they are still weak enemies,
their HP, MP, EXP will still increase as the players grow.

How to overwrite database:
set WRITE_2_DATABASE to true
create any event on map and call the function (by script command)

make_enemy_database

cloas RMVX (without saving) and reopen
then back to the script editor and set WRITE_2_DATABASE to false
to avoid any misoperation.

=end

# Settings:
module Auto_Enemy

# Chose whether to overwrite database data
WRITE_2_DATABASE = false

# Experience Coefficient
EXPERIENCE = 0.1
BOSS_EXP = 3

# strength of the enemies
STRENGTH = {
"weaker" => -3,
"weak" => -2,
"same" => 1,
"strong" => 2,
"stronger" => 3,
"default" => 0 # DO NOT CHANGE THIS LINE !!!
}

# set the types of the enemies
ENEMY_TYPE = {
"Normal" => 0, # Normal enemies, use avg level to calculate
"Warrier" => 1, # Warrior type enemies, higher physical atk
"Wizard" => 2, # Wizard type enemies, higher magical atk
"Priest" => 3, # Priest type enemies, higher magic pts
"Mage" => 4, # Magician type enemies, higher hit ratio
"Giant" => 5, # Giant type enemies, higher HP and def
"Boss" => 6, # Boss type enemies, increase in all stats
"Random" => -1, # Random, increase in 1~1.99 times
"default" => 0 # DO NOT CHANGE THIS LINE, THIS IS FOR DEFAULT
}

end

class Game_Party
def avg_number(number, level=nil)
average = 0
for i in @actors
actor = level ? $data_actors[i] : $game_actors[i]
case number
when "level"
average += $game_actors[i].level
when "exp"
average += $game_actors[i].next_exp_s
when "hp"
if level
average += actor.parameters[0, level]
else
average += actor.maxhp
end
when "mp"
if level
average += actor.parameters[1, level]
else
average += actor.maxmp
end
when "atk"
if level
average += actor.parameters[2, level]
else
average += actor.atk
end
when "def"
if level
average += actor.parameters[3, level]
else
average += actor.def
end
when "spi"
if level
average += actor.parameters[4, level]
else
average += actor.spi
end
when "agi"
if level
average += actor.parameters[5, level]
else
average += actor.agi
end
when "hit"
average += $game_actors[i].hit
when "eva"
average += $game_actors[i].eva
end
end
average /= members.size
return average
end

def avg_level
return avg_number("level")
end

def avg_exp_needed
return avg_number("exp")
end

def avg_hp_max(level=nil)
return avg_number("hp", level)
end

def avg_mp_max(level=nil)
return avg_number("mp", level)
end

def avg_atk(level=nil)
return avg_number("atk", level)
end

def avg_def(level=nil)
return avg_number("def", level)
end

def avg_spi(level=nil)
return avg_number("spi", level)
end

def avg_agi(level=nil)
return avg_number("agi", level)
end

def avg_hit
return avg_number("hit")
end

def avg_eva
return avg_number("eva")
end
end

class RPG::Enemy
# Get Level of the enemy
def get_level
self.note.split(/[\r\n]+/).each { |line|
if line =~ /\[(level|??|??) \d+\]/
a = line.split(/ /)[1]
d = ""
while ((c = a.slice!(/./m)) != nil)
d += c if c != "]"
end
return d.to_i
elsif line =~ /\[player_level|????|????\]/
return $game_party.avg_level
end
}
return nil
end

# Get strength of the enemy
def get_str
self.note.split(/[\r\n]+/).each { |line|
if line =~ /\[(strength|??|??) \w+\]/ #
a = line.split(/ /)[1]
d = ""
while ((c = a.slice!(/./m)) != nil)
d += c if c != "]"
end
return d
end
}
return "default"
end

def get_enemy_type
self.note.split(/[\r\n]+/).each { |line|
if line =~ /\[(type|??|??) \w+\]/ #
a = line.split(/ /)[1]
d = ""
while ((c = a.slice!(/./m)) != nil)
d += c if c != "]"
end
return d
end
}
return "default"
end

# Calculate level
def level
if auto_level?
if auto_str?
return [get_level + str, 1].max
else
return get_level
end
elsif auto_str?
level = ($game_party.avg_level + str)
return [level, 1].max
end
end

def str
estr = Auto_Enemy::STRENGTH[get_str]
if estr != nil
return estr
else
return Auto_Enemy::STRENGTH["default"]
end
end

def type
if $enemies_class != nil
return $enemies_class[@enemy_id]
else
return Auto_Enemy::ENEMY_TYPE[get_enemy_type]
end
end

def auto_level?
return get_level
end
def auto_str?
return get_str
end
end

#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
def base_maxhp
if enemy.auto_level?
enemy_maxhp = $game_party.avg_hp_max(enemy.level)
case enemy.type
when 1
enemy_maxhp *= 1.5
when 2
enemy_maxhp *= 0.75
when 3
enemy_maxhp *= 0.75
when 4
enemy_maxhp *= 0.8
when 5
enemy_maxhp *= 2
when 6
enemy_maxhp *= 4
when -1
enemy_maxhp *= (1 + rand(0))
end
return enemy_maxhp.to_i
else
return enemy.maxhp
end
end
#--------------------------------------------------------------------------
# * Get basic Maximum MP
#--------------------------------------------------------------------------
def base_maxmp
if enemy.auto_level?
enemy_maxmp = $game_party.avg_mp_max(enemy.level)
case enemy.type
when 1
enemy_maxmp *= 0.75
when 2
enemy_maxmp *= 1.5
when 3
enemy_maxmp *= 3
when 4
enemy_maxmp *= 1.4
when 5
enemy_maxmp *= 1.1
when 6
enemy_maxmp *= 4
when -1
enemy_maxmp *= (1 + rand(0))
end
return enemy_maxmp.to_i
else
return enemy.maxmp
end
end
#--------------------------------------------------------------------------
# * Get Basic Attack
#--------------------------------------------------------------------------
def base_atk
if enemy.auto_level?
enemy_atk = $game_party.avg_atk(enemy.level)
case enemy.type
when 1
enemy_atk *= 2
when 2
enemy_atk *= 0.75
when 3
enemy_atk *= 0.5
when 4
enemy_atk *= 0.6
when 5
enemy_atk *= 1.1
when 6
enemy_atk *= 4
when -1
enemy_atk *= (1 + rand(0))
end
return enemy_atk.to_i
else
return enemy.atk
end
end
#--------------------------------------------------------------------------
# * Get Basic Defense
#--------------------------------------------------------------------------
def base_def
if enemy.auto_level?
enemy_def = $game_party.avg_def(enemy.level)
case enemy.type
when 1
enemy_def *= 1.25
when 2
enemy_def *= 0.5
when 3
enemy_def *= 0.75
when 4
enemy_def *= 0.7
when 5
enemy_def *= 3
when 6
enemy_def *= 4
when -1
enemy_def *= (1 + rand(0))
end
return enemy_def.to_i
else
return enemy.def
end
end
#--------------------------------------------------------------------------
# * Get Basic Spirit
#--------------------------------------------------------------------------
def base_spi
if enemy.auto_level?
enemy_spi = $game_party.avg_spi(enemy.level)
case enemy.type
when 1
enemy_spi *= 0.1
when 2
enemy_spi *= 2
when 3
enemy_spi *= 1.75
when 4
enemy_spi *= 1.5
when 5
enemy_spi *= 0
when 6
enemy_spi *= 4
when -1
enemy_spi *= (1 + rand(0))
end
return enemy_spi.to_i
else
return enemy.spi
end
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
if enemy.auto_level?
enemy_agi = $game_party.avg_agi(enemy.level)
case enemy.type
when 1
enemy_agi *= 1.2
when 2
enemy_agi *= 2
when 3
enemy_agi *= 0.8
when 4
enemy_agi *= 1.1
when 5
enemy_agi *= 0.2
when 6
enemy_agi *= 2
when -1
enemy_agi *= (1 + rand(0))
end
return enemy_agi.to_i
else
return enemy.agi
end
end
#--------------------------------------------------------------------------
# * Get Hit Rate
#--------------------------------------------------------------------------
def hit
if enemy.auto_level?
enemy_hit = $game_party.avg_hit
case enemy.type
when 1
enemy_hit *= 1.3
when 2
enemy_hit *= 1.1
when 3
enemy_hit *= 1.5
when 4
enemy_hit *= 1.8
when 5
enemy_hit *= 1
when 6
enemy_hit = 95
when -1
enemy_hit *= (1 + rand(0))
end
return [[enemy_hit.to_i, 95].min, 0].max
else
return enemy.hit
end
end
#--------------------------------------------------------------------------
# * Get Evasion Rate
#--------------------------------------------------------------------------
def eva
if enemy.auto_level?
enemy_eva = $game_party.avg_eva
case enemy.type
when 1
enemy_eva *= 1
when 2
enemy_eva *= 1
when 3
enemy_eva *= 0.9
when 4
enemy_eva *= 1.1
when 5
enemy_eva *= 0
when 6
enemy_eva = 95
when -1
enemy_eva *= (1 + rand(0))
end
return [[enemy_eva.to_i, 95].min, 0].max
else
return enemy.eva
end
end
#--------------------------------------------------------------------------
# * Get Experience
#--------------------------------------------------------------------------
def exp
if enemy.auto_level?
exp = ($game_party.avg_exp_needed * Auto_Enemy::EXPERIENCE).to_i
if enemy.type == 6
return exp *= Auto_Enemy::BOSS_EXP
else
return exp
end
else
return enemy.exp
end
end
end

class Game_Interpreter
def make_enemy_database
for i in 1...$data_enemies.size
game_enemy = Game_Enemy.new(1, i)
if $data_enemies[i].auto_level?
$data_enemies[i].maxhp = $game_party.avg_hp_max($data_enemies[i].level)
$data_enemies[i].maxmp = game_enemy.base_maxmp
$data_enemies[i].atk = game_enemy.base_atk
$data_enemies[i].def = game_enemy.base_def
$data_enemies[i].spi = game_enemy.base_spi
$data_enemies[i].agi = game_enemy.base_agi
$data_enemies[i].hit = game_enemy.hit
$data_enemies[i].eva = game_enemy.eva
$data_enemies[i].exp = game_enemy.exp
end
end
save_data($data_enemies,"Data/Enemies.rvdata") if Auto_Enemy::WRITE_2_DATABASE
end
end


Wie man das Script einbaut und die Gegner erstellt steht alles im Script selber bei den Notizen.

Bei Fragen oder Problemen wendet ihr euch bitte an den Ersteller, den ihr hier (http://www.rpgmakervx.net/index.php?showtopic=1364) kontaktieren könnt. Ich habe das Script lediglich rausgesucht.

Kyoshiro
Titel: Re: Auto Enemy Setup
Beitrag von: MarcoMario am Februar 06, 2009, 21:02:14
Hört sich ja ganz gut an, aber ich steig' da nicht so ganz durch, kannst du mir folgende Funktionen bitte genauer erklären:

Wie kann ich machen, dass das Monster dasselbe Level wie der Durchschnitt der Truppe hat?
Wie kann ich machen, dass das Monster immer ein paar Level höher ist?
Und was ist mit dem Boss-Modus oder so ähnlich gemeint?
Titel: Re: Auto Enemy Setup
Beitrag von: Shinji am Februar 06, 2009, 21:57:22
schreib das was da im kopf des scriptes steht in die
notes von deinen enemies.

hab grad kb den ganzen text zu übersetzen...
Titel: Re: Auto Enemy Setup
Beitrag von: Sk!p am Februar 07, 2009, 10:52:51
Also der Boss-Modus scheint mir offensichtlich zu sein,.

Rein hypotethisch hat ein Endboss immer einen gewissen Level übder der Helden Gruppe.
Es ist ja n Bos und kein Map Enemy.

Dementsprechend denke ich, dass im Boss-Modus das Lefel des Mob's automatisch einen gewissen
Wert übder die Atati und Level der Helden gesetzt wird, damit der Schwierigkeitsgrad angepasst wird.
Das ist reeine Spekulation, ich habe mir das Skript nicht angesehen ^^

Sk!p
Titel: Re: Auto Enemy Setup
Beitrag von: Onkel Hell am Februar 09, 2009, 08:05:05
ich hab mal aufgeräumt,
das war genug sinnlose diskussion darüber ob jemand englisch kann oder nich
~hell

edit : jetz nochma für ALLE, ich will in diesem thread keinen spam mehr sehen sondern konstruktives
Titel: Re: Auto Enemy Setup
Beitrag von: xelawebdev am März 11, 2009, 13:57:15
Gelöscht
Titel: Re: Auto Enemy Setup
Beitrag von: Prince am März 11, 2009, 16:14:48
Muss man das per call script oder comment machen???

MfG
Titel: Re: Auto Enemy Setup
Beitrag von: Ðeity am März 11, 2009, 17:23:46
Die ersten Zeilen sind die Beschreibung für die Anwendung des Scriptes.
Du muss die Befehle in die Memo von den einzelnen Gegnern schreiben.
Hier die Beschreibung auf Englisch:
=begin
================================================================================
How to use:
1. Setting of enemy level

type this in the memo space for enemy

[level n]

e.g.: [level 25]
where n is the level of the enemy

2. Evemy level is the same as that of the players

type this in the memo space for enemy

[player_level]

the enemy level is calculated with avg party level

3. Enemy level is hi-er or lo-er

type this in the memo space for enemy

[strength X]

e.g.: [strength weaker]
X is the string set in the hash below, you can change it urself.

when this flag is set only by itself, the strength is calculated with
party avg level. If it is used with level flag, then the strength is
calculated with the set level.
kindly refer to the example below.

4. Enemy type
type this in the memo space for enemy

[type X]

e.g.: [type wizard]
X is the type set in the hash below, you can change it urself.

5. Experience Coefficient
EXPERIENCE is for the setting of common enemies
0.1 means that the exp earned is tenth of the avg needed exp
for next level of the entire party
BOSS_EXP is for Boss enemies
3 means to multiply by 3 after calculating exp pts.

6. How to set the Hash?
ENEMY_TYPE hash
the string part is the type, change it all you want
the number part is the code, DO NOT CHANGE IT

STRENGTH hash
the string part is the strength name
the number part is the difference to the avg party level

e.g. "weaker" => -3

means when an enemy is set to be "weaker", the level of the enemy is
avg party level -3

Example:
character 1 level 3
character 2 level 4
character 3 level 8
character 4 level 6
enemy 1 is set to be [strength weaker]
enemy 2 is set to be [strength string] [level 1]

the the level of enemy 1 is
(3+4+8+6)/4 = 5.25 <= round to int 5
5 - 2 = 3 <= enemy level 3

the the level of enemy 2 is
1 + 3 = 4 <= enemy level 4

just note that when level is less than or equal to 0,
it will be automatically corrected to 1
If a key cannot be found in hash, then by default the enemy will
be set to be same of the avg party level

Miscenllaneous Recommendation:
I suggest you use the level flag to create normal enemies
by setting (fake) absolute level, enemies that remain weak even when
the party level has raised.

Boss enemies can be directly be set to be Boss type, yet its stats will be
kinda uncharacterized, if for eg you want to make a wizard type boss,
then you can use the method stated below:

Use the second and strength flag or the player level flag
by setting relative level enemies that grow as the players grow.
when strength is set as weak, although they are still weak enemies,
their HP, MP, EXP will still increase as the players grow.

How to overwrite database:
set WRITE_2_DATABASE to true
create any event on map and call the function (by script command)

make_enemy_database

cloas RMVX (without saving) and reopen
then back to the script editor and set WRITE_2_DATABASE to false
to avoid any misoperation.

=end
MfG

Deity
Titel: Re: Auto Enemy Setup
Beitrag von: xelawebdev am März 11, 2009, 17:27:11
Gelöscht
Titel: Re: Auto Enemy Setup
Beitrag von: Prince am März 11, 2009, 17:55:11
Die ersten Zeilen sind die Beschreibung für die Anwendung des Scriptes.
Du muss die Befehle in die Memo von den einzelnen Gegnern schreiben.
Hier die Beschreibung auf Englisch:
=begin
================================================================================
How to use:
1. Setting of enemy level

type this in the memo space for enemy

[level n]

e.g.: [level 25]
where n is the level of the enemy

2. Evemy level is the same as that of the players

type this in the memo space for enemy

[player_level]

the enemy level is calculated with avg party level

3. Enemy level is hi-er or lo-er

type this in the memo space for enemy

[strength X]

e.g.: [strength weaker]
X is the string set in the hash below, you can change it urself.

when this flag is set only by itself, the strength is calculated with
party avg level. If it is used with level flag, then the strength is
calculated with the set level.
kindly refer to the example below.

4. Enemy type
type this in the memo space for enemy

[type X]

e.g.: [type wizard]
X is the type set in the hash below, you can change it urself.

5. Experience Coefficient
EXPERIENCE is for the setting of common enemies
0.1 means that the exp earned is tenth of the avg needed exp
for next level of the entire party
BOSS_EXP is for Boss enemies
3 means to multiply by 3 after calculating exp pts.

6. How to set the Hash?
ENEMY_TYPE hash
the string part is the type, change it all you want
the number part is the code, DO NOT CHANGE IT

STRENGTH hash
the string part is the strength name
the number part is the difference to the avg party level

e.g. "weaker" => -3

means when an enemy is set to be "weaker", the level of the enemy is
avg party level -3

Example:
character 1 level 3
character 2 level 4
character 3 level 8
character 4 level 6
enemy 1 is set to be [strength weaker]
enemy 2 is set to be [strength string] [level 1]

the the level of enemy 1 is
(3+4+8+6)/4 = 5.25 <= round to int 5
5 - 2 = 3 <= enemy level 3

the the level of enemy 2 is
1 + 3 = 4 <= enemy level 4

just note that when level is less than or equal to 0,
it will be automatically corrected to 1
If a key cannot be found in hash, then by default the enemy will
be set to be same of the avg party level

Miscenllaneous Recommendation:
I suggest you use the level flag to create normal enemies
by setting (fake) absolute level, enemies that remain weak even when
the party level has raised.

Boss enemies can be directly be set to be Boss type, yet its stats will be
kinda uncharacterized, if for eg you want to make a wizard type boss,
then you can use the method stated below:

Use the second and strength flag or the player level flag
by setting relative level enemies that grow as the players grow.
when strength is set as weak, although they are still weak enemies,
their HP, MP, EXP will still increase as the players grow.

How to overwrite database:
set WRITE_2_DATABASE to true
create any event on map and call the function (by script command)

make_enemy_database

cloas RMVX (without saving) and reopen
then back to the script editor and set WRITE_2_DATABASE to false
to avoid any misoperation.

=end
MfG

Deity

In die Note rechts beim Gegner???
Titel: Re: Auto Enemy Setup
Beitrag von: Ðeity am März 11, 2009, 18:06:53
Ya genau, das was unten rechts ist und meistens leer^^

MfG
Deity
SimplePortal 2.3.3 © 2008-2010, SimplePortal