mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-10 06:30:41 +00:00
f2c9526c79
cmdsys so that dependencies have to be updated. Version now 0.8 - getting close
227 lines
4.4 KiB
Plaintext
227 lines
4.4 KiB
Plaintext
import cmdsys
|
|
predef syscall, call, memset, getc, putc, puts, putln
|
|
predef memset, memcpy
|
|
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
|
|
byte MACHID
|
|
end
|
|
|
|
import ROGUEMAP
|
|
predef puti, toupper, moveplayer
|
|
word rnd, getkb, home, gotoxy, tone
|
|
end
|
|
|
|
struc t_pos
|
|
byte xpos
|
|
byte ypos
|
|
end
|
|
|
|
//
|
|
// Player
|
|
//
|
|
|
|
struc t_player
|
|
byte[t_pos]
|
|
byte angle
|
|
byte lamp
|
|
byte fov
|
|
byte skill
|
|
byte health
|
|
byte energy
|
|
word oil
|
|
byte gold
|
|
byte key
|
|
byte raft
|
|
byte[32] name[32]
|
|
end
|
|
|
|
//
|
|
// ASCII Warrior
|
|
//
|
|
|
|
byte[] ascii_warrior
|
|
byte = " | "
|
|
byte = " T "
|
|
byte = " \\ () "
|
|
byte = " \\^ "
|
|
byte = " #\\_] "
|
|
byte = " # ] "
|
|
byte = " /\\ "
|
|
byte = " / \\ "
|
|
byte = " / / "
|
|
byte = " = = "
|
|
|
|
//
|
|
// Other monsters
|
|
//
|
|
|
|
struc t_other
|
|
byte[t_pos]
|
|
byte kind
|
|
byte tileid
|
|
byte life
|
|
byte power
|
|
word prev_other
|
|
word next_other
|
|
end
|
|
|
|
//
|
|
// ASCII Enemy Art
|
|
//
|
|
byte[] ascii_thief
|
|
byte = " "
|
|
byte = " "
|
|
byte = " ____ "
|
|
byte = " /o_o\\\\ "
|
|
byte = "| \\ = // "
|
|
byte = "T /###|\\\\ "
|
|
byte = "@==###||| "
|
|
byte = " xxx@// "
|
|
byte = " #|#|\\\\ "
|
|
byte = " #|#| \\\\"
|
|
|
|
byte[] ascii_ogre
|
|
byte = " :^; "
|
|
byte = " @ }\"{ "
|
|
byte = " # /'\\ "
|
|
byte = " ##=<#>=##"
|
|
byte = " ===== #"
|
|
byte = " \\===/ ?"
|
|
byte = " ===== :"
|
|
byte = " ()^() :"
|
|
byte = " () () *"
|
|
byte = " {{} {}} "
|
|
|
|
byte[] ascii_zombie
|
|
byte = " \\\\/ "
|
|
byte = " {o|0} "
|
|
byte = " { ^ } "
|
|
byte = " ### "
|
|
byte = " /:\\ "
|
|
byte = " /%%%%%\\ "
|
|
byte = "|%%%//%%|\\"
|
|
byte = "|%%%\\%%%||"
|
|
byte = "|%%//%%%/|"
|
|
byte = "<===|@___/"
|
|
|
|
byte[] ascii_rogue
|
|
byte = " "
|
|
byte = " \\ / "
|
|
byte = " < - - > "
|
|
byte = " ( \" ) "
|
|
byte = " \\VVV/ "
|
|
byte = " \\M/ "
|
|
byte = " ^^^^^^ "
|
|
byte = " / \\ "
|
|
byte = "( ) ^^>--="
|
|
byte = "( ) WW>--//"
|
|
|
|
word ascii_entity = @ascii_thief, @ascii_ogre, @ascii_zombie, @ascii_rogue
|
|
//
|
|
// Monster types
|
|
//
|
|
|
|
byte thief = "Thief", 5
|
|
byte ogre = "Ogre", 20
|
|
byte zombie = "Zombie", 40
|
|
byte rogue = "Rogue", 80
|
|
export word entity = @thief, @ogre, @zombie, @rogue
|
|
export word entities = 0
|
|
|
|
//
|
|
// Combat status strings
|
|
//
|
|
|
|
byte skillstr = "Skill :"
|
|
byte healthstr = "Health :"
|
|
byte energystr = "Energy :"
|
|
byte powerstr = "Power :"
|
|
byte lifestr = "Life :"
|
|
byte fightstr = "F)ight or R)un?"
|
|
|
|
//
|
|
// Combat Return 1 if running away, 0 if end of fight
|
|
//
|
|
|
|
def win
|
|
tone(30, 15)
|
|
tone(5, 15)
|
|
tone(5, 15)
|
|
tone(30, 5)
|
|
end
|
|
|
|
export def fight(player, enemy)
|
|
word p_atck, e_atck
|
|
|
|
repeat
|
|
home()
|
|
gotoxy(0, 0)
|
|
puts(player+name)
|
|
gotoxy(1, 2)
|
|
puts(@skillstr); puti(player->skill)
|
|
gotoxy(1, 3)
|
|
puts(@healthstr); puti(player->health)
|
|
gotoxy(1, 4)
|
|
puts(@energystr); puti(player->energy)
|
|
gotoxy(20, 0)
|
|
puts(entity[enemy->kind])
|
|
gotoxy(21, 2)
|
|
puts(@powerstr); puti(enemy->power)
|
|
gotoxy(21, 3)
|
|
puts(@lifestr); puti(enemy->life)
|
|
for e_atck = 0 to 9
|
|
gotoxy(0, 10 + e_atck)
|
|
puts(@ascii_warrior + e_atck * 11)
|
|
gotoxy(20, 10 + e_atck)
|
|
puts(ascii_entity[enemy->kind] + e_atck * 11)
|
|
next
|
|
gotoxy(12, 8); puts(@fightstr)
|
|
if toupper(getkb()) == 'R'
|
|
return 1
|
|
else
|
|
//
|
|
// Turn player in random direction
|
|
//
|
|
player->angle = rnd() & 7
|
|
//
|
|
// Calculate attack (with a little random variation)
|
|
//
|
|
p_atck = player->skill + player->energy / 10 - enemy->power / 25 + (rnd() & 7)
|
|
e_atck = enemy->power - player->skill / 5 - player->energy / 20 + (rnd() & 7)
|
|
if enemy->life > p_atck
|
|
enemy->life = enemy->life - p_atck
|
|
else
|
|
win
|
|
enemy->life = 0
|
|
p_atck = player->skill + enemy->power / 3
|
|
if p_atck > 100 // Limit skill
|
|
p_atck = 100
|
|
fin
|
|
player->skill = p_atck
|
|
//
|
|
// Unlink dead enemy from entities list
|
|
//
|
|
if enemy == entities
|
|
entities = enemy=>next_other
|
|
fin
|
|
if enemy=>next_other
|
|
enemy=>next_other=>prev_other = enemy=>prev_other
|
|
fin
|
|
if enemy=>prev_other
|
|
enemy=>prev_other=>next_other = enemy=>next_other
|
|
fin
|
|
fin
|
|
if player->health > e_atck
|
|
player->health = player->health - e_atck
|
|
else
|
|
player->energy = 0
|
|
player->health = 0
|
|
fin
|
|
if player->energy >= 4
|
|
player->energy = player->energy - 4
|
|
fin
|
|
fin
|
|
until player->health == 0 or enemy->life == 0
|
|
return 0
|
|
end
|
|
|
|
done |