I need a couple bugs worked out...(Im confused beyond reason)

Discussion in 'Archives' started by ZamorakianFaith, Jun 4, 2007.

I need a couple bugs worked out...(Im confused beyond reason)
  1. Unread #1 - Jun 4, 2007 at 12:00 AM
  2. ZamorakianFaith
    Joined:
    Apr 28, 2005
    Posts:
    406
    Referrals:
    0
    Sythe Gold:
    0

    ZamorakianFaith Forum Addict
    Banned

    I need a couple bugs worked out...(Im confused beyond reason)

    Alright... I had this whole program working fine until i changed the formula for how the engine decides the integer being used as damage in the "fight" procedure.... after i thought i had fixed it, when searching through the dungeon you no longer could encounter enemies- even if i set the chance it 1:1...

    Please see if you can fix the problem- my variables are named pretty straight forward so you should just be able to read along and fix the problem when you find it.

    also if you wouldnt mind, could you please sort of beta test your way through the "lvlup" procedure? I havent done that yet. feel free to make changes to the code.
    Code:
    {//////////////////////////////////////////////////////////////////////')
    {//  //      //    //////////////////////////////////    //      //  //
    {//    /////////////         RPG By ZFaith       ///////////////    //
    {//  //      //    //////////////////////////////////    //      //  //
    {//////////////////////////////////////////////////////////////////////
    
    Please set up your stats if you want to start out ahead
    of the game, or if you are continuing from a previous game.
    
    The stats setup section starts at line 23.
    }
    
    program RPG;
    var
    yourcurrentxp,xp,yourcurrenthp,monsterint:integer;
    weapon,answer2,monst:string;
    m:array [1..15] of string;
    chance,at,st,df,es,hp,hitpoints:integer;
    
    
    procedure declarestats;
    begin
    //SET UP STATS HERE\\
    HP:= 10;
    AT:= 1;
    ST:= 1;
    DF:= 1;
    ES:= 1;
    chance:= 3; // if chance = 7 then you have a 1:7 chance of combat
    weapon:= 'Staff'
    //DID YOU SET UP YOUR STATS?\\
    end;
    
    function anim(text:string):boolean;
    var
    t:integer;
    begin
    result:=true
    repeat
    writeln(text)
    writeln('-')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('\')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('|')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('/')
    t:=t+1
    wait(100)
    cleardebug;
    until(t=5)
    end;
    
    procedure getmonster;
    begin
    monsterint:=random(15)
    if monsterint>15 then
     begin
     monsterint:=7
     end;
    if monsterint<1 then
     begin
     monsterint:=8
     end;
    end;
    
    procedure start; forward;
    procedure fight; forward;
    
    procedure idle;
    var
    answer:string;prob:integer;
    begin
      prob:=random(chance)
      anim('...you venture further into the dungeon...')
      anim('...you venture further into the dungeon...')
      if prob = 3 then
      begin
        getmonster;
        monst:=m[monsterint]
        hitpoints:=random(hp)
        if hitpoints = 0 then
          hitpoints:= 7
        writeln('You have encountered a level '+inttostr(hitpoints)+' '+monst+'!')
        wait(3000)
        cleardebug
        anim('Get Ready')
        answer:=readln('What do you want to do? type "Run" or "Fight"')
        if answer = 'run' then
        begin
          cleardebug
          anim('You run away...')
          idle
        end;
        if answer = 'fight' then
        begin
          cleardebug
          wait(500)
          fight
        end else
        anim('You find nothing of interest...')
      end else
      anim('You find nothing of interest...')
    end;
    
    //Readys the monster list for usage
    Procedure declaremonsters;
    begin
    m[1]:='Wolf'
    m[2]:='Bat'
    m[3]:='Spider'
    m[4]:='Rouge'
    m[5]:='Spirit'
    m[6]:='Slime'
    m[7]:='Soul Collecter'
    m[8]:='Reaper'
    m[9]:='Mage'
    m[10]:='Swordsman'
    m[11]:='Dwarf'
    m[12]:='Elf'
    m[13]:='Bowman'
    m[14]:='Valkrie'
    m[15]:='Sythe'
    end;
    
    procedure reportstats;
    begin
    writeln('/////////////////////////')
    writeln('//      Your Stats     //')
    writeln('/////////////////////////')
    writeln('')
    writeln('    AT:'+inttostr(at))
    writeln('    ST:'+inttostr(ST))
    writeln('    DF:'+inttostr(df))
    writeln('    HP:'+inttostr(hp))
    writeln('    Weapon:'+weapon)
    writeln('')
    writeln('/////////////////////////')
    end;
    
    procedure lvlup;
    var
    stat:string;
    begin
    stat:=readln('You have enough XP to increase a level! what do you want to increase? (AT, DF, ST, HP)')
    if stat='AT' then
      begin
      at:=at+1
      xp:=xp-100
      end;
    if stat='ST' then
      begin
      st:=st+1
      xp:=xp-100
      end;
    if stat='DF' then
      begin
      df:=df+1
      xp:=xp-100
      end;
    if stat='HP' then
      begin
      hp:=hp+1
      xp:=xp-100
      end;
    end;
    
    
    procedure fight;
    var
    lasthit,lasthit2,currentxp,currenthp:integer;
    begin
      begin
        repeat
        wait(2500)
        currenthp:=hitpoints-(lasthit-random(at+st*2))
        lasthit:=hitpoints-currenthp
        anim('You attack the '+monst+' with your '+weapon+'. You have dealt a total of '+inttostr(hitpoints-currenthp)+' damage so far.')
        anim('You attack the '+monst+' with your '+weapon+'. You have dealt a total of '+inttostr(hitpoints-currenthp)+' damage so far.')
        wait(2500)
        yourcurrenthp:=hp-(lasthit2-random(hitpoints-df))
        lasthit2:=hp-yourcurrenthp
        anim('The '+monst+ 'lunges at you ferociously. It has dealt a total of '+inttostr(hp-yourcurrenthp)+' damage so far.')
        anim('The '+monst+ 'lunges at you ferociously. It has dealt a total of '+inttostr(hp-yourcurrenthp)+' damage so far.')
        until(currenthp or yourcurrenthp=0)
        if currenthp<=0 then
          begin
          currentxp:=xp+(hitpoints/2)
          anim('You killed a level '+inttostr(hitpoints)+' with your '+weapon+' and gained '+inttostr(currentxp)+' experience!')
          xp:=currentxp
          if xp>100 then
            begin
            lvlup
            end;
          end;
        if yourcurrentxp=0 then
          begin
          anim('You have died....  GAME OVER')
          reportstats
          terminatescript
          end;
      end;
    end;
    
    
    
    procedure start;
    begin
    writeln('//////////////////////////////////////////////////////////////////////')
    writeln('//  //      //    //////////////////////////////////    //      //  //')
    writeln('//    /////////////    Welcome to RPG By ZFaith  ///////////////    //')
    writeln('//  //      //    //////////////////////////////////    //      //  //')
    writeln('//////////////////////////////////////////////////////////////////////')
    wait(5000)
    cleardebug
    wait(500)
    repeat
    anim('Press F11 to start')
    until(isfkeydown(11)=true)
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    repeat
    wait(random(200))//(creates a flicker effect)
    anim('Press F11 to enter the dungeon.')
    until(isfkeydown(11)=true)
    anim('You warily enter the dungeon- '+weapon+' in hand.')
    anim('You warily enter the dungeon- '+weapon+' in hand.')
    repeat
    idle
    answer2:=readln('Continue into the dungeon? type "yes" or "no" (your stats will be saved until you stop the script)')
    until(answer2='no')
    end;
    
    
    begin
    cleardebug
    writeln('Please Wait While The Game Compiles...')
    wait(3000)
    cleardebug
    wait(500)
    anim('Loading')
    declarestats;
    anim('Loading')
    declaremonsters;
    anim('Loading')
    repeat
    start
    until(false)
    end.
     
  3. Unread #2 - Jun 4, 2007 at 6:20 PM
  4. Town
    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5

    Town Grand Master
    Scar Programmers

    I need a couple bugs worked out...(Im confused beyond reason)

    You should use DeclareMonsters as a case after a monster is found.

    Code:
    procedure DeclareMonster;
    begin
      MonsterInt := Random(15);
      case Random(15) of
        0: Monst := 'wolf';
        1: Monst := 'bat';
        2: Monst := 'spider';
        3: Monst := 'rouge';
        4: Monst := 'Spirit';
      end;
    end;
    etc.

    Just declare that where "getmonster; monst:=m[monsterint]" is.
     
  5. Unread #3 - Jun 6, 2007 at 12:01 AM
  6. ZamorakianFaith
    Joined:
    Apr 28, 2005
    Posts:
    406
    Referrals:
    0
    Sythe Gold:
    0

    ZamorakianFaith Forum Addict
    Banned

    I need a couple bugs worked out...(Im confused beyond reason)

    does that solve the error? will the script run? can you explain other ways to use "where" etc.. please? Im trying to improve my skills.
     
  7. Unread #4 - Jun 6, 2007 at 10:16 AM
  8. Town
    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5

    Town Grand Master
    Scar Programmers

    I need a couple bugs worked out...(Im confused beyond reason)

    I'm not sure if it works but it should. Make DeclareMonster what I said above. Then replace "getmonster; monst:=m[monsterint]" with DeclareMonster.
     
< Buying lvl 87+ RS2 ( Pure ) Account - 1-4M | All Str Pure Owners Look Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site