Preventing Battle if higher than mob level

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
I want to know if there is a way to compare highest level party member vs monster level. I have a battle setup where the mobs are on the screen. The player runs into the mob to initiate battle. I want to setup a conditional branch checking to see if the party is higher level or not. If the party level is 5 levels higher than the mob level, no fight occurs.

How can this be done? 

I am using Yanfly's Enemy Level script for mob levels. If no script is used, I'm sure a variable could be setup and set on each mob.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


What is the party level? If you have 4 members in the party, their levels could be 1, 10, 20 and 99. What is the party level?
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Since you have Yanfly's enemy levels script already, you can get the party's average level with a script call to:

$game_party.average_level

Store the result in a variable, and compare that variable to the number you wish to compare with. If it is higher, have no fight occur. Else, call battle processing and the battle occurs.
 

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
Since you have Yanfly's enemy levels script already, you can get the party's average level with a script call to:

$game_party.average_level

Store the result in a variable, and compare that variable to the number you wish to compare with. If it is higher, have no fight occur. Else, call battle processing and the battle occurs.
Very nice. Thank you. This will work perfectly, because each monster type has their own event. So I can setup individual level restrictions based on the mob. 
 
Last edited by a moderator:

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
How do I do the same thing, but for map encounters? As in map properties and battle by steps.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
That I think will take a script, and I'm not sure one such one has been written. I've attempted to start one, but I only got it as far as a cut off for each map (as in, if your average level is above a set value that you set, then no battles will occur). If that will help you I can send it your way, but if you need more you may need to make a script request for it.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
How do I do the same thing, but for map encounters? As in map properties and battle by steps.
You can use a Random Encounter Event, which allows you to run a common event when a random encounter occurs and cancel the encounter if needed.


Example video starting at 0:32
 
Last edited by a moderator:

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
Very nice. This will do the trick. Thank you!
 

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
I can't get your script to work. What am I doing wrong?

Also, will this command work "$game_troop.enemy_level" to compare against the troop level that you encounter?

-Update-

That command doesn't work. Is there a similar command I can call to check enemy level like the check party level above?

1.png

2.png

3.PNG
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
The ID that you set is not the common event that will run, it's the variable that will store the ID of the common event that will run.


So if variable 3 is currently 0, then no common event will run.


I set things up like this so dev's can have different common events run under different circumstances.


$game_troop is available when the common event runs.
 
Last edited by a moderator:

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
The ID that you set is not the common event that will run, it's the variable that will store the ID of the common event that will run.

So if variable 3 is currently 0, then no common event will run.

I set things up like this so dev's can have different common events run under different circumstances.

$game_troop is available when the common event runs.
Ok so you pretty much set the variable to = what common event ID you want to run? I set the variable 3 to = 3 on autostart and it calls the common event successfully.

Using the enemy levels script, how would I check the party's level vs the monster level? Before when I was running into the mobs on the map, I could specify level requirements based on which mob it was. For instance if mob = dragonfly then party level past lv 8 would cause the battle to not fire. How do I check this in random encounters?

If no command can be used like how you can check party lv ($game_party.average_level) can a command check against enemies inside the troop? Like $game_troop has monster ID X?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
This would suggest that each encounter will only consist of one enemy, or multiple copies of the same enemy.

$game_troop.members[0]Returns the first enemy in the troop.You can then check its ID like

Code:
$game_troop.members[0].id
 
Last edited by a moderator:

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
How do I do this with the default in game conditional branch? I can't figure it out.

I've tried:

$game_troop.members[0].id = 3

and

$game_troop.members[0] = $game_troop.members[3].id

How do I get this to work?

1.png
 
Last edited by a moderator:

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
Oops. I changed it to:

$game_troop.members[0] == $game_troop.members[3].id

and I have an encounter with the id of either 3 or 4. This doesn't fire. I have it display a message that doesn't show up. See attached pic.

What is the correct way to set this up?

1.png
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
What are you trying to do?

If you want to check whether the first enemy has ID 3 then you would say

Code:
$game_troop.members[0].id == 3
 

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
What are you trying to do?

If you want to check whether the first enemy has ID 3 then you would say

$game_troop.members[0].id == 3
I've also tried that as well. Doesn't work. Look at the picture. Am I putting the code in the right part? Clicking script in the conditional branch?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
The script requires you to set a variable in the config.


That variable needs to have a value of the common event you want to run.


Verify these are correct.
 

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
Yes, The script is firing. Everything is configured correctly. I can put a message outside of that condition and it will fire each time a encounter happens. 

So I set everything up correctly in the picture?

-=Update=-

This is the error message I am getting when trying:

$game_troop.members[0].id == 3

1.png
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Sorry, should have double-checked. Only actors can access their ID's via "id". Enemies need to use "enemy_id" for some reason.

Code:
$game_troop.members[0].enemy_id == 3
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,855
Messages
1,017,007
Members
137,563
Latest member
MinyakaAeon
Top