TGC Codebase Backup



Arena by yuri_dragon 17

30th Jun 2007 23:42
Summary

A 2D arena game I am working on.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    start:
restore info
rem set up program
randomize timer()
hide mouse
x=0
class$=""
q=0
w=0
e=0
r=0
print "STATS PROGRAM"
print "PUSH KEY TO START"
wait key
cls

rem info
info:

rem # of creatures/monsters/races
data 6
elf:
data "Elf",10,6,7,8
troll:
data "Troll",3,9,10,10
human:
data "Human",7,7,7,7
dwarf:
data "Dwarf",5,10,7,10
goblin:
data "Goblin",10,4,10,5
zombie:
data "Zombie",6,10,10,4
rem speed,health,stamina,strength

rem stats
read x
for a=1 to x
read class$
read q
read w
read e
read r
Print class$;" -  Speed: ";q;";  Health: ";w;";  Stamina: ";e;";  Strength: ";r
print "Total -  ";q+w+e+r
print
if b=10
b=0
wait key
cls
endif
inc b
next a
print
print "Speed-succeding in attack or defense; Strength-defense; Stamina-attack"
wait key

`read class
print "Pick a class"
input a$
restore elf
if a$="deity" then restore deity
if a$="elf" then restore elf
if a$="dwarf" then restore dwarf
if a$="zombie" then restore zombie
if a$="human" then restore human
if a$="troll" then restore troll
if a$="goblin" then restore goblin

read class$
read speed
read health
read stamina
read strength

health=health*10

`check for 'an' or 'a'
if left$(class$,1)="A" or left$(class$,1)="E" or left$(class$,1)="I" or left$(class$,1)="O" or left$(class$,1)="U"
	print "You are an ";class$
else
	print "You are a ";class$
endif
wait key

`core
cls
do
gosub find_opponent
	do
		print "BATTLE"
		print

		if left$(class$,1)="A" or left$(class$,1)="E" or left$(class$,1)="I" or left$(class$,1)="O" or left$(class$,1)="U"
			print "You are an ";class$
		else
			print "You are a ";class$
		endif

		print
		if ohealth=0
			print "YOU WON!!!"
			wait key
			exit
		endif

		if ohealth<0
			print "YOU WON!!!"
			wait key
			exit
		endif

		gosub their_action
	if class$="deity" then health=99999999
		if health=0
			print "YOU DIED!!!"
			wait key
			exit
		endif

		if health<0
			print "YOU DIED!!!"
			wait key
			exit
		endif
		print "Your health is ";health
		print "Block: ";speed+strength+35; "% chance of blocking"
		print "Attack: ";speed+stamina+35; "% chance of hitting"
		print
		print "Their health is ";ohealth
		print "Opponent: ";oclass$
		print ospeed+ostamina+35; "% chance of hitting you"
		print ospeed+ostrength+35; "% chance of blocking your attack"
		print
		print "What is your choice of action?"
		print
		input ac$

		gosub your_action

		if ohealth=0
			print "YOU WON!!!"
			wait key
			exit
		endif

		if ohealth<0
			print "YOU WON!!!"
			wait key
			exit
		endif

		gosub their_action
	if class$="deity" then health=99999999
		if health=0
			print "YOU DIED!!!"
			wait key
			exit
		endif

		if health<0
			print "YOU DIED!!!"
			wait key
			exit
		endif

		gosub determine_combat


		wait key



		cls
	loop
cls
if health<0 then exit
loop

gosub start

`subroutines

find_opponent:

	a=rnd(5)+1
	if a=1 then oa$="elf"
	if a=2 then oa$="zombie"
	if a=3 then oa$="troll"
	if a=4 then oa$="dwarf"
	if a=5 then oa$="human"
	if a=6 then oa$="goblin"

	if oa$="elf" then restore elf
	if oa$="dwarf" then restore dwarf
	if oa$="zombie" then restore zombie
	if oa$="human" then restore human
	if oa$="troll" then restore troll
	if oa$="goblin" then restore goblin

	read oclass$
	read ospeed
	read ohealth
	read ostamina
	read ostrength

	ohealth=ohealth*10

return


your_action:

	if ac$="block"
		rand=rnd(99)+1
		if rand >speed+strength+35 then suc=0
		if rand=<speed+strength+35 then suc=1
	endif

	if ac$="attack"
		rand=rnd(99)+1
		if rand >speed+stamina+35 then suc=0
		if rand=<speed+stamina+35 then suc=1
	endif

return



their_action:

	wtd=rnd(1)

	if wtd=1
		rand=rnd(99)+1
		if rand <ospeed+ostrength then osuc=0
		if rand=>ospeed+ostrength then osuc=1
	endif

	if wtd=0
		rand=rnd(99)+1
		if rand <ospeed+ostamina then osuc=0
		if rand=>ospeed+ostamina then osuc=1
	endif

return



determine_combat:

`you

if ac$="attack" and suc=1 and wtd=0
	extra=rnd(4)
	if class$="deity" then extra=extra*2
	print "You hit ";strength+extra;" damage on the ";oclass$;"!"
	dec ohealth,strength+extra
endif

if ac$="attack" and suc=0
	print "You missed the ";oclass$;"!"
endif

if ac$="attack" and suc=1 and wtd=1 and osuc=0
	extra=rnd(4)
	if class$="deity" then extra=extra*2
	print "The ";oclass$;" tried to block, but you hit ";strength+extra;" damage on the ";oclass$;"!"
	dec ohealth,strength+extra
endif

if ac$="attack" and suc=1 and wtd=1 and osuc=1
	print "The ";oclass$;" blocked your attack!"
endif

`them

if wtd=0 and osuc=1 and ac$="attack"
	extra=rnd(4)
	print "The ";oclass$;" hit ";ostrength+extra;" damage on you!"
	dec health,ostrength+extra
endif

if wtd=0 and osuc=0
	print "The ";oclass$;" missed you!"
endif

if wtd=0 and osuc=1 and ac$="block" and suc=0
	extra=rnd(4)
	print "You tried to block, but the ";oclass$;" hit ";ostrength+extra;" damage on you!"
	dec health,ostrength+extra
endif

if wtd=0 and osuc=1 and ac$="block" and suc=1
	print "You blocked the ";oclass$;"'s attack!"
endif

return


deity:
rem speed,health,stamina,strength
data "Deity",25,99999999,25,25