Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Dealing with Multiple Characters with Different Attributes

$
0
0
I'm trying to make a game where the characters are randomly generated and retain individual attributes over time. Right now, I'm working on the combat system. I've made it so the roles of "Attacker" and "Defender" will switch between the player character and the NPC they are fighting. Problem is, I'm unsure of how to organize it in an elegant way. All I can think of is doing a bunch of if & else statements every time I need to check. Could you suggest ways of doing this in an elegant way? If there is anything in my code that could be significantly simplified don't be afraid to point that out either. Here is an example of one of the methods I could use help with. In it, I am taking the int type variable, "overall action score", or OAS, from a tuple, which then helps to determine the force of any attacks that land. On if and else statements, I am checking who is attacking, and calling one of their respective physical attributes. def forceFinder(self): """ Determines force of strike from OAS and alacrity. """ #subtract attacker OAS from defender OAS force = self._oasTuple[0] - self._oasTuple[1] #exponentially adds to force according to alacrity and #margin between attacker, and defender OAS. for i in range(0, force, 10): force *= 1.10 if Combat._attacker == "pc": force += Combat._pcAttr["alacrity"] * 3 else: force += Combat._npcAttr["alacrity"] * 3 return int(force)

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>