Simple Combat Script

This is a simple combat script that can be plugged and played where needed.

code

*create istwohanded 0

*comment 1 means yes and 0 means no

*create twohandedmin 0

*comment how much do two handed weapons not minus from sheild def

*create baseatk 5
*create basedef 5
*create atkdmg 0
*create minatk 2
*create tempdefwep 0
*create tempdef 0

*comment player armor

*create weaponatk 0
*create weapondef 0
*create sheilddef 0
*comment armor
*create headdef 0
*create bodydef 0
*create armsdef 0
*create legsdef 0

*comment enemy armor

*create enweaponatk 0
*create enweapondef 0
*create ensheilddef 0
*comment armor
*create enheaddef 0
*create enbodydef 0
*create enarmsdef 0
*create enlegsdef 0

*comment all under are for random body part hit chance
*create hhu 0
*comment head hit chance up 1 yes 0 no
*create ranbodypart 0
*create headdmg 10
*create bodydmg 0
*create armsdmg 0
*create legsdmg 0

*create bodyhit 0
*create tempbdp 0
*create counter 0
*comment battle code

*rand ranbodypart 1 4
*set tempbdp 0
*if (hhu = 1)
*rand ranbodypart 1 5
*if (ranbodypart = 1)
*set tempbdp + headdmg
*set counter 1
*elseif (ranbodypart = 2)
*set tempbdp + headdmg
*set counter 1
*elseif (ranbodypart = 3)
*set tempbdp + armsdmg
*set counter 2
*elseif (ranbodypart = 4)
*set tempbdp + legsdmg
*set counter 3
*elseif (ranbodypart = 5)
*set tempbdp + bodydmg
*set counter 4
*if (hhu = 0)
*if (ranbodypart = 1)
*set tempbdp + headdmg
*set counter 1
*elseif (ranbodypart = 2)
*set tempbdp + armsdmg
*set counter 2
*elseif (ranbodypart = 3)
*set tempbdp + legsdmg
*set counter 3
*elseif (ranbodypart = 4)
*set tempbdp + bodydmg
*set counter 4

*if (istwohanded = 1)
*set tempdef 0
*comment simple reset of the stat
*set tempdef + twohandedmin - sheilddef

*if (sheilddef > 0)
*set tempdefwep 0
*set tempdefwep + (enweapondef - (sheilddef - 2))

*if (counter = 1)
*set bodyhit + (tempbdp - headdef)
*elseif (counter = 2)
*set bodyhit + (tempbdp - armsdef)
*elseif (counter = 3)
*set bodyhit + (tempbdp - legsdef)
*elseif (counter = 4)
*set bodyhit + (tempbdp - bodydef)
*set bodyhit - basedef
*if (bodyhit < 0)
*set bodyhit 0

*set atkdmg + ((baseatk - basedef) + ((weaponatk - tempdefwep) + (ensheilddef + tempdef)))
*set atkdmg + bodyhit
*if (atkdmg < 0)
*set atkdmg 0
*set atkdmg + minatk
*set Hp - atkdmg

1 Like

There is a coding button you can click so it posts your indentions.

It looks like this:
</>

Highlight you code and hit that button to save your indents. Your code as is, is very hard to read.

*create istwohanded 0

*comment 1 means yes and 0 means no

*create twohandedmin 0

*comment how much do two handed weapons not minus from sheild def 

*create baseatk 5
*create basedef 5
*create atkdmg 0
*create minatk 2
*create tempdefwep 0
*create tempdef 0

*comment player armor

*create weaponatk 0
*create weapondef 0
*create sheilddef 0
*comment armor
*create headdef 0
*create bodydef 0
*create armsdef 0
*create legsdef 0

*comment enemy armor

*create enweaponatk 0
*create enweapondef 0
*create ensheilddef 0
*comment armor
*create enheaddef 0
*create enbodydef 0
*create enarmsdef 0
*create enlegsdef 0

*comment all under are for random body part hit chance
*create hhu 0
*comment head hit chance up 1 yes 0 no
*create ranbodypart 0
*create headdmg 10
*create bodydmg 0
*create armsdmg 0
*create legsdmg 0

*create bodyhit 0
*create tempbdp 0
*create counter 0
*comment battle code

*rand ranbodypart 1 4
*set tempbdp 0
*if (hhu = 1)
	*rand ranbodypart 1 5
	*if (ranbodypart = 1)
		*set tempbdp + headdmg
		*set counter 1
	*elseif (ranbodypart = 2)
		*set tempbdp + headdmg
		*set counter 1
	*elseif (ranbodypart = 3)
		*set tempbdp + armsdmg
		*set counter 2
	*elseif (ranbodypart = 4)
		*set tempbdp + legsdmg
		*set counter 3
	*elseif (ranbodypart = 5)
		*set tempbdp + bodydmg
		*set counter 4
*if (hhu = 0)
	*if (ranbodypart = 1)
		*set tempbdp + headdmg
		*set counter 1
	*elseif (ranbodypart = 2)
		*set tempbdp + armsdmg
		*set counter 2
	*elseif (ranbodypart = 3)
		*set tempbdp + legsdmg
		*set counter 3
	*elseif (ranbodypart = 4)
		*set tempbdp + bodydmg
		*set counter 4

*if (istwohanded = 1)
	*set tempdef 0
	*comment simple reset of the stat
	*set tempdef + twohandedmin - sheilddef 
	
*if (sheilddef > 0)
	*set tempdefwep 0
	*set tempdefwep + (enweapondef - (sheilddef - 2))

*if (counter = 1) 
	*set bodyhit + (tempbdp - headdef)
*elseif (counter = 2)
	*set bodyhit + (tempbdp - armsdef)
*elseif (counter = 3)
	*set bodyhit + (tempbdp - legsdef)
*elseif (counter = 4)
	*set bodyhit + (tempbdp - bodydef)
*set bodyhit - basedef
*if (bodyhit < 0)
	*set bodyhit 0
	
*set atkdmg + ((baseatk - basedef) + ((weaponatk - tempdefwep) + (ensheilddef + tempdef)))
*set atkdmg + bodyhit
*if (atkdmg < 0)
	*set atkdmg 0
	*set atkdmg + minatk
*set Hp - atkdmgi