Author Topic: (no subject)  (Read 2726 times)

Dragonmaster

  • Member
  • *
  • Posts: 11
    • View Profile
(no subject)
« on: July 27, 2004, 10:04:56 PM »
Im having trouble correctly implementing the funcitonality that I want in my battle system with the savescreen/restorescreen.  Right now Im using cache screen, but I dont watnt to have to use a plugin.  I was hoping someone could give me some pointers on when and where to put them in order to get the effect.

heres the main battle code:
Code: [Select]
#Method battle(benemy[1]$, benemy[2]$, benemy[3]$, benemy[4]$, backgroundpic$, run$)
{
#newplyr("blank.tem")
#send("black.brd",1,1,1)
#bitmap(backgroundpic$)
#NewPlyr ("Damien.tem")
#battleend! = 0
#charactersplayed! = 0
#enemiesplayed! = 5
*cursor settings
  #cursor0! = 120
  #cursor1! = 140
  #cursor2! = 158
  #cursor3! = 175
  #cursor4! = 193
  #cursor5! = 210
  #CacheScreen(0)
  #loadenemies()
  #positionplayers()
  #positionenemies()
  #listchars()
  #CacheScreen(1)
*****Main While******
 #While(battleend! = 0)
 {
   #flipscreen(1)
   #drawbars()
  *#positionenemies()
   #input$ = ""
  #if(playablecharacters! > 0)
  {
    #if(charactersplayed! < playablecharacters!)
    {
      #playerschoice()
    }
    #if(charactersplayed! >= playablecharacters!)
    {
     #Mwin("Enemies turn to fight")
     *#enemyturn()
     #battleend! = 1
    }
  }
  #if(playablecharacters! = 0)
  {
   #battleend! = 1
  }
  #if(numenemies! = 0)
  {
   #battleene! = 1
  }
 }
#kill(battleend!)
#kill(charactersplayed!)
#kill(numenemies!)
#BattleEnd()
}

#Method positionplayers()
{
 #y_to_player! = 1.3
 #For(i! = 0; i! < 4; i! = i! + 1)
 {
   #y_to_player! = y_to_player! + 1.7
   #putplayer(playerhandle[i!]$,3,y_to_player!,8)
   *#if(hp[i!]! = 0)
   *{
   *}
   #if(hp[i!]! ~= 0)
   {
   #stance(43,playerhandle[i!]$)
   }
 }
}
#Method listchars()
{
#ColorRGB(255,255,255)
#x_to_text! = 1
#x_to_pic! = 3
#For(i! = 0; i! < 4; i! = i! + 1)
 {
  * #Mwin(playerhandle[i!]$)
  #if(playerhandle[i!]$ ~= "")
   {
   #GetHP(playerhandle[i!]$, hp[i!]!)
   #getmaxhp(playerhandle[i!]$,maxhp[i!]!)
   #getsmp(playerhandle[i!]$,mp[i!]!)
   #getmaxsmp(playerhandle[i!]$,maxmp[i!]!)
   #code$ = "#playerprofile$ = " + playerhandle[i!]$ +"profile.gif"
   #rpgcode(code$)
   #x_to_text! = x_to_text! + 3
   #SetImage(playerprofile$,x_to_pic!,380,54,54)
   #x_to_pic! = x_to_pic! + 126
   }
 }
}

#Method Drawbars()
{
#barlength! = 70
#barstart! = 70
#aroundbarlength! = 71
#aroundbarstart! = 69
#FontSize(16.3)
#textstart! = 4.7
#For(i! = 0; i! < 4; i! = i! + 1)
 {
  * #Mwin(playerhandle[i!]$)
  #if(playerhandle[i!]$ ~= "")
   {
    *Write Player's name  
       #ColorRGB(255,255,255)
       #Text(textstart!,25.5,playerhandle[i!]$)
    *draw surrounding HP blue rectangle
    *  #ColorRGB(255,255,255)
    *  #aroundbarend! = aroundbarstart! + aroundbarlength!
    *  #DrawRect(aroundbarstart!,399,aroundbarend!,418)
    *draw HP black bar
    *  #ColorRGB(0,0,0)
    *  #blackbarend! = barstart! + barlength!
    *  #FillRect(barstart!,400,blackbarend!,417)
    *draw current HP bar
    *  #ColorRGB(155,9,34)
    *  #actlength! = hp[i!]!/maxhp[i!]! * barlength!
    *  #hpbarend! = barstart! + actlength!
    *  #FillRect(barstart!,400,hpbarend!,417)
    *Write the HP on the bar
      #ColorRGB(255,255,255)
      #Text(textstart!, 27.2,"1000/1000")
    *draw surrounding MP white rectangle
    * #ColorRGB(255,255,255)
    *  #aroundbarend! = aroundbarstart! + aroundbarlength!
    *  #DrawRect(aroundbarstart!,429,aroundbarend!,448)
    *draw MP black bar
    *  #ColorRGB(0,0,0)
    *  #blackbarend! = barstart! + barlength!
    *  #FillRect(barstart!,430,blackbarend!,447)
    *draw current MP bar
    *  #ColorRGB(0,0,240)
    *  #actlength! = mp[i!]!/maxmp[i!]! * barlength!
    *  #mpbarend! = barstart! + actlength!
    *  #FillRect(barstart!,430,mpbarend!,447)
    *Write the MP on the bar
      #ColorRGB(255,255,255)
      #Text(textstart!, 27.9,"<mp[i!]!>/<maxmp[i!]!>")
    *set up variables for next loop
      #textstart! = textstart! + 7.9
      #aroundbarstart! = aroundbarstart! + 140
      #barstart! = barstart! + 140
     #if(hp[i!]! ~= 0)
     {
      #playablecharacters! = i! + 1
     }
   }
}
#kill(barlength!)
#kill(barstart!)
#kill(hpbarend!)
#kill(mpbarend!)
#kill(actlength!)
#kill(aroundbarstart!)
#kill(aroundbarend!)
#kill(aroundbarlength!)
#kill(blackbarstart!)
#kill(blackbarend!)
#kill(textstart!)
}
#Method loadenemies()
{
  #for(k! = 1; k! <= numenemies!; k! = k!+1)
  {
   #code$ = "#enemyprg$ = enemy" + benemy[k!]$ + ".prg"
   #RPGCode(code$)
   #include(enemyprg$)
   #code$="#LoadEnemy_"+ benemy[k!]$
   #rpgcode(code$)
   #Enemy_Name[k!]$=En[Name]$
   #Enemy_MaxHP[k!]!=En[MaxHP]!
   #Enemy_HP[k!]!=En[HP]!
   #Enemy_MaxMP[k!]!=En[MaxMP]!
   #Enemy_MP[k!]!=En[MP]!
   #Enemy_Attack[k!]!=En[Attack]!
   #Enemy_Defense[k!]!=En[Defense]!
   #Enemy_Magic[k!]!=En[Magic]!
   #Enemy_Element]$=En[Element]$
   #Enemy_Exp[k!]!=En[Exp]!
   #Enemy_GP[k!]!=En[GP]!
   #Enemy_Pic[k!]$=En[Pic]$
   #Enemy_Graphic_Flash[k!]$=En[Graphic_Flash]$
   #Enemy_Graphic_Death[k!]$=En[Graphic_Death1]$
   #Enemy_Death_Anim[k!]$=En[Death_Anim]$
   #Enemy_X[k!]!=En_X[k!]!
   #Enemy_Y[k!]!=En_Y[k!]!
   #Enemy_Width[k!]!=En[Width]!
   #Enemy_Height[k!]!=En[Height]!
   #item[k!]$=En_Item$
   #for(i!=1;i!<=10;i!=i!+1){#Enemy_Attack[i!]$=En_Attack[i!]$}
  }
}
#Method positionenemies()
{
  #for(l! = 1; l! <= numenemies!; l! = l!+1)
  {
    #if(enemy_hp[l!]! ~= 0)
    {
    **#MWin("Enemy <l!>'s x is <Enemy_X[l!]!> y is <Enemy_Y[l!]!>")
     #SetImageTransparent(Enemy_Pic[l!]$, Enemy_X[l!]!,Enemy_Y[l!]!, Enemy_Width[l!]!, Enemy_Height[l!]!,255,255,255)
     ***#SetImage(playerprofile$,x_to_pic!,400,50,50)***
    }
    #if(enemy_hp[l!]! ~= 0)
    {
     #numenemies! = numenemies! - 1
    }
  }
}
#Method playerschoice()
{
  #if charactersplayed! < 4)
  {
   #if(hp[charactersplayed!]! = 0)
   {
    #charactersplayed! = charactersplayed! + 1
    #playerschoice()
   }
   #if(hp[charactersplayed!]! ~= 0)
   {
    *#highlightplayer(charactersplayed!)
    #showmenu(charactersplayed!)
    #charactersplayed! = charactersplayed! + 1
    #MWinCls()
   }
  }
}
#Method highlightplayer(playernum!)
{
      #ColorRGB(255,255,0)
      #x1! = playernum! * 150 + 9
      #x2! = playernum! + 1 * 150 + 4
      #DrawRect(x1!,397,x2!,466)
      #kill(playernum!)
}
#Method showmenu(playernum!)
{
     #SetImage("battlemenu.gif",150,90,100,140)
     #ColorRGB(0,0,0)
     #FontSize(18)
     #Bold("on")
     #Text(11, 6, playerhandle[charactersplayed!]$)
     #Text(11, 7.5, "Fight")
     #Text(11, 8.5, "Item")
     #Text(11, 9.5, "Special")
     #Text(11, 10.5, "Magic")
     #Text(11, 11.5, "Defend")
     #Text(11, 12.5, "Run")
     #Bold("off")
     #SaveScreen()
     #battleoption! = 0
     #battlemoveto! =0
     #While(battleoption! = 0)
     {
       #SetCursor()
       #Wait(a$)
       #If(a$=="ENTER")
       {
         #If(battlemoveto!==0)
         {
         *do fight stuff
         #FlipScreen(1)
         #Push("EEE", playerhandle[charactersplayed!]$)
         #for(j! = 17; j! <=19; j!=j!+1)
          {
           #Stance(j!,playerhandle[charactersplayed!]$)
           #delay(1)
          }
         #Stance(20, playerhandle[charactersplayed!]$)
         #delay(.5)
         #battleoption! = 1
         }
         #If(battlemoveto!==1)
         {
         *do defend
         }
         #If(battlemoveto!==2)
         {
         *do ability stuff
         *#action$ = "Ability"
         *#PickCharacter()
         }
         #If(battlemoveto!==3)
         {
         *#Mwin("Pick a character")
         *#action$ = "Stats"
         *#PickCharacter()
         }
         #If(battlemoveto!==5)
         {
         #battleoption! = 1
         }
       }
     #Setmoveto(a$,5, battlemoveto!)
   }
}
#Method SetCursor()
{
 *#RestoreScreen()
 #castlit(battlemoveto!,battlemoveto$)
 #code$ = "#cursory! = cursor" + battlemoveto$ + "!"
 #RPGcode(code$)
 #SetImage("cursor.gif", 155, cursory!, 14, 9)
}
#Method Setmoveto(movement$,limit!, moveresult!)
{
  #If(movement$=="DOWN")
  {
    #If(moveresult!==limit!)
    {
      #moveresult!=-1
    }
    #If(#moveresult! < limit!)
    {
      #moveresult!=moveresult!+1
    }
  }
  #If(movement$=="UP")
  {
    #If(moveresult!==0)
    {
      #moveresult!=limit!+1
    }
    #If(moveresult!>0)
    {
      #moveresult!=moveresult!-1
    }
  }
  #ReturnMethod(moveresult!)
}
#Method BattleEnd()
{
  #if(playablecharacters! = 0)
  {
   #MWin("Game Over")
  }
  #if(playablecharacters! ~= 0)
  {
  #kill(playablecharacters!)
  #ClearScreens()
  #kill(cursor0!)
  #kill(cursor1!)
  #kill(cursor2!)
  #kill(cursor3!)
  #kill(cursor4!)
  #kill(cursor5!)
  #kill(enemy[1]$)
  #kill(enemy[2]$)
  #kill(enemy[3]$)
  #kill(enemy[4]$)
  #kill(benemy[1]$)
  #kill(benemy[2]$)
  #kill(benemy[3]$)
  #kill(benemy[4]$)
  #NewPlyr ("Damien.tem")
  #send(backtobrd$,backtox!,backtoy!,backtolayer!)
  }
}
Many thanks
Dragonmaster
« Last Edit: December 31, 1969, 06:00:00 PM by Dragonmaster »

Dude Man

  • Member
  • *
  • Posts: 6393
    • View Profile
    • http://dmdgames.mysticsoftware.net//
(no subject)
« Reply #1 on: July 27, 2004, 10:09:20 PM »
My head hurts... :wacko: ....
« Last Edit: December 31, 1969, 06:00:00 PM by Dude Man »
~Welcome back mysticsoftware.net??
The Black Walkway

Xorlak

  • Administrator
  • Member
  • *****
  • Posts: 2225
    • View Profile
    • http://darkagegames.net
(no subject)
« Reply #2 on: July 28, 2004, 12:08:27 PM »
While you can only have one #savescreen at a time, remember that you can restore parts of the screen at a time if you want, for example:

#restorescreen(1,1,300,200,1,1)

will restore roughly only the upper left hand corner of the screen.  Take a look at the command reference for details on the parameters.

Another trick is using images rather than #restorescreen for cursors.  If your cursor is in front of a solid background, you can use an image of that background to erase it when the cursor moves (or a totally different image, like the bars I use in Dark Age 2's battle system).

Hope that helps!
« Last Edit: December 31, 1969, 06:00:00 PM by Xorlak »

Colin

  • Member
  • *
  • Posts: 299
    • View Profile
(no subject)
« Reply #3 on: July 28, 2004, 03:27:14 PM »
Or you can use TK3 which has multiple save/restore screens. =)
« Last Edit: December 31, 1969, 06:00:00 PM by Colin »
— Colin

Spyder

  • Member
  • *
  • Posts: 1695
    • View Profile
    • http://www.mysticsoftware.net
(no subject)
« Reply #4 on: July 28, 2004, 08:29:51 PM »
Boo!
« Last Edit: December 31, 1969, 06:00:00 PM by Spyder »

Dude Man

  • Member
  • *
  • Posts: 6393
    • View Profile
    • http://dmdgames.mysticsoftware.net//
(no subject)
« Reply #5 on: July 28, 2004, 11:28:21 PM »
I take you do not like TK3. It's not a bad toolkit. Just because it's a highly unstable peice of crap, dosen't make it a bad toolkit! Laughing
« Last Edit: July 29, 2004, 12:59:56 PM by Dude Man »
~Welcome back mysticsoftware.net??
The Black Walkway

Spyder

  • Member
  • *
  • Posts: 1695
    • View Profile
    • http://www.mysticsoftware.net
(no subject)
« Reply #6 on: July 29, 2004, 02:24:32 PM »
Quote from: "Dude Man"
I take you do not like TK3. It's not a bad toolkit. Just because it's a highly unstable peice of crap, dosen't make it a bad toolkit! Laughing

Actually I was being sarcastic...I figured people would figure that out considering there is a TK Development Project banner in my signiature....even though it's badly outdated.
« Last Edit: December 31, 1969, 06:00:00 PM by Spyder »

Dude Man

  • Member
  • *
  • Posts: 6393
    • View Profile
    • http://dmdgames.mysticsoftware.net//
(no subject)
« Reply #7 on: July 29, 2004, 05:32:25 PM »
I see....
« Last Edit: December 31, 1969, 06:00:00 PM by Dude Man »
~Welcome back mysticsoftware.net??
The Black Walkway