Post new topic    
Enemy Scaling 
 PostSun Nov 24, 2013 6:22 pm
Send private message Reply with quote
So for my first script after my 8+ year-long sabbatical I thought I'd try and take a page from modern RPGs: Enemies level up with the player. I dropped a couple loops on the page, knocked them around for a week or so, and swore profusely at game.exe. The results are below.

A little about what this script does in particular:

The old Ctr stat, beloved by plotscript junkies everywhere, has been renamed Threat.

There are eight "elements" to represent HP, MP, Attack, Accuracy, Defense, Dodge, Magic, and Will. Each enemy's "resistance" to these elements is set to their base stats (for example, if damage from the HP element is 15%, the base stat is 15). (Side Note: My first attempt used the normal enemy stats, but unfortunately the script would stack each successive time the same enemy was encountered, ad TPK.)

Speed is not scaled due to maths; Hits and MP~ are unused.

The main loop is "EnemyScaling" and is triggered Instead of Battle.

Code:
include, plotscr.hsd

plotscript, EnemyScaling, formation, formset, begin
variable (slot)                  

for(   slot,0,7,1
   )                     
do   (if(   (FormationSlotEnemy (formation, slot))>=0
      )      
   then(   SetEnemyStats(FormationSlotEnemy(formation,slot))   
      slot += 1
      )
   else(   slot +=1)
   )
fight formation (formation)                  
end                           


script, GetThreat, begin
variable (CatCT, HeroCT, Threat)         

Threat :=0
CatCT  :=0
HeroCT :=0
                  
for (CatCT,0,4,1)
do   (if    (HeroBySlot (CatCT)>=0)      
   then    (threat+=(GetHeroStat(CatCT,9))
         CatCT+=1         
         HeroCT+=1)         
   else (CatCT+=1))
            
for(   CatCT,4,5,1
   )            
do(   (threat:=threat/HeroCT)         
   CatCT+=1
   )               

if(   CatCT>>5
   )
then(   return (threat)
   )
end

script, SetEnemyStats, EID, begin
variable (Floor, Cap, StatCT, threat, ethreat, statmod, base)

threat:=GetThreat
ethreat:=getenemystat(EID,9)
statmod :=(threat+ethreat)/2

Floor   := (statmod/4)*3
Cap   := statmod+(statmod/4)
            #Below: Enemy stats = stat base (stored as elemental resistance)
for   (StatCT,0,7,1)      #times the average of Hero Threat and Enemy Threat divided by 100

do   (
   base :=EnemyElementalResistAsInt(EID,StatCT+8)
   if (StatCT==5)
   then   (
      )
   else   (
      set enemy stat(EID,StatCT,(base+random(Floor, Cap)))
      )
   )
if   (StatCT>0)
then   (write enemy data (EID, enemy:experience, random(Floor,Cap)))
end


Basically, the script first gets the party's average Threat, then gets the average of that number and the enemy's threat, then adds the result to the enemy's base stats. Crude, but effective.

This is somewhat difficult to balance (to say the least) but seems to be working properly. Has anyone experimented with this sort of thing before? Thoughts? Advice? Glaring flaws? Input of any kind is very much appreciated!

EDIT: The comment is a lie.
DISCLAIMER: Contents may be offensive or inappropriate. Viewer discretion is advised.
Super Slime
Send private message
 
 PostSun Nov 24, 2013 6:33 pm
Send private message Reply with quote
Maybe this isn't what you're looking for, but I really have to question the purpose behind level scaling to begin with. What's the point of having either heroes or monsters level up if they're just going to both scale?
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Blubber Bloat
Send private message
 
 PostSun Nov 24, 2013 7:25 pm
Send private message Reply with quote
Mogri wrote:
Maybe this isn't what you're looking for, but I really have to question the purpose behind level scaling to begin with. What's the point of having either heroes or monsters level up if they're just going to both scale?

difficulty, more strategy introduced, perhaps a cap on enemy levels so they can't be so weak but not so strong, less grinding, and much more! Just pay shipping and handling.
dOn'T MiNd mE! i'M jUsT CoNtAgIoUs!!!
Play Orbs CCG: http://orbsccg.com/r/4r6x V
 
 PostSun Nov 24, 2013 8:14 pm
Send private message Reply with quote
Mogri wrote:
Maybe this isn't what you're looking for, but I really have to question the purpose behind level scaling to begin with. What's the point of having either heroes or monsters level up if they're just going to both scale?


I didn't want to cramp the player's ability to grind for stats, gold and craft items by limiting the amount of G and Exp in the game, but I didn't want them to be able to out-level the game, either. The enemy's threat stat is intended as a balance to the scaling effect. An enemy with 10 threat isn't going to be as difficult at level 20 as it was at level 4, but it's not going down like a chump, either. On the other end, you would really need to have your shit together at any level if you hoped to take down the optional 500 Threat boss dragon in yonder hills.

It could also potentially be used to give the player a difficulty option, either with a menu option that sets Threat or with equipments with that modify Threat, leaving enemy Threat out of it altogether. This was something I was keeping in mind as I wrote it; the math originally applied threat as a (sort of) percentage (40 Threat = Enemy stats at 40%).
DISCLAIMER: Contents may be offensive or inappropriate. Viewer discretion is advised.
Metal King Slime
Send private message
 
 PostMon Nov 25, 2013 7:34 am
Send private message Reply with quote
What I did in Legacy (well, before the complete revamp of the combat system) was to not have enemies scale, but rather to have encounters scale. Each enemy would have a certain level (CR I suppose). Going to one area while at low level (Party level is 3, for example) would do a lookup and have baddies within the CR 3 range. If you went back at a higher level, you wouldn't face the same enemies, you'd face more level appropriate enemies. That way, you're not fighting the same goblin (albeit with better stats), but you're instead first fighting a goblin, then later on an elder fire elemental or something. Still provides variety, but allows for the scaling you wanted.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Metal Slime
Send private message
 
 PostMon Nov 25, 2013 10:23 am
Send private message Reply with quote
BMR wrote:
What I did in Legacy (well, before the complete revamp of the combat system) was to not have enemies scale, but rather to have encounters scale. Each enemy would have a certain level (CR I suppose). Going to one area while at low level (Party level is 3, for example) would do a lookup and have baddies within the CR 3 range. If you went back at a higher level, you wouldn't face the same enemies, you'd face more level appropriate enemies. That way, you're not fighting the same goblin (albeit with better stats), but you're instead first fighting a goblin, then later on an elder fire elemental or something. Still provides variety, but allows for the scaling you wanted.


That sounds pretty cool. Similar concept to how battle scaling worked in SaGa Frontier, where you could run into the same monster sprite but it'd yield a stronger monster of the same race/type if you encountered it later in the game after you have higher stats.
Metal King Slime
Send private message
 
 PostMon Nov 25, 2013 3:30 pm
Send private message Reply with quote
Do not manually increment the loop counter inside a for loop. It does that automatically. Doing it manually results in it skipping over every second value, so you average hero stat calculation are broken and you're only updating every second enemy.

What is the point of the if condition in this piece of code?
Code:

if   (StatCT>0)
then   (write enemy data (EID, enemy:experience, random(Floor,Cap)))

This is outside the for loop, and at this point "StatCT>0" will always be true (in fact StatCT==8).

You've made roughly same mistake in GetThreat, writing
Code:

if(   CatCT>>5
   )
then(   return (threat)
   )

At this point CatCT is always 6, but I can see absolutely no reason to check anything before deciding to return the value.

In GetThreat, you iterate over the first 5 heroes rather than the first 4 (the end value you pass to "for" is inclusive):
Code:
for (CatCT,0,4,1)

Hero 4 is usually the first hero in the reserve party.

You follow this up with the following bizarre code:
Code:
for(   CatCT,4,5,1
   )           
do(   (threat:=threat/HeroCT)         
   CatCT+=1
   )   

I don't know why you try to divide by HeroCT twice but notice that it iterates just once because of the "CatCT+=1", so the two bugs cancel out.
This should be replaced with just "threat:=threat/HeroCT"

I recommend writing "(statmod*3)/4" instead of "(statmod/4)*3", as the later has a larger rounding error (is always a multiple of 3).

That's a creative use of elemental resistances; I'd never considered it. Your indentation is also `creative'. (And you used more parentheses than necessary.)
Liquid Metal Slime
Send private message
 
 PostTue Nov 26, 2013 6:26 am
Send private message Reply with quote
If heroes becoming so mighty from their manly exercises that they become able to treat goblins or ogres as chumps is a problem, why not just make leveling up give slower stat progression? It makes more sense than for every member of every species to be out there level-grinding at roughly the same rate as the heroes.
Remeber: God made you special and he loves you very much. Bye!
Metal King Slime
Send private message
 
 PostTue Nov 26, 2013 9:55 am
Send private message Reply with quote
Or alternatively, do away with levels altogether. You get more powerful by learning new skills, buying better equipment, etc... but not by leveling. Dunno how well that'd work though, or if it'd even work at all.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Blubber Bloat
Send private message
 
 PostTue Nov 26, 2013 5:56 pm
Send private message Reply with quote
BMR wrote:
Or alternatively, do away with levels altogether. You get more powerful by learning new skills, buying better equipment, etc... but not by leveling. Dunno how well that'd work though, or if it'd even work at all.

I've been working on something that does this for a little bit, though not majorly.
dOn'T MiNd mE! i'M jUsT CoNtAgIoUs!!!
Play Orbs CCG: http://orbsccg.com/r/4r6x V
 
 PostMon Dec 02, 2013 11:53 pm
Send private message Reply with quote
Many thanks for actually reading my sloppy mess, TMC. I just learned a lot from you.

I like a lot of the ideas being thrown out. I just might steal a couple of them.
DISCLAIMER: Contents may be offensive or inappropriate. Viewer discretion is advised.
Metal Slime
Send private message
 
 PostTue Dec 03, 2013 12:35 pm
Send private message Reply with quote
BMR wrote:
Or alternatively, do away with levels altogether. You get more powerful by learning new skills, buying better equipment, etc... but not by leveling. Dunno how well that'd work though, or if it'd even work at all.

You could also implement a way to upgrade certain bits of equipment as well. Like Relics, or something.

I don't know if being able to upgrade every single bit of equip-able gear would be a good idea, because it would take a LOT of extra work and whatnot.

I actually had this idea for that one game I was working on with the blue-haired guy in the red bandana. Never really got the chance to bring it up until seeing this.
"One can never improve enough nor should one stop trying to improve."
Metal Slime
Send private message
 
 PostTue Dec 03, 2013 1:32 pm
Send private message Reply with quote
My game, Silhouette, does not have levels.

However, it's so short right now that it doesn't feel like an RPG quite yet.

I should really getting around to testing and uploading what I've done since last year.
Display posts from previous: