Jump to content


Photo

Programming Issues


  • Please log in to reply
5 replies to this topic

#1 Serkai

Serkai

    Corporal

  • Members
  • 57 posts

Posted 31 January 2012 - 02:53 PM

Uuh, right.

So I'm trying to create an equation for the exp system in this game I'm programming but can't really seem to get it to work. I was hoping I could maybe get some help on it if I post the basic structure here. Thanks for your time.

Each combat has a base experience value equal to the average level of the enemy party x300. That value is then increased or decreased by 20% for each monster in the enemy party more or less than the number of characters in the player party.
Ex: Two Goblins (Lv1) attack the main character (Lv1). The goblins have an average level of 1 which gives 300 experience. Since they are 2 vs 1 the exp value is increased by 20% for a total value of 360 exp.
This would be the monster part of the experience calculation. Next is the player part which starts with a compare between monster party average level and player party average level and applies a possitive or negative modifier of 20% for each level that differs between the two averages.
Ex: Lets say that the player was second level in the previous example. If such was the case, the players level would reduce the value by 20% while the number of opponents would increase it by 20%. These effects cancel eachother out which results in an unmodded basevalue of 300 experience points.
Ex2: Lets instead say that the monsters were Kobolds (Lv2). That would give a base experience of 600 which is increased by 20% due to the difference between participants in the two opposing parties. Since the monster party is one level higher than the player party, the value is once again increased by 20% for a total increase of 40% (and a total value of 840).
Lastly I want the increase/decrease values (the 20% parts in both number of participants and level difference) to stop at 100%. I don't want high-level characters gaining any experience from grinding extremely low-level monsters nor do I want low-level characters to get near-infinite experience from battling high-level monsters.

And that's that. If anyone has any idea of how I make this into a mathematical equation (or even better if anyone knows how to program a system like this) please do let me know.

#2 FaithoftheFallen

FaithoftheFallen

    Hikikomori

  • Members
  • 85 posts

Posted 05 February 2012 - 08:53 AM

It really varies with the programming language you use, but it looks like a set of if-else statements could capture that.

Just a heads-up though, I've never programmed any games or the like before and this is just all noob theory and might create unexpected overhead or other effects lol

variable averageMonsterLevel
variable playerLevel
varaible playerPartyMemberCount
variable monsterPartyMemberCount
variable exp //amount of exp earned by player, changes with each individual battle
variable levelDifference
variable memberDifference (difference in number of enemy and player party members)
final variable baseExp = 300

// the following set of statements should run at the end of each battle
levelDifference = averageMonsterLevel - playerLevel
if levelDifference > 5, levelDifference = 5 //sets max levelDifference to 5, which in
if levelDifference < -5, levelDifference = -5 //turn caps exp modifier to 100%

memberDifference = monsterPartyMemberCount - playerPartyMemberCount

//calculates exp
exp = (averageMonsterLevel * baseExp) * (1 + (memberDifference + levelDifference) * 0.2)
//note: this assumes your programming language follows the order of operations and calculates multiplication before addition, which I think all should do

*insert code here to give the newly calculated exp to player*

===example===
4x lvl 2 monsters appear and the player party has 2 people at lvl 3
Plugging it into the equation gives this:
exp = (averageMonsterLevel * baseExp) * (1 + (memberDifference + levelDifference) * 0.2)
exp = (2 * 300) * (1 + (2 + -1) * 0.2)
exp = (600) * (1 + 1 * 0.2)
exp = (600) * (1 + 0.2)
exp = (600) * (1.2)
exp = 720


Hopefully this gives you an idea, but your best bet would be to go to actual programming forums and ask for tips there :P

I can help identify and locate h anime. I can also do small translations. Ask if you need anything :)

 

hime_siggy1.jpg


#3 ero-jiji

ero-jiji

    Lieutenant

  • Super Donator
  • 338 posts

Posted 05 February 2012 - 10:35 PM

what are you writing the game engine in?

#4 Serkai

Serkai

    Corporal

  • Members
  • 57 posts

Posted 06 February 2012 - 12:46 PM

Well, I'm trying to make it using RenPy (google it) and Python, but since my skills in python-speak are somewhat lacking I find it hard to do.
I've also considdered using UDK (Unread Developement Kit) but it seems somewhat messy and way more complicated than what my weak little mind can handle.

#5 ero-jiji

ero-jiji

    Lieutenant

  • Super Donator
  • 338 posts

Posted 06 February 2012 - 01:54 PM

the guy that does my game hacking/dumping for tl/mod projects works extensively with python, i sent him a link to this thread, hopefully he can help ya out =3

#6 Serkai

Serkai

    Corporal

  • Members
  • 57 posts

Posted 06 February 2012 - 11:03 PM

That would be amazing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users