'// for game purposes - we can display seed if we want to use it agian
seed = stripTime
'// ASCII MAP GEN TRY I
'// BASED ON SMcNeil of QB64 idea
'// FAKE BOOLEAN :-)
'// MAPSIZE
'// TILES USED
Const MIN_INNS
= 5 ' MIN INNS IN THE WORLD. HIGHER FOR EASIER GAME Const MIN_RUINS
= 20 ' RUINS ARE SPECIAL - 20 IS ABOVE AVERAGE, HIGHER FOR MONTE HALL. Const PLAYER_AVATAR
= " " Const INITIAL_HP
= 20 ' STARTING HP Const INITIAL_DEF
= 0 ' STARTING DEFENSE Const INITIAL_ATK
= 5 ' STARTING ATTACK Const MAX_MOBS
= 112 ' TOTAL MOBS IN THE DATABASE - ADJ AS ADDED OR DELETED
'// MAX RANDOM SPELLS LIMITS
Const INVISI
= 3 ' STARTING # OF INVISIBILITY Const CHARM
= 4 ' STARTING # OF CHARM Const STUN
= 6 ' STARTING # OF STUN SPELLS
'// GAME INFO
total_ruins
As Integer ' once ruins are explored they are deleted from map.
'$include: 'playerRec.bi'
'// DATA FILES
'$include: 'xpgain.bi'
'$include: 'weapons.bi'
'$include: 'armorlist.bi'
'$include: 'moblist.bi'
'$include: 'masterslist.bi'
INIT_GAME
'// initial walking ticker for random encounters
RESET_RANDOM_ENCOUNTER_TICK
X = (player.qx * 10 - 10) + player.sx
Y = (player.qy * 10 - 10) + player.sy
If RANDOM_TICK
<= 0 Then COMBAT
DRAW_MAP
'// get player input
'// is player moving
'// THESE KEYS MEANS THE PLAYER IS MOVING. I AM USING THE FINAL FANTASY MOVE CRITERIA
'// TO DETERMINE A RANDOM ENCOUNTER (FOLLWO THE BEST!)
'// countdown is based on terrain
'// TREES = -6
'// PATHS = -5
'// ALL ELSE -2
'// incase of error save old pos
oqx = player.qx: oqy = player.qy
osx = player.sx: osy = player.sy
Case "w": player.sy
= player.sy
- 1 If player.sy
< 1 Then player.sy
= 10: player.qy
= player.qy
- 1 If player.qy
< 1 Then player.sy
= 1: player.qy
= oqy
Case "s": player.sy
= player.sy
+ 1 If player.sy
> 10 Then player.sy
= 1: player.qy
= player.qy
+ 1 If player.qy
> 10 Then player.sy
= 1: player.qy
= oqy
Case "a": player.sx
= player.sx
- 1 If player.sx
< 1 Then player.sx
= 10: player.qx
= player.qx
- 1 If player.qx
< 1 Then player.sx
= 1: player.qx
= oqx
Case "d": player.sx
= player.sx
+ 1 If player.sx
> 10 Then player.sx
= 1: player.qx
= player.qx
+ 1 If player.qx
> 10 Then player.sx
= 1: player.qx
= oqx
'// to figure terrain to determain tick, where the hell are we :-)
X = (player.qx * 10 - 10) + player.sx
Y = (player.qy * 10 - 10) + player.sy
If area
(X
, Y
) = 1 Then RANDOM_TICK
= RANDOM_TICK
- 6 'trees If area
(X
, Y
) = 2 Then RANDOM_TICK
= RANDOM_TICK
- 5 'paths
'$include: 'utils.bi'
'$include: 'combat.bi'
RESET_RANDOM_ENCOUNTER_TICK
'// FIND MOB TO MATCH PLAYERS LEVEL
'LEVEL,NAME,ATK,XP,HP,GOLD,WEAPON,DEATHTXT
'// FIND A RANDOM MOB AT PLAYERS LEVEL
mob
(I
).mName
= _Trim$(mob
(I
).mName
) ' for some reason this is not working...
Print "You encountered a "; mob
(I
).mName
'// start combat
Print "Your hp: "; player.hp
startFight mob(I).atk
If FightResults.mobCrit
= TRUE
Then Print _Trim$(mob
(I
).mName
);
" does a powerful move on you!!" Print _Trim$(mob
(I
).mName
);
" did "; FightResults.mobDamage;
" damage with its "; mob
(I
).weaponStr
If FightResults.playerCrit
= TRUE
Then Print "You do critical damage!!" Print "You did "; FightResults.playerDamage;
" points of damage with your "; weapon
(player.weaponId
).gearName
player.hp = player.hp - FightResults.mobDamage
mob(I).hp = mob(I).hp - FightResults.playerDamage
'// TODO: PUT THIS IN A SUB - AS IT WILL BE CALLED FROM OTHER LOCATIONS
Print "You were knocked out by ";
_Trim$(mob
(I
).mName
);
" and left for dead" Print "You lost all your gold!!": player.money
= 0 Print "and lost 10% of your experience!": player.xp
= player.xp
- Int(player.xp
* .1) Print "after some time, you were able to recover about half your health": player.hp
= Int(player.hpMax
* .5) Print "You gained "; mob
(I
).xp;
"xp! ": player.xp
= player.xp
+ mob
(I
).xp
Print "It was guarding "; mob
(I
).gold;
"gold pieces": player.money
= player.money
+ mob
(I
).gold
P_AUSE
gameover = FALSE
tile(1) = " " 'TREES
tile(2) = " -" 'PLAINS
tile(3) = " º" 'CRUMBLING WALLS (IMPASSABLE)
tile(4) = " M" 'RUINS TO EXPLORE
tile(5) = " " 'INN
tile(99) = " ." 'nothing
'// SETUP DEFAULT PLAYER STUFF
player.pName = "Adventurer"
player.avatar = PLAYER_AVATAR
player.level = 1
player.xp = 0
player.potions = 5
player.qx = r(10): player.qy = r(10)
player.sx = r(10): player.sy = r(10)
player.daysInGame = 0.0
player.hp = INITIAL_HP
player.hpMax = player.hp
player.defense = INITIAL_DEF
player.atk = INITIAL_ATK
player.atkMax = player.atk
player.defMax = player.defense
player.armorBuff = 1
player.weaponBuff = 5
player.charm = r(CHARM)
player.stun = r(STUN)
player.invisi = r(INVISI)
player.armorId = 1
player.weaponId = 1
player.money = 0
For I
= 1 To 16:
Read armor
(I
).level
, armor
(I
).gearName
, armor
(I
).cost
, armor
(I
).buff:
Next For I
= 1 To 16:
Read weapon
(I
).level
, weapon
(I
).gearName
, weapon
(I
).cost
, weapon
(I
).buff:
Next
Read mob
(I
).deathGossip
' not used anymore
CREATE_MAP
'// DRAW PLAYER CURRENT QUADRANT AND SECTOR
row = 1:
For Y
= (player.qy
* 10 - 10) + 1 To (player.qy
* 10) col = 1
For X
= (player.qx
* 10 - 10) + 1 To (player.qx
* 10)
'Print "found": End
I = r(2)
col = col + 1
Case 1:
Print , _Trim$(player.pName
);
" Level: "; player.level
'; " Q: "; player.qx; ","; player.qy; " S: "; player.sx; ","; player.sy
Case 2:
Print , "HP: "; player.hp;
"/"; player.hpMax; _
" Atk: ";player.atk;
"(+";
_Trim$(Str$(wbuff
));
")/"; player.atkMax; _
" Def: "; player.defense;
"(+";
_Trim$(Str$(abuff
));
") /"; player.defMax
row = row + 1
'// TODO: MAKE A DECENT MAP GEN, THIS IS JUST RANDOM STUFF
'// CLOSE TO THE ORIGINAL GAME OF JUST TREES, PATHS AND WALLS.
area(I, J) = 99
If k
< .99 Then area
(I
, J
) = 1 'Trees If k
< .55 Then area
(I
, J
) = 2 ' Plains If k
< .07 Then area
(I
, J
) = 3 ' WALLS '// .011 about 120-140 ish
If k
< .011 Then area
(I
, J
) = 4: game.total_ruins
= game.total_ruins
+ 1 'Ruins '// .002 less than 30 avg
If k
< .002 Then area
(I
, J
) = 5: game.total_inns
= game.total_inns
+ 1 'INN
'// we need at least 5 inns
If game.total_inns
< MIN_INNS
Then For I
= 1 To MIN_INNS
- game.total_inns
area(r(10), r(10)) = 5
If game.total_ruins
< MIN_RUINS
Then For I
= 1 To MIN_RUINS
- game.total_ruins
area(r(10), r(10)) = 4
Sub RESET_RANDOM_ENCOUNTER_TICK
'// restart the random encoutner ticker
'// This only needs to be called at new game,
'// when player leaves an inn.
'// after combat.
'// this will set a ticker that is counted down based on the number of
'// steps the player takes. how mcuh is based on terrain. see movement sub.
'// https://finalfantasy.fandom.com/wiki/Random_encounter
'// this ticker is smaller due to this game size being small
RANDOM_TICK
= Int(Rnd * 30) + 1
'// USE IN CONJUNCTION WITH RANDOMIZE
'// The TIMER function returns the number of seconds past the previous midnite
'// This means next day, same seed.
'// strip date
stripTime = d * t