The QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 
 

 Return to Index  

RPG With Spell Problems

July 23 2002 at 12:52 PM
  (Login Guy_Smilie)

 
DECLARE SUB battle ()

DIM SHARED HP AS INTEGER
DIM SHARED MaxHPAS INTEGER
DIM SHARED MP AS INTEGER
DIM SHARED MaxMPAS INTEGER
DIM SHARED Strength AS INTEGER
DIM SHARED DefenseAS INTEGER
DIM SHARED Experience AS LONG
DIM SHARED RequiredExperience AS LONG
DIM SHARED Gold AS LONG
DIM SHARED LevelAS INTEGER
DIM SHARED Weapon AS STRING
DIM SHARED ArmorAS STRING
DIM SHARED Shield AS STRING
DIM SHARED BootsAS STRING
DIM SHARED Gloves AS STRING
DIM SHARED ArmorDefense AS INTEGER
DIM SHARED WeaponDamage AS INTEGER
DIM SHARED MaxSpell AS INTEGER
DIM SHARED spell$(MaxSpell)
DIM SHARED EnemyNameAS STRING
DIM SHARED EnemyHPAS INTEGER
DIM SHARED EnemyMPAS INTEGER
DIM SHARED EnemyStrengthAS INTEGER
DIM SHARED EnemyWeaponDamageAS INTEGER
DIM SHARED EnemyDefense AS INTEGER
DIM SHARED EnemyExperienceAS INTEGER
DIM SHARED EnemyGoldAS INTEGER
DIM SHARED EnemyWeaponAS STRING
DIM SHARED MaxEnemyHP AS INTEGER
DIM SHARED MaxEnemyMP AS INTEGER

CONST true = -1, false = 0

HP = 25
MaxHP = 25
MP = 10
MaxMP = 10
MaxSpell = 5
Strength = 5
Defense = 1
Experience = 0
RequiredExperience = 100
Gold = 100
Level = 1
Weapon = "Fists"
Armor = "None"
Shield = "None"
Boots = "None"
Gloves = "None"

IF Armor = "None" THEN
Ar = 0
ELSEIF Armor = "Grass Armor" THEN
Ar = 1
ELSEIF Armor = "Chain Mail" THEN
Ar = 5
ELSEIF Armor = "Tin Breast Plate" THEN
Ar = 7
ELSEIF Armor = "Breast Plate" THEN
Ar = 10
ELSEIF Armor = "Full Body Armor" THEN
Ar = 15
ELSEIF Armor = "Force Field" THEN
Ar = 20
ELSEIF Armor = "Force Field of Defense" THEN
Ar = 25
ELSEIF Armor = "Gods Force Field" THEN
Ar = 40
END IF

IF Shield = "None" THEN
S = 0
ELSEIF Shield = "Grass Shield" THEN
S = 1
ELSEIF Shield = "Small Wooden Shield" THEN
S = 2
ELSEIF Shield = "Large Wooden Shield" THEN
S = 3
ELSEIF Shield = "Small Tin Shield" THEN
S = 4
ELSEIF Shield = "Large Tin Shield" THEN
S = 5
ELSEIF Shield = "Force Shield" THEN
S = 6
ELSEIF Shield = "Gods Shield" THEN
S = 10
END IF

IF Boots = "None" THEN
B = 0
ELSEIF Boots = "Rag Boots" THEN
B = 1
ELSEIF Boots = "Leather Boots" THEN
B = 2
ELSEIF Boots = "Heavy Boots" THEN
B = 3
END IF

IF Gloves = "None" THEN
G = 0
ELSEIF Gloves = "Rag Gloves" THEN
G = 1
ELSEIF Gloves = "Leather Gloves" THEN
G = 2
ELSEIF Gloves = "Gloves of Defense" THEN
G = 3
END IF

ArmorDefense = Ar + S + B + G

IF Weapon = "Fists" THEN
WeaponDamage = 3
ELSEIF Weapon = "Brass Knuckles" THEN
WeaponDamage = 5
ELSEIF Weapon = "Daggar" THEN
WeaponDamage = 8
ELSEIF Weapon = "Short Laser Sword" THEN
WeaponDamage = 10
ELSEIF Weapon = "Long Laser Sword" THEN
WeaponDamage = 13
ELSEIF Weapon = "Phase Gun" THEN
WeaponDamage = 15
ELSEIF Weapon = "Broad Light Sword" THEN
WeaponDamage = 20
ELSEIF Weapon = "Nuclear Phase Gun" THEN
WeaponDamage = 50
ELSEIF Weapon = "Hand Grenade" THEN
WeaponDamage = 100
END IF

IF EnemyWeapon = "Tail" THEN
EnemyWeaponDamage = 5
ELSEIF EnemyWeapon = "Fists" THEN
EnemyWeaponDamage = 5
ELSEIF EnemyWeapon = "Laser Sword" THEN
EnemyWeaponDamage = 10
ELSEIF EnemyWeapon = "Phase Gun" THEN
EnemyWeaponDamage = 15
END IF

SCREEN 13: CLS '40x25

x = 1
y = 1


DO
A = INT(RND * 5) + 1
IF A = 1 THEN battle
CLS
k$ = ""
LOCATE x, y: PRINT CHR$(1)
WHILE k$ = ""
k$ = INKEY$
WEND
SELECT CASE k$
CASE CHR$(0) + CHR$(&H48)'up
x = x - 1
CASE CHR$(0) + CHR$(&H50)'down
x = x + 1
CASE CHR$(0) + CHR$(&H4B)'left
y = y - 1
CASE CHR$(0) + CHR$(&H4D)'right
y = y + 1
END SELECT
LOOP

SUB battle



RANDOMIZE TIMER

Enemy = INT(RND * 3) + 1

IF Enemy = 1 THEN
EnemyName = "Big Cat"
EnemyHP = 30
EnemyStrength = 5
EnemyMP = 0
MaxEnemyMP = 0
MaxEnemyHP = 30
EnemyDefense = 1
EnemyExperience = 100
EnemyGold = INT(RND * 7)
EnemyWeapon = "Tail"
ELSEIF Enemy = 2 THEN
EnemyName = "Slime"
EnemyHP = 15
EnemyMP = 0
MaxEnemyMP = 0
MaxEnemyHP = 15
EnemyStrength = 5
EnemyDefense = 0
EnemyExperience = 100
EnemyGold = INT(RND * 7)
EnemyWeapon = "Tail"
ELSEIF Enemy = 3 THEN
EnemyName = "Snake"
EnemyHP = 25
EnemyMP = 0
MaxEnemyMP = 0
MaxEnemyHP = 25
EnemyStrength = 5
EnemyDefense = 2
EnemyExperience = 100
EnemyGold = INT(RND * 3)
EnemyWeapon = "Tail"
END IF

CLS

PRINT "You've run into a "; EnemyName; "!"


DO

SLEEP

CLS

LOCATE 2, 1: PRINT "Experience:"; Experience; "/"; RequiredExperience
LOCATE 3, 1: PRINT "HP:"; HP; "/"; MaxHP
LOCATE 4, 1: PRINT "MP:"; MP; "/"; MaxMP
LOCATE 5, 1: PRINT "Gold:"; Gold
LOCATE 2, 21: PRINT "Enemy HP:"; EnemyHP; "/"; MaxEnemyHP
LOCATE 3, 21: PRINT "Enemy MP:"; EnemyMP; "/"; MaxEnemyHP
LOCATE 7, 1

PRINT "What do you want to do? (R)un, (F)ight"

choice$ = LCASE$(INPUT$(1))

IF choice$ = "r" THEN

RunAway = INT(RND * 2) + 1

IF RunAway = 1 THEN
PRINT "You Got away!"
done = 1
ELSE
PRINT "Couldn't Run!"
END IF

ELSEIF choice$ = "f" THEN
PRINT "(A)ttack"
PRINT "(M)agic"
DO
choice$ = LCASE$(INPUT$(1))
IF choice$ = "a" OR choice$ = "m" THEN MadeChoice = true
LOOP UNTIL MadeChoice
IF choice$ = "a" THEN
attack = ((INT(RND * 3) + 2) * Strength + WeaponDamage) - ((INT(RND * 3) + 2) * EnemyDefense)
IF attack > 0 THEN
PRINT "You attack "; EnemyName; " with your "; Weapon; " and do "; attack; " damage!"
EnemyHP = EnemyHP - attack
ELSE
PRINT "You did no damage!"
END IF
ELSEIF choice$ = "m" THEN
FOR ShowSpell = 1 TO MaxSpell
IF spell$(ShowSpell) <> "" THEN
PRINT ShowSpell; " "; spell$(ShowSpell)
END IF
NEXT ShowSpell
DO
choice$ = LCASE$(INPUT$(1))
IF choice$ = "1" AND spell$(1) = "Heal" THEN
IF MP >= 10 THEN
HP = HP + (INT(RND * 50) + 20)
MadeChoice = true
MP = MP - 10
ELSE
PRINT "Not Enough MP."
END IF
END IF
IF choice$ = "2" AND spell$(2) = "Fireball" THEN
IF MP >= 25 THEN
SpellDamage = (INT(RND * 30) + 20 * Level)
EnemyHP = EnemyHP - SpellDamage
MP = MP - 25
ELSE
PRINT "Not enough MP."
END IF
END IF
IF choice$ = "3" AND spell$(3) = "Dust Storm" THEN
IF MP >= 20 THEN
EnemyDefense = EnemyDefense - EnemyDefense
MP = MP - 20
ELSE
PRINT "Not enough MP."
END IF
END IF
IF choice$ = "4" AND spell$(4) = "Monster" THEN
IF MP >= 50 THEN
SpellDamage = (INT(RND * 50) + 20)
ContDamage = INT(RND * 10) + 3
EnemyHP = EnemyHP - SpellDamage - ContDamage
MP = MP - 50
ELSE
PRINT "Not enough MP."
END IF
END IF
IF choice$ = "5" AND spell$(5) = "Black Death" THEN
IF MP > 100 THEN
EnemyHP = EnemyHP - EnemyHP
MP = MP - MP
ELSE
PRINT "Not enough MP."
END IF
END IF
LOOP
MadeChoice = false

END IF

IF EnemyHP < 1 THEN
Gold = Gold + EnemyGold
Experience = Experience + EnemyExperience
PRINT "You beat the "; EnemyName; " and got"; EnemyGold; " gold and gained "; EnemyExperience; "Experince"
done = 1
SLEEP
ELSE
attack = ((INT(RND * 3) + 2) * EnemyStrength + EnemyWeaponDamage) - ((INT(RND * 3) + 2) * Defense + ArmorDefense)
IF attack > 0 THEN
PRINT EnemyName; " attacks you with his "; EnemyWeapon; " and does "; attack; " damage!"
HP = HP - attack
IF ContDamage > 0 THEN
EnemyHP = EnemyHP - ContDamage
PRINT EnemyName; "is hurt from a previous injury!"
END IF
ELSE
PRINT EnemyName; " Did no damage!"
END IF
IF HP < 1 THEN
PRINT "You have been defeated by the "; EnemyName
done = 1
SLEEP
CLS
END
END IF
END IF
IF HP < 0 THEN HP = 0
IF Experience >= RequiredExperience THEN
Experience = 0
RequiredExperience = RequiredExperience + 100
Level = Level + 1
Strength = Strength + INT(RND * 5)
Defense = Defense + INT(RND * 3)
MaxHP = MaxHP + INT(RND * 10) + 1
MaxMP = MaxMP + INT(RND * 10) + 1
HP = MaxHP
MP = MaxMP
PRINT "You grew to Level "; Level; "! Your HP is now "; MaxHP; ", you MP is now"; MaxMP; ", your Strength is now"; Strength; " and your defense is now "; Defense; "!"
IF Level = 2 THEN
spell$(1) = "Heal"
ELSEIF Level = 3 THEN
spell$(2) = "Fireball"
ELSEIF Level = 5 THEN
spell$(3) = "Dust Storm"
ELSEIF Level = 8 THEN
spell$(4) = "Monster"
ELSEIF Level = 20 THEN
spell$(5) = "Black Death"
END IF
SLEEP
END IF
ELSE
PRINT "That is not a valid choice."

END IF
A = A + 5
LOOP UNTIL done = 1

END SUB



iy
http://24.93.200.104/billy

 
 Respond to this message   
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums