mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-03 00:29:59 +00:00
Cleaning up display of combat.
This commit is contained in:
parent
98d9631a90
commit
c4a7e4fe6a
@ -1508,6 +1508,19 @@ def countList(p)
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def countListFiltered(p, offset, filterFunc)
|
||||||
|
word n
|
||||||
|
n = 0
|
||||||
|
while p
|
||||||
|
if filterFunc(p)
|
||||||
|
n = n+1
|
||||||
|
fin
|
||||||
|
p = *(p + offset)
|
||||||
|
loop
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Call like this: addToList(player + items, itemToAdd)
|
// Call like this: addToList(player + items, itemToAdd)
|
||||||
def addToList(addTo, p)
|
def addToList(addTo, p)
|
||||||
@ -1538,12 +1551,7 @@ include "playtype.pla"
|
|||||||
//include "heaptest.pla"
|
//include "heaptest.pla"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def playerCanFight(p)
|
def canFight(p)
|
||||||
return p=>w_health > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
def enemyCanFight(p)
|
|
||||||
return p=>w_health > 0
|
return p=>w_health > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1556,7 +1564,7 @@ def chooseEnemy(maxDist)
|
|||||||
n = rand16() % nEnemiesFighting
|
n = rand16() % nEnemiesFighting
|
||||||
p = global=>p_combatFirst
|
p = global=>p_combatFirst
|
||||||
while TRUE
|
while TRUE
|
||||||
if p->t_type == TYPE_ENEMY and enemyCanFight(p)
|
if p->t_type == TYPE_ENEMY and canFight(p)
|
||||||
if n == 0; return p; fin
|
if n == 0; return p; fin
|
||||||
n = n - 1
|
n = n - 1
|
||||||
fin
|
fin
|
||||||
@ -1625,12 +1633,57 @@ def chooseWeapon(player)
|
|||||||
displayStr("TODO: choose weapon\n")
|
displayStr("TODO: choose weapon\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def combatPause()
|
||||||
|
word n
|
||||||
|
for n = 1 to 2000
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def displayOpponents()
|
||||||
|
word p
|
||||||
|
byte count, first
|
||||||
|
|
||||||
|
buildString(@addToString)
|
||||||
|
puts("You face ")
|
||||||
|
first = TRUE
|
||||||
|
p = global=>p_enemyGroups
|
||||||
|
while p
|
||||||
|
if !first
|
||||||
|
if p=>p_nextObj
|
||||||
|
puts(", ")
|
||||||
|
else
|
||||||
|
puts(" and ")
|
||||||
|
fin
|
||||||
|
fin
|
||||||
|
first = FALSE
|
||||||
|
count = countListFiltered(p=>p_enemies, p_nextObj, @canFight)
|
||||||
|
isPlural = (count <> 1)
|
||||||
|
printf3("%d %s at %d'", count, p=>p_enemies=>s_name, p->b_enemyGroupRange)
|
||||||
|
p = p=>p_nextObj
|
||||||
|
loop
|
||||||
|
puts(".\n")
|
||||||
|
displayStr(finishString(isPlural))
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def displayOption(key, str)
|
||||||
|
buildString(@addToString)
|
||||||
|
printf2(" (%c)^T033%s\n", key, str)
|
||||||
|
rawDisplayStr(finishString(0))
|
||||||
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def playerCombatTurn(pl)
|
def playerCombatTurn(pl)
|
||||||
word p, pWeapon
|
word p, pWeapon
|
||||||
byte key, nWeapons
|
byte nWeapons, key
|
||||||
byte canShoot, canReload, canChange
|
byte canShoot, canReload, canChange
|
||||||
|
|
||||||
|
// Tell what the player currently faces
|
||||||
|
displayOpponents()
|
||||||
|
combatPause()
|
||||||
|
|
||||||
// Count weapons, and take the first as the current one.
|
// Count weapons, and take the first as the current one.
|
||||||
nWeapons = 0
|
nWeapons = 0
|
||||||
pWeapon = NULL
|
pWeapon = NULL
|
||||||
@ -1644,36 +1697,43 @@ def playerCombatTurn(pl)
|
|||||||
loop
|
loop
|
||||||
|
|
||||||
// Let them know their options
|
// Let them know their options
|
||||||
buildString(@addToString)
|
displayStr("\n")
|
||||||
printf1("%s, your turn.\n\nWeapon: ", pl=>s_name)
|
when rand16() % 5
|
||||||
if pWeapon
|
is 0
|
||||||
printf2("%s.\nLoaded: %d\n", pWeapon=>s_name, pWeapon->b_clipCurrent)
|
displayStr("Think fast!"); break
|
||||||
// TODO: display avail ammo as well
|
is 1
|
||||||
else
|
displayStr("Do you:"); break
|
||||||
puts("none.\n")
|
is 2
|
||||||
fin
|
displayStr("Suck it up:"); break
|
||||||
|
is 3
|
||||||
|
displayStr("Options:"); break
|
||||||
|
otherwise
|
||||||
|
displayStr("Decisions, decisions..."); break
|
||||||
|
wend
|
||||||
|
displayStr("\n")
|
||||||
|
|
||||||
puts("\nOptions: M)elee")
|
displayOption('M', "Melee")
|
||||||
if pWeapon
|
if pWeapon
|
||||||
if pWeapon->b_clipCurrent
|
if pWeapon->b_clipCurrent
|
||||||
canShoot = TRUE
|
canShoot = TRUE
|
||||||
puts(", S)hoot")
|
displayOption('S', "Shoot")
|
||||||
fin
|
fin
|
||||||
if pWeapon->b_clipCurrent < pWeapon->b_clipSize
|
if pWeapon->b_clipCurrent < pWeapon->b_clipSize
|
||||||
// TODO: Need to check for enough ammo, and use it up.
|
// TODO: Need to check for enough ammo, and use it up.
|
||||||
canReload = TRUE
|
canReload = TRUE
|
||||||
puts(", R)eload")
|
displayOption('R', "Reload")
|
||||||
fin
|
fin
|
||||||
if nWeapons >= 2
|
if nWeapons >= 2
|
||||||
canChange = TRUE
|
canChange = TRUE
|
||||||
puts(", C)hange weapon")
|
displayOption('C', "Change weapon")
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
puts(", D)odge, F)lee.\n")
|
displayOption('D', "Dodge")
|
||||||
displayStr(finishString(0))
|
displayOption('F', "Flee")
|
||||||
|
|
||||||
while TRUE
|
while TRUE
|
||||||
key = getUpperKey()
|
key = getUpperKey()
|
||||||
|
displayStr("\n")
|
||||||
if key == 'M'
|
if key == 'M'
|
||||||
if playerMelee(pl, pWeapon); return; fin
|
if playerMelee(pl, pWeapon); return; fin
|
||||||
break
|
break
|
||||||
@ -1700,8 +1760,12 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def enemyCombatTurn(pe)
|
def enemyCombatTurn(pe)
|
||||||
|
if !canFight(pe)
|
||||||
|
return
|
||||||
|
fin
|
||||||
isPlural = FALSE
|
isPlural = FALSE
|
||||||
displayf1("TODO: Enemy turn for %s\n", pe=>s_name)
|
displayf1("TODO: Enemy turn for %s\n", pe=>s_name)
|
||||||
|
combatPause()
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1734,7 +1798,7 @@ def determineCombatOrder()
|
|||||||
global=>p_combatFirst = NULL
|
global=>p_combatFirst = NULL
|
||||||
p = global=>p_players
|
p = global=>p_players
|
||||||
while p
|
while p
|
||||||
if playerCanFight(p)
|
if canFight(p)
|
||||||
p->b_combatOrder = rand16() % (p->b_agility * 10)
|
p->b_combatOrder = rand16() % (p->b_agility * 10)
|
||||||
combatInsert(p)
|
combatInsert(p)
|
||||||
nPlayersFighting = nPlayersFighting + 1
|
nPlayersFighting = nPlayersFighting + 1
|
||||||
@ -1747,7 +1811,7 @@ def determineCombatOrder()
|
|||||||
while p
|
while p
|
||||||
p2 = p=>p_enemies
|
p2 = p=>p_enemies
|
||||||
while p2
|
while p2
|
||||||
if enemyCanFight(p2)
|
if canFight(p2)
|
||||||
p2->b_combatOrder = rand16() % p2->b_chanceToHit
|
p2->b_combatOrder = rand16() % p2->b_chanceToHit
|
||||||
combatInsert(p2)
|
combatInsert(p2)
|
||||||
nEnemiesFighting = nEnemiesFighting + 1
|
nEnemiesFighting = nEnemiesFighting + 1
|
||||||
@ -1813,7 +1877,9 @@ def startCombat()
|
|||||||
p = p=>p_nextObj
|
p = p=>p_nextObj
|
||||||
loop
|
loop
|
||||||
|
|
||||||
displayStr("Do you: F)ight or R)un?")
|
rawDisplayStr("\nDo you:\n")
|
||||||
|
displayOption('F', "Fight")
|
||||||
|
displayOption('R', "Run")
|
||||||
while TRUE
|
while TRUE
|
||||||
n = getUpperKey()
|
n = getUpperKey()
|
||||||
if n == 'F'
|
if n == 'F'
|
||||||
@ -1845,9 +1911,17 @@ def doCombat()
|
|||||||
displayStr("\n")
|
displayStr("\n")
|
||||||
if !nPlayersFighting
|
if !nPlayersFighting
|
||||||
displayStr("You lost.")
|
displayStr("You lost.")
|
||||||
|
//Lose: You bought the farm, with your life! Thank's for playing! Relead last save ? Y/N
|
||||||
|
//Lose: Didn't see that coming...to see a fine player like you slaughtered like a common rodent...Well, let's reload and try that again, ok? Y/N
|
||||||
return
|
return
|
||||||
elsif !nEnemiesFighting
|
elsif !nEnemiesFighting
|
||||||
displayStr("You won!")
|
displayStr("You won!")
|
||||||
|
//WIN: You survive the ordeal and rifle through the carnage to find X gold. (if player gets random item) Upon further searching you find a
|
||||||
|
//Win: That was a close call! You see something shimmering on the ground and find X gold.
|
||||||
|
//Win: Looks like you live to fight another day anyway! You get X experience and discover X gold.
|
||||||
|
//I forgot to add experience to the above ones
|
||||||
|
// WIN: You survive the ordeal and rifle through the carnage to find X gold and receive x experience. (if player gets random item) Upon further searching you find a
|
||||||
|
//Win: That was a close call! You see something shimmering on the ground and find X gold and x expereince.
|
||||||
return
|
return
|
||||||
elsif isFleeing
|
elsif isFleeing
|
||||||
displayStr("You have fled.")
|
displayStr("You have fled.")
|
||||||
@ -1862,6 +1936,7 @@ def doCombat()
|
|||||||
otherwise
|
otherwise
|
||||||
brk()
|
brk()
|
||||||
wend
|
wend
|
||||||
|
combatPause()
|
||||||
p = p=>p_combatNext
|
p = p=>p_combatNext
|
||||||
loop
|
loop
|
||||||
loop
|
loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user