Categories
development infernusrpg

Adding combat system to infernusrpg

The design of the classes for the combat system is as follows:

-library/Stats.gd: stores the constants of the strength,dexterity,hp and speed for each enemy or for the player.

const SPEED: int = 100
const STRENGTH: int = 1
const DEXTERITY: int = 3
const HP: int = 10

-library/Combat.gd: make the calculations for the attack and for roll a dice

func roll(number:int ,type:int  )->int:           
	var acc=0
	for x in range(0,number):                    
		acc += _rng.randi_range(1,type)                 
	return acc

-sprites/Script.gd: it serves to store some instance variables of each sprite

var ar:int
var dr:int
var hp:int

func _init():
	ar=_new_PCStats.STRENGTH/4
	dr=_new_PCStats.DEXTERITY*4
	
	hp=_new_PCStats.HP

-scenes/main/PCAttack and scenes/main/EnemyAttack make the calls to the combat system

_new_Combat.attack(_pc,enemy)

infernusrpg is a rpg turn-based demo game or prototype made in godot. you can download the source code at https://github.com/blockcha1n444/infernusrpg

screenshoot
screenshoot

Leave a Reply

Your email address will not be published. Required fields are marked *