I got this code and I cannot get it to work.

I want it to show up with the type of attacks you can do which it does.

After each time you attack the enemy the enemy attacks you of a damage between 1-10, then its my turn etc until you or enemy < 0 then writes you win or enemy win.

Also I want to add a thing where when its your turn you can use portions to restore your health of value of 10 and another potion of value of 20.

Here is the code:

program RPG;

var

Attack : Integer;
Defense : Integer;
Health : Integer;
EnemyHealth : Integer;
Damage : Integer;
EnemyAttack : Integer;
EnemyDefense : Integer;
Whatdo : Integer;
Healz : Integer;
Death : Boolean;
EnemyDam : Integer;

Begin

Death := FALSE;
Defense := 10;
EnemyDefense := 5;
EnemyAttack := 8;
Health := 100;
EnemyHealth := 50;
Healz := 10;
Attack := 12;



Writeln ('Hero vs Enemy');
Writeln ('Hero Health : ', Health);
Writeln ('Enemy Health : ',EnemyHealth);
Writeln ('');
Writeln ('1. Attack');
Writeln ('2. Heal');
Writeln ('');
Writeln ('What do?');
Readln (Whatdo);
If whatdo = 1 then
repeat
Damage := Attack - EnemyDefense;
EnemyHealth := Enemyhealth - Damage;
if (EnemyHealth < 0) then
   EnemyHealth := 0;
Enemydam := EnemyAttack - Defense;
Health := Health - EnemyDam;
Writeln ('Enemy health is now ', EnemyHealth);
Writeln ('Hero Health is now ', Health);
Readln;
until
(EnemyHealth <= 0);

If whatdo = 2 then
Health := Health + healz;
Enemydam := EnemyAttack - Defense;
Health := Health - EnemyDam;
if (EnemyHealth < 0) then
   EnemyHealth := 0;
Writeln ('Enemy health is now ', EnemyHealth);
Writeln ('Hero Health is now ', Health);
Until
(Health = 100);

If Health := 100 then writeln ('Health is full');
readln;

begin
Death := TRUE;
Writeln ('Enemy is dead');
Readln;
end;




End.

Thanks in advance

i overwrite your program a bit :D
written in dev pascal 1.9.2

{game against the computer}
program game_by_FlamingClaw;

uses crt;

type properties = record
                    name:string[10];
                    attack:integer;
                    defense:integer;
                    health:integer;
                    damage:integer;
                    death:boolean;
                    numberof_p:1..3;{number of potions}
                  end;

{forwarded functions and procedures}
function takeonepotion(p:byte;var x:properties):boolean;forward;
function who_begins:byte;forward;
procedure statusmenu(one:properties);forward;
procedure statusmenu2(two:properties);forward;
procedure fight(var y,z:properties);forward;
procedure attack_menu(cpu:boolean;h:byte;var a,b:properties);forward;
procedure lines;forward;


{***FUNCTION WHO_BEGINS}
{generate one number
this number is 1 or 0}
function who_begins:byte;
var w:byte;
begin
     w:=random(250)+1;
     if w mod 2 = 0 then who_begins:=0
     else who_begins:=1;
end;


{***PROCEDURE FIGHT}
{attack one player}
procedure fight(var y,z:properties);
begin
     y.health:=y.health-z.damage;
end;


{***PROCEDURE STATUSMENU}
{write the hero's status}
procedure statusmenu(one:properties);
begin
     gotoxy(1,2);
     writeln(one.name);
     lines;
     writeln('Attack : ',one.attack:3);
     writeln('Defense: ',one.defense:3);
     writeln('Health : ',one.health:3);
     writeln('Potions: ',one.numberof_p:3);
     if one.death = false then writeln('Death  : ','No':3)
     else writeln('Death  : ','Yes':3);
end;

{***PROCEDURE STATUSMENU2}
{write the enemy's status to the screen}
procedure statusmenu2(two:properties);
const x = 20;
var y:byte;
begin
     y:=1;
     gotoxy(x,y+1);
     writeln(two.name);
     gotoxy(x,y+3);
     writeln('Attack : ',two.attack:3);
     gotoxy(x,y+4);
     writeln('Defense: ',two.defense:3);
     gotoxy(x,y+5);
     writeln('Health : ',two.health:3);
     gotoxy(x,y+6);
     writeln('Potions: ',two.numberof_p:3);
     gotoxy(x,y+7);
     if two.death = false then writeln('Death  : ','No':3)
     else writeln('Death  : ','Yes':3);
end;
{***PROCEDURE LINES}
{write a line to the screen}
procedure lines;
var i:byte;
begin
     for i:=1 to 40 do write('-');
     writeln;
end;


{***FUNCTION TAKEONEPOTION}
{if the player has potions then heals the player
and take one potion from the player' item
else  'nothing'}
function takeonepotion(p:byte;var x:properties):boolean;
begin
     if x.numberof_p < 1 then begin
         writeln('empty potion.');
         takeonepotion:=false;
     end else begin
         dec(x.numberof_p,1);
         inc(x.health,p);
         takeonepotion:=true;
     end;
end;


{***PROCEDURE ATTACK_MENU}
{displays an attack menu }
{cpu = if true then the enemy comes else the hero}
{h = will be the potion,if he want to heal}
{a = hero}
{b = enemy}
procedure attack_menu(cpu:boolean;h:byte;var a,b:properties);
var selecting,automate:byte;
begin
     if cpu = false then begin
        writeln('HERO''S GAME MENU');
        writeln('1.ATTACK.');
        writeln('2.HEAL.');
        write('SELECT ONE: ');
        readln(selecting);
        lines;
        case selecting of
             1:begin
                 writeln(a.name,' ATTACK!');
                 fight(a,b);
               end;
             2:begin
                 writeln(a.name,' HEAL...');
                 takeonepotion(h,a);
               end;
        end;{of case}
     end else begin
         automate:=random(2);
         {if automate is 1 then the enemy is attacks you}
         if automate = 1 then begin
            writeln(b.name,' ATTACK!');
            fight(b,a);
         end else begin
            {else heals himself}
            writeln(b.name,' HEAL...');
            takeonepotion(h,b);
         end; {of else}
         lines;
     end;{of else}

end;


{global variables section!}
var enemy,hero:properties; {two fighters}
    potion:byte; {heals}
    counter:byte; {counts the rounds of fight}


begin  {the main program,here begins...}
     clrscr;

     randomize;

     {inicialise }
     potion:=10;
     counter:=1;
     {the status of the enemy}
     with enemy do begin
          name:='Enemy';
          attack:=random(20)+1;
          defense:=random(5)+1; {1..5}
          health:=100;
          damage:=0;
          death:=false;
          numberof_p:=3;
     end;

     {and here we fill the player's properties}
     with hero do begin
          name:='Hero';
          attack:=random(20)+1;
          defense:=random(5)+1;
          health:=100;
          damage:=0;
          death:=false;
          numberof_p:=3;
     end;

     repeat
           writeln('Round: ',counter);
           statusmenu(hero);
           writeln;
           lines;
           statusmenu2(enemy);
           writeln;
           lines;
           hero.damage:=hero.attack-enemy.defense;
           enemy.damage:=enemy.attack-hero.defense;
           {if who_begins is 1 then the hero begins}
           if who_begins = 1 then begin
              attack_menu(false,potion,hero,enemy);
              if enemy.health > 0 then begin
                 attack_menu(true,potion,hero,enemy);
              end
           end else begin {else the enemy begins the fight}
              attack_menu(true,potion,hero,enemy);
              if hero.health > 0 then begin
                 attack_menu(false,potion,hero,enemy);
              end;
           end;
           if hero.health <= 0 then begin
              hero.health:=0;
              hero.death:=true;
              writeln(hero.name,' is dead.',enemy.name,' Win!!!!');
           end else begin
               hero.attack:=random(20)+1;
               hero.defense:=random(5)+1;
           end;
           if enemy.health <= 0 then begin
              enemy.health:=0;
              enemy.death:=true;
              writeln(enemy.name,' is dead.',hero.name,' Win!!!!');
           end else begin
               enemy.attack:=random(20)+1;
               enemy.defense:=random(5)+1;
           end;
           lines;
           write('press enter to continue.');
           inc(counter,1);
           readln;
           clrscr;
     until (hero.death = true)or (enemy.death = true);
     statusmenu(hero);
     statusmenu2(enemy);
     lines;
     writeln('The GAME is over,press enter to exit...');
     readln;

end. {of main program}
{created by FlamingClaw 2009}

of course tested and working,good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.