Dark Age Games
Home Dark Age EX Dark Age 2 Message Board Fan Art FAQ Kelzar Mage DALpedia MS Forum
Board Index Dark Age General Bug Report Website Off Topic Register User Edit User User List Search

Xorlak (or other RPGCode coders)...
Posted by: Colin
21:36:52 03-18-2004

It really makes me feel degraded to ask for help, heh...

Anyhow, I am having a problem with #AddPlayer- I don't think it is my program's fault but I will post it just in case.

See, I am using #AddPlayer(var$). The contents of var$ is the filename but when the command runs it does nothing. Just for a test a tried putting the actual filename in the place... still nothing.

Here is the program (it's a battlesystem)...

NOTE: I wrote this several years ago and am now in the process of riving it for my game. There is a fair amount of repeated code in it for, as you already know, the RPGToolkit has no support for Multi-Dimensional arrays.

NOTE 2: I don't feel like putting the pre tag in front of every single line.

NOTE 3: Variables within HTML-like greater-than and lesser-than signs have been mis-read as tags and lost.

#Method Battle(enemy1$,enemy2$,enemy3$,background$)
{

      #Custom.Setup* Sets up my MWin

      #go_down!=0
      *#GetPlayerCoords(0,oldx!,oldy!)
      *#GetBoardName(oldboard$)

      #if(background$=="")
      {
            #Send(BoardBackground$,11,4,1)
            #ViewBrd(BoardBackgound$)
      }
      #if(background$~="")
      {
            #Send(Background$,11,4,1)
            #ViewBrd(Backgound$)
      }
      #Stance(43,playerHandle[0]$)
      #players!=1
      #If(playerHandle[1]$~="")
      {
            #PutPlayer(playerHandle[1]$,12,5,1)
            #players!=2
            #Stance(43,playerHandle[1]$)
      }
      #If(playerHandle[2]$~="")
      {
            #PutPlayer(playerHandle[2]$,11,6,1)
            #players!=3
            #Stance(43,playerHandle[2]$)
      }

      *Kill possible remnants of old stats...
      #stat.KillIt

      #if(enemy1$~="")
      {

            #to_run$="#Stat." + enemy1$
            #RPGCode(to_run$)
            #EnHp[1]!=hp!
            #EnDp[1]!=dp!
            #EnSp[1]$=sprite$
            #EnAt[1]$=attacks!
            #for(a!=1;a!<=attacks!;a!=a!+1)
            {
                  #EnFiPo1[a!]!=fightpow[a!]!
                  #EnFiMe1[a!]!=fightmet[a!]!
                  #EnFiDe1[a!]!=fightdelay[a!]!
                  #EnFiCo1[a!]!=fightcon[a!]!
                  #EnFiAn1[a!]!=fightanm[a!]!
            }
            #enemycount!=1

            ***********************************************
            ***********************************************
            *Here's what I'm talking about...
            #AddPlayer(sprite$)

            #temp!=players!
            #EnHa[1]$=PlayerHandle[temp!]$
            #PutPlayer(EnHa[1]$,3,3,1)
      }

      #if(enemy2$~="")
      {
            #to_run$="#Stat." + enemy2$
            #RPGCode(to_run$)
            #EnHp[2]!=hp!
            #EnDp[2]!=dp!
            #EnSp[2]$=sprite$
            #EnAt[2]$=attacks!
            #for(a!=1;a!<=attacks!;a!=a!+1)
            {
                  #EnFiPo2[a!]!=fightpow[a!]!
                  #EnFiMe2[a!]!=fightmet[a!]!
                  #EnFiDe2[a!]!=fightdelay[a!]!
                  #EnFiCo2[a!]!=fightcon[a!]!
                  #EnFiAn2[a!]!=fightanm[a!]!
            }
            #enemycount!=2
            #AddPlayer(sprite$)
            #temp!=players!+1
            #EnHa[2]$=PlayerHandle[temp!]$
            #PutPlayer(EnHa[2]$,3,5,1)
      }

      #if(enemy3$~="")
      {
            #to_run$="#Stat." + enemy3$
            #RPGCode(to_run$)
            #EnHp[3]!=hp!
            #EnDp[3]!=dp!
            #EnSp[3]$=sprite$
            #EnAt[3]$=attacks!
            #for(a!=1;a!<=attacks!;a!=a!+1)
            {
                  #EnFiPo3[a!]!=fightpow[a!]!
                  #EnFiMe3[a!]!=fightmet[a!]!
                  #EnFiDe3[a!]!=fightdelay[a!]!
                  #EnFiCo3[a!]!=fightcon[a!]!
                  #EnFiAn3[a!]!=fightanm[a!]!
            }
            #enemycount!=3
            #AddPlayer(sprite$)
            #temp!=players!+2
            #EnHa[3]$=PlayerHandle[temp!]$
            #PutPlayer(EnHa[3]$,3,5,1)
      }

      #enemyturn!=0
      #currentplayer!=-1
      *Load the move menu:
      #SetImage("moveback.bmp",450,160,110,160)
      #if(boss!==1)
      {
            #SetImage("movebacknorun.bmp",450,160,110,160)
      }
***********************************************
      #main_loop!=0
      #while(main_loop!==0)
      {
            #misses!=0
            #currentplayer!=currentplayer!+1
    #temp!=players!-1
            #if(currentplayer!>temp!) {#currentplayer!=0}
            #if(go_down!==1)
            {
                  #MWin("Defense power has returned to normal!")
                  #system.pause
                  #MWinCls()
                  #go_down!=0

                  #if(PlayerHandle[currentplayer!]$=to_go_down$)
                  {
                        #GetDP(to_go_down$,temp!)
                        #temp!=temp!-to_go_down_by!
                        #CastLit(temp!,temp$)
                        #to_run$="#" + to_go_down$ + "[defence]!=" + temp2$
                        #RPGCode(to_run$)
                  }
            }
***********************************************
            #SaveScreen()
            #Text(8,1,playerHandle[currentplayer!]$)
            #GetSMP(playerHandle[currentplayer!]$,playersmp!)
            #GetMaxSMP(playerHandle[currentplayer!]$,playermaxsmp!)
            #Text(8,2,"Remaining MP : <playersmp!>/<playermaxsmp!>")
            #Kill(playersmp!)
            #Kill(playermaxsmp!)
            #GetHP(playerHandle[currentplayer!]$,playerhp!)
            #GetMaxHP(playerHandle[currentplayer!]$,playermaxhp!)
            #Text(8,3,"Remaining Health: <playerhp!>/<playermaxhp!>")
            #Kill(playerhp!)
            #Kill(playermaxhp!)
            *Your turn:
            #MidiPlay(Music$)
            #key_done!=0
***********************************************
            #if(statuseffect!==1)
            {
                  #RPGCode(status$)
                  #MWinCls()
            }
***********************************************
            :vt
            #key_done!=0
            #while(key_done!==0)
            {
                  #wait(key$)
                  #if(key$=="1") {#key_done!=1}
                  #if(key$=="2") {#key_done!=1}
                  #if(key$=="3") {#key_done!=1}
                  #if(key$=="4") {#key_done!=1}
                  #if(key$=="5") {#key_done!=1}
            }
            #RestoreScreen()
***********************************************
            #if(key$=="1") *fight:
            {
                  :topoffight
  #if(enemycount!=1) {#Branch(:MiddleOfFight)}

                  #Profile("on")
                  #SetProfile("Gregory_Profile.bmp")
                  #MWin(" Which enemy are you attacking?")
                  #MWin(" 1 - <enemycount!>")
                  #ClearBuffer()
                  #done!=0
                  #while(done!=0)
                  {
                        #Wait(key$)
                        #if(key$="1") {#done!=1}
                        #if(key$="2") {#done!=1}
                        #if(key$="3") {#done!=1}
                  }
                  #MWinCls()
                  #CastNum(key$,key2!)
                  #if(key2!>enemycount!)
                  {
                        #MWin(" I am afraid there aren't that many enemies!")
                        #System.Pause
                        #MWinCls()
                        #Branch(:topoffight)
                  }
                  #Profile("off")
  :MiddleOfFight
                  #Wav("Fight.wav")
                  #SaveScreen()
                  #for(count!=17;count!<=20;count!=count!+1)
                  {
                        #Stance(count!,playerHandle[currentplayer!]$)
                        #Delay(.1)
                  }
                  #Delay(.5)
                  #for(count!=24;count!<=28;count!=count!+1)
                  {
                        #Stance(count!,EnHa[key2!]$)
                        #Delay(.1)
                  }
                  #GetFP(playerHandle[currentplayer!]$,playerfp!)
                  #damage! = playerfp! - EnDp[key2!]!
                  #Text(8,1,"Damage Dealt: <damage!>")
                  #Kill(playerfp!)
                  #EnHp[key2!]! = EnHp[key2!]! - damage!
                  #Delay(2)
                  #RestoreScreen()
            }
***********************************************
            #if(key$=="2") *magic
            {
                  #special.moves *Run the special moves method!
            }
***********************************************
            #if(key$=="4") *defend
            {
                  #MWin("Defense power will raise for this turn!")
                  #system.pause
                  #MWinCls()
                  #Wav("Item.wav")

                  #go_down!=1
                  #to_go_down$=PlayerHandle[currentturn!]$
                  #GetDP(PlayerHandle[currentturn!]$,temp!)
                  #temp!=temp!*0.1
                  #to_go_down_by!=temp!
                  #GiveDP(PlayerHandle[currentturn!]$,temp!)
            }
***********************************************
            #if(key$=="3") *items:
            {
                  #SaveScreen()
                  #SetImageTranslucent("MWin.jpg",0,0,600,350)
                  #ClearBuffer()
                  #Text(1,1,"Choose an item to use:")
                  #For(a!=1;a!<11;a!=a!+1)
                  {
                        #battles[a!]!=0
                        #if(items[a!]$~="")
                        {      
                              #battle$="no"
                              #My2.ItemInfo(items[a!]$)
                              #if(battle$=="yes")
                              {
                                    #Print("<a!> - <handle$>")
                                    #battles[a!]!=1
                              }
                        }
                  }
                  #Print("c - Cancel")
                  #key_done!=0
                  #while(key_done!==0)
                  {
                        #ClearBuffer()
                        #wait(key$)
                        #For(a!=0;a!<10;a!=a!+1)
                        {
                              #do_it!=0
                              #if(battles[a!]!==1) {#do_it!=1}
                              #if(a!==0) {#if(battles[10]!==1) {#do_it!=1}
                              #if(do_it!==1)
                              {
                                    #CastLit(a!,b$)
                                    #if(key$==b$) {#key_done!=1}
                              }
                        }
                        #if(key$=="C") {#key_done!=1}
                  }
                  #Kill(do_it!)
                  #RestoreScreen()
                  #if(key$=="C") {#Branch(:itemdone)}
                  #CastNum(key$,choice!)
                  #My2.ItemInfo(items[choice!]$)
                  #if(choice!==0) {#choice!=10}
                  #item_to_throw!=choice!
                  #items[item_to_throw!]$=""
                  *knock all items back a slot:
                  #throw_done!=1
                  #For(a!=2;a!<11;a!=a!+1)
                  {
                        #if(a!>item_to_throw!)
                        {
                              #correctslot!=a!-1
                              #items[correctslot!]$=items[a!]$
                              #if(a!==10)
                              {
                                    #items[10]$==""
                              }
                        }
                  }
                  #if(useon$=="player")
                  {
                        #Profile("on")
                        #SetProfile("Gregory_Profile.bmp")
                        #If(restore!~=0)
                        {
                              #MWin(" <playerHandle[currentplayer!]$> restored <restore!> HP!")
                              *#system.pause
                              *#MWInCls()
                        }
                        #If(damage!~=0)
                        {
                              #Delay(1)
                              #MWin(" The recoil hurt <playerHandle[currentplayer!]$> <damage!> HP!")
                              *#system.pause
                              *#MWInCls()
                        }
                        #If(MPgive!~=0)
                        {
                              #Delay(1)
                              #MWin(" <playerHandle[currentplayer!]$> gained <MPgive!> MP!")
                              *#system.pause
                              *#MWInCls()
                        }
                        #If(MPtake!~=0)
                        {
                              #Delay(1)
                              #MWin(" <playerHandle[currentplayer!]$> lost <MPtake!> MP!")
                        }
                        #system.pause
                        #MWInCls()
                        #Profile("off")
                        *actually do the stuff:
                        *restore health:
                        #GiveHP(playerHandle[currentplayer!]$,restore!)
                        *recoil:
                        #GiveHP(playerHandle[currentplayer!]$,-damage!)
                        *MP Gain:
                        #GiveSMP(playerHandle[currentplayer!]$,MPgive!)
                        *MP Take:
                        #GiveSMP(playerHandle[currentplayer!]$,-MPtake!)
                  }
                  #if(useon$=="enemy")
                  {
                        :topofitemattack
#if(enemycount!=1) {#Branch(:middleofitemattack)}
                        #Profile("on")
                        #SetProfile("Gregory_Profile.bmp")
                        #MWin(" Which enemy are you attacking?")
                        #MWin(" 1 - <enemycount!>")
                        #ClearBuffer()
                        #done!=0
                        #while(done!=0)
                        {
                              #Wait(key$)
                              #if(key$="1") {#done!=1}
                              #if(key$="2") {#done!=1}
                              #if(key$="3") {#done!=1}
                        }
                        #MWinCls()
                        #CastNum(key$,key2!)
                        #if(key2!>enemycount!)
                        {
                              #MWin(" I am afraid there aren't that many enemies!")
                              #System.Pause
                              #MWinCls()
                              #Branch(:topofitemattack)
                        }
:middleofitemattack
                        #If(damage!~=0)
                        {
                              #SaveScreen()
                              #for(count!=24;count!<=28;count!=count!+1)
                              {
                                    #Stance(count!,EnHa[key2!]$)
                                    #Delay(.1)
                              }
                              #RestoreScreen()
                              #GetFP(playerHandle[currentplayer!]$,playerfp!)
                              #damage! = playerfp! - EnDp[key2!]!
                              #SaveScreen()
                              #Text(8,1,"Damage Dealt: <damage!>")
                              #Kill(playerfp!)
                              #EnHp[key2!]! = EnHp[key2!]! - damage!
                              #Delay(2)
                              #RestoreScreen()
                        }
                        #Profile("off")
                  }
                  #If(Method$~="") {#RPGCode(Method$)}
                  #Kill(choice!)
                  #Kill(key$)
                  #Kill(key_done!)
                  #Kill(MPtake!)
                  #Kill(MPgive!)
                  #Kill(handle$)
                  #Kill(restore!)
                  #Kill(damage!)
            }
            :itemdone
***********************************************
            #if(key$=="5") *run:
            {
                  #if(boss!==1)
                  {
                        #MWin("You can't run from this enemy!")
                        #system.pause
                        #MWinCls()
                  }
                  #if(boss!~=1)
                  {
                        #random(10,run!)
                        #if(run!<=6)
                        {
                              #main_loop!=1
                              #battleover!=3
                        }
                        #if(run!>6)
                        {
                              #MWin("You didn't get away!")
                              #system.pause
                              #MWinCls()
                        }
                  }
            }
***********************************************
            #if (hp!<=0) *enemy is dead:
            {
                  #main_loop!=1
                  #battleover!=2
            }
***********************************************
            *Enemy's turn:

            #enemyturn!=enemyturn!+1
            #if(enemyturn!>enemycount!) {#enemyturn!=1}
            #if(enemyturn!=1)
            {
                  #hp!=EnHp[1]!
                  #dp!=EnDp[1]!
                  #attacks!=EnAt[1]$
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                     {
                        #fightpow[a!]!=EnFiPo1[a!]!
                             #fightmet[a!]!=EnFiMe1[a!]!
                        #fightdelay[a!]!=EnFiDe1[a!]!
                        #fightcon[a!]!=EnFiCo1[a!]!
                        #fightanm[a!]!=EnFiAn1[a!]!
                  }
            }
            #if(enemyturn!=2)
            {
                  #hp!=EnHp[2]!
                  #dp!=EnDp[2]!
                  #attacks!=EnAt[2]$
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                     {
                        #fightpow[a!]!=EnFiPo2[a!]!
                             #fightmet[a!]!=EnFiMe2[a!]!
                        #fightdelay[a!]!=EnFiDe2[a!]!
                        #fightcon[a!]!=EnFiCo2[a!]!
                        #fightanm[a!]!=EnFiAn2[a!]!
                  }
            }
            #if(enemyturn!=3)
            {
                  #hp!=EnHp[3]!
                  #dp!=EnDp[3]!
                  #attacks!=EnAt[3]$
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                     {
                        #fightpow[a!]!=EnFiPo3[a!]!
                             #fightmet[a!]!=EnFiMe3[a!]!
                        #fightdelay[a!]!=EnFiDe3[a!]!
                        #fightcon[a!]!=EnFiCo3[a!]!
                        #fightanm[a!]!=EnFiAn3[a!]!
                  }
            }
            #enemyattack!=0
            #While(enemyattack!==0)
            {
                  #Random(attacks!,to_do!)
                  #if(fightcon[to_do!]!>=mp!)
                  {
                        #SaveScreen()
                        #if(fightmet[to_do!]$~="") {#RPGCode(fightmet[to_do!]$)}
                        #if(fightanm[to_do!]$~="")
                        {
                              #to_run$="#Anim." + fightanm[to_do!]$
                              #RPGCode(to_run$)
      #RestoreScreen()
                        }
                        :topofloop
                        #range!=players!+1
                        #Random(range!,rnd!)
                        #Kill(range!)
                        #rnd!=rnd!-1
                        #GetHP(playerhandle[rnd!]$,playerhp!)
                        #if(playerhp!<=0) {#Branch(:topofloop)}
                        #Kill(playerhp!)
                        #GetDP(playerHandle[rnd!]$,playerdp!)
                        #damage!= fightpow[to_do!]! - playerdp!
                        #if(damage!<0) {#damage! = 0}
                        #dealdamage!=0-damage!
                        #GiveHP(playerHandle[rnd!]$,dealdamage!)
                        #Kill(dealdamage!)
                        #for(count!=25;count!<=28;count!=count!+1)
                        {
                              #Stance(count!,playerHandle[rnd!]$)
                        }
                        #if(fightcon[to_do!]!>0)
                        {
                              #Text(8,3,"MP Used: <fightcon[to_do!]!>")
                        }
                        #if(damage!>0)
                        {
                              #Text(8,2,"<playerHandle[rnd!]$> was hurt: <damage!>")
                        }
                        #hp!=hp!+fightres[to_do!]!
                        #if(fightres[to_do!]!>0)
                        {
                              #Text(8,3,"Enemy Restored: <fightres[to_do!]!>")
                        }
                        #GiveHP(playerHandle[rnd!]$,fightplres[to_do!]!)
                        #if(fightplres[to_do!]!>0)
                        {
                              #Text(8,4,"You Restored: <fightplres[to_do!]!>")
                        }
                        #Delay(fightdelay[to_do!]!)
                        #RestoreScreen()
                        #mp!=mp!-fightcon[to_do!]!
                        #enemyattack!=1
                        }

                  }
            }
                 #if(enemyturn!=1)
            {
                       #EnHp[1]!=hp!
                  #EnDp[1]!=dp!
                  #EnAt[1]$=attacks!
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                  {
                        #EnFiPo1[a!]!=fightpow[a!]!
                             #EnFiMe1[a!]!=fightmet[a!]!
                          #EnFiDe1[a!]!=fightdelay[a!]!
                        #EnFiCo1[a!]!=fightcon[a!]!
                        #EnFiAn1[a!]!=fightanm[a!]!
                  }
            }
                 #if(enemyturn!=2)
            {
                     #EnHp[2]!=hp!
                  #EnDp[2]!=dp!
                  #EnAt[2]$=attacks!
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                  {
                        #EnFiPo2[a!]!=fightpow[a!]!
                             #EnFiMe2[a!]!=fightmet[a!]!
                          #EnFiDe2[a!]!=fightdelay[a!]!
                        #EnFiCo2[a!]!=fightcon[a!]!
                        #EnFiAn2[a!]!=fightanm[a!]!
                  }
            }
                 #if(enemyturn!=3)
            {
                     #EnHp[3]!=hp!
                  #EnDp[3]!=dp!
                  #EnAt[3]$=attacks!
                  #for(a!=1;a!<=attacks!;a!=a!+1)
                  {
                        #EnFiPo3[a!]!=fightpow[a!]!
                             #EnFiMe3[a!]!=fightmet[a!]!
                          #EnFiDe3[a!]!=fightdelay[a!]!
                        #EnFiCo3[a!]!=fightcon[a!]!
                        #EnFiAn3[a!]!=fightanm[a!]!
                  }
            }
      }
***********************************************
            *Is the player dead?
            #skipover!=0
            #For(b!=0;b!<=players!;b!=b!+1)
            {
                  #GetHP(playerHandle[b!]$,playerhp!)
                  #if(playerhp!>0) {#skipover!=1}
                  #Kill(playerhp!)
            }
            #if(skipover!~=1)
            {
                  #main_loop!=1
                  #battleover!=1
                  #for (count!=29;count!<=32;count!=count!+1)
                  {
                        #For(a!=0;a!<=players!;a!=a!+1)
                        {
                              #Stance(count!,playerHandle[a!]$)
                        }
                  }
            }
            #Kill(skipover!)
            #ClearBuffer()
***********************************************
      }* end of main loop

      *battle is over:
      #if(battleover!=1)
      {
            #if(Lose_Program$~="")
            {
                  #temp$=Lose_Program$
                  #Lose_Program$=""
                  #Run(temp$)
            }
            #MWin("Slain...")
            #system.pause
            #MWinCls()
            #special.gameover
            #Empty()
            #Windows()
      }
      #if(battleover!=2)
      {

    *MAJOR FIXING REQUIRED NOW THAT ENEMIES ARE SPRITES
            #SizedAnimation(die$,30,40,width!,height!)

            #if(winfight$~="") {#RPGCode(winfight$)}
            #GiveGP(gm!)
            #For(a!=0;a!<=players!;a!=a!+1)
            {
                  #GiveEXP(playerHandle[a!]$,exp!)
            }
            #Kill(a!)
            #MWin("Players gained <exp!> exp!")
            #system.pause
            #MWinCls()
            #MWin("Players gained <gm!> Golden Ms!")
            #system.pause
            #MWinCls()
      }
      #if(battleover!=3)
      {
            #players!=players!-1
            #for(a!=0;a!<=players!;a!=a!+1)
            {
                  #PathFind(PlayerX[a!]!,PlayerY[a!]!,19,PlayerY[a!]!,temp$)
                  #Push(temp$,PlayerHandle[a!]$)
            }
            #Profile("on")
            #SetProfile("Gregory_Profile.bmp")
            #MWin(" You made it away!")
            #system.pause
            #MWinCls()
            #Profile("off")
      }
***********************************************
      #walkspeed("fast")
      *Kill all useless variables (unfortunently I've missed about 106787 of them)...
      #Kill(exp!)
      #Kill(gm!)
      #Kill(width!)
      #Kill(height!)
      #Kill(count!)
      #Kill(dp!)
      #Kill(hp!)
      #Kill(main_loop!)
      #Kill(battleover!)
      #Kill(run!)
      #Kill(players!)
      #Kill(go_down!)
      #Kill(main_loop!)
      #Kill(key_done!)
      #Kill(damage!)
      #Kill(winfight$)
      #Kill(enemyattack!)
      #Send(oldboard$,oldx!,oldy!,1)
      #Kill(oldboard$)
      #Kill(oldx!)
      #Kill(oldy!)
      #Kill(b$)
      #Kill(rnd!)
      #Kill(key$)
      #Kill(temp!)
}

Edit Post