Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

Worms for mIRC!

Recommended Posts

  • Administrators
Do to my boredom, i am no longer designing Worms..

im giving the source out so someone can finish it - its fully(or mostly ) commented and has very few if none(unlikely ) pipes..

What needs done:

write the actual game

code the rest of the buttons in the lobby

finish the create/modify game

add some more options

make it look pretty

 

what is done:

almost everything is functional

game list box works, all the chat boxes work, scroll boxes work

options work

custom servers

chatting

more

 

there is a website: worms.vndv.com -- talk to me if u need to use it or have questions or whatever

 

well, heres the code.. go knock yourself out -- please provide credit to me, Wims, and Sophie(alloallo56)

 

 

alias Worms {

  if ($window(@Worms)) halt

  ;create our windows  - a main window that shows the game, a window with all of our sprites, and a buffer window that has the mountains and such that we can blow up :P

  window -pkodCfB +nt @Worms -1 -1 640 480 

  window -pkfBh @Wm.buf1 -1 -1 640 480

  window -pkfBh @Wm.buf2 -1 -1 640 480

  ;free the table if it exists, create the table, add our page variable so we know what page we're on, and goto the loop

  hadd -m Worms Page Menu

  ;create our options data

  hadd Worms Server IRC.WebChat.org

  hadd Worms Port 6668

  hadd Worms On-Top True

  ;draw our sprites and our sprite window lime(a color that not many things use)

  drawdot -r @Wm.buf1 65280 600 320 240

  drawrect -rf @Wm.buf2 8355711 1 0 300 640 380

  hadd Worms p1 100 100

  Worms.loop

}

alias -l Worms.loop {

  ;check to make sure the game is still running!, otherwise halt the game, and then set the ticks variable for the fps at the end of the script

  if (!$window(@Worms)) halt

  var %ticks $ticks

  ;clear the screen - (draws a huge white dot - bigger than the screen - in the middle of the screen)

  drawdot -nr @Worms 16777215 600 320 240

  ;we need to check what to draw

  if ($hget(Worms,Page) == Menu) {

    ;draw the title 

    var %i 0 | while (%i Play

      drawtext -nrp @Worms 200 arial 40 282 200 Play

    }

    else {

      drawtext -nr @Worms 3618615 arial 40 282 202 Play

      drawtext -nr @Worms 200 arial 40 282 200 Play

    }

    if ($inrect($mouse.x,$mouse.y,288,400,64,46)) {

      drawtext -nrp @Worms 3618615 arial 40 288 402 Exit

      drawtext -nrp @Worms 200 arial 40 288 400 Exit

    }

    else {

      drawtext -nr @Worms 3618615 arial 40 288 402 Exit

      drawtext -nr @Worms 200 arial 40 288 400 Exit

    }

    if ($inrect($mouse.x,$mouse.y,253,330,134,46)) {

      drawtext -nrp @Worms 3618615 arial 40 253 332 Options

      drawtext -nrp @Worms 200 arial 40 253 330 Options

    }

    else {

      drawtext -nr @Worms 3618615 arial 40 253 332 Options

      drawtext -nr @Worms 200 arial 40 253 330 Options

    }

  }

  ;our lobby

  if ($hget(Worms,Page) == Lobby) {

    ;draw the screen blue

    drawdot -nr @Worms 16762980 500 320 240

    ;draw the frames

    drawrect -nr @Worms 0 1 10 10 620 140

    drawrect -nr @Worms 0 1 10 170 460 140

    drawrect -nr @Worms 0 1 10 330 460 140

    drawline -nr @Worms 0 1 10 450 470 450

    drawline -nr @Worms 0 1 440 450 440 470

    drawrect -nr @Worms 0 1 150 152 100 16

    drawrect -nr @Worms 0 1 260 152 100 16

    drawrect -nr @Worms 0 1 370 152 100 16

    drawrect -nr @Worms 0 1 480 149 150 16 

    drawtext -nr @Worms 0 tahoma 9 484 151 $iif($line(@Wm.games,0), $v1, 0) $iif($v1 == 1, Game, Games)

    if ($hget(Worms,Connected) == True) drawtext -nr @Worms 0 tahoma 9 $iif($hget(Worms,Game), 172 154 Modify, 167 154 Create a) Game 

    if ($hget(Worms,GameSel)) drawtext -nr @Worms 0 tahoma 9 288 154 Join Game 

    drawtext -nr @Worms 0 tahoma 9 397 154 Main Menu 

    ;only draw 'Send' if theres text

    if ($hget(Worms,chm)) drawtext -nr @Worms 0 tahoma 10 444 454 Send

    drawrect -nr @Worms 0 1 480 170 150 300

    drawline -nr @Worms 0 1 10 294 470 294

    drawline -nr @Worms 0 1 480 454 630 454

    ;draw the refresh button for the news

    drawrect -nr @Worms 0 1 10 155 50 16

    drawtext -nr @Worms 0 tahoma 9 20 158 Refresh

    ;draw the clear button for the chat box

    drawrect -nr @Worms 0 1 10 315 50 16

    drawtext -nr @Worms 0 tahoma 9 23 318 Clear

    ;draw the refresh for the games list

    drawrect -nr @Worms 0 1 80 149 50 16

    drawtext -nr @Worms 0 tahoma 9 90 152 Refresh

    ;draw our total users

    drawtext -nr @Worms 0 tahoma 9 484 456 $iif($Line(@Wm.chat,0,1) == 0, 0, $v1) $iif($v1 == 1, Player, Players)

    ;draw the users

    var %3 1 | while (%3  23, 23, $v1)) { 

      if ($line(@Wm.chat,$calc(%3 + %Wm.ppos),1)) drawtext -nrc @Worms 0 tahoma 9 484 $calc(163 + (%3 * 12)) 142 12 $v1

      inc %3

    }

    ;draw the text to the chat

    var %l 1 | while (%l  9, 9, $v1)) { 

      if ($line(@Wm.chat,$calc(%l + %Wm.cpos))) drawtext -nrc @Worms 0 tahoma 9 14 $calc(445 - (%l * 12)) 450 12 $v1

      inc %l

    }

    ;draw the little beam on the edit box if @worms is the active window

    if ($active == @Worms) && ($appactive) && ($ticks & 8) && ($hget(Worms,Connected) == True) {

      if ($width($hget(Worms,chm),tahoma,9)  $v1

        hdel Worms chm

      }

      ;if we hit refresh, get the news again - and only if were connected, so we dont interupt it

      if ($inrect($mouse.x,$mouse.y,10,155,50,16)) && ($hget(Worms,Connected) == True) {

        clear @Wm.news

        .sockclose Wm.News

        sockopen Wm.News worms.vndv.com 80 

      }

      ;clear button

      if ($inrect($mouse.x,$mouse.y,10,315,50,16)) && ($hget(Worms,Connected) == True) {

        clear @Wm.chat

      }

      ;main menu

      if ($inrect($mouse.x,$mouse.y,370,152,100,16)) {

        sockclose WM*

        hdel Worms Connected

        window -c @Wm.chat

        window -c @Wm.news

        window -c @Wm.Games

        hadd Worms Page Menu

      }

      ;the join a game

      if ($inrect($mouse.x,$mouse.y,260,152,100,16)) {



      }

      ;create/modify game

      if ($inrect($mouse.x,$mouse.y,150,152,100,16)) && ($hget(Worms,Connected) == True) {

        hadd Worms page Create

        ;create some settings for our game

        hadd Worms GameSets $me $+ : $+ $me $+ 's Game:3

      }

    }

    ;our options page

    if ($hget(Worms,Page) == Options) {

      ;if we want to change the server or the port

      if ($inrect($mouse.x,$mouse.y,400,20,105,36)) hadd Worms Server $iif($input(Enter a server,eqdo,New Server), $v1, $Hget(Worms,Server))

      if ($inrect($mouse.x,$mouse.y,400,60,105,36)) hadd Worms Port $iif($input(Enter a port,eqdo,New Port), $v1, $Hget(Worms,Port))

      ;go back if we click menu

      if ($inrect($mouse.x,$mouse.y,600,10,30,20)) hadd Worms Page Menu

    }

    ;the create a game page

    if ($hget(Worms,Page) == Create) {

      ;if we click to go back

      if ($inrect($mouse.x,$mouse.y,600,10,30,20)) hadd Worms Page Lobby

      ;if we click create

      if ($inrect($mouse.x,$mouse.y,500,400,130,70)) { 

        ;create our game and delete the settings

        hadd Worms Game $hget(Worms,GameSets) | hdel Worms GameSets

        sockwrite -n WMP PRIVMSG #Worms WM.Create $hget(Worms,Game)

        iline 1 @Wm.chat 1  You have successfully created a new game.

        hadd Worms Page Lobby

      }

      ;delete a game

      if ($inrect($mouse.x,$mouse.y,10,450,100,20)) && ($hget(Worms,Game)) {

        sockwrite -n WMP PRIVMSG #Worms WM.Del $me $+ : $+ $gettok($hget(Worms,Game),2,58)

        hdel Worms Game 

        iline 1 @Wm.Chat 1  You have successfully ended your game.

        hadd Worms Page Lobby

      }

    }

  }

  sclick: {

    ;scroll bars clicking and the games list box

    if ($hget(Worms,Page) == Lobby) {

      if ($inrect($mouse.x,$mouse.y,455,330,15,15)) && (%Wm.cpos  0) dec %Wm.cpos

      if ($inrect($mouse.x,$mouse.y,615,440,15,15)) && (%Wm.ppos  0) dec %Wm.ppos

      if ($inrect($mouse.x,$mouse.y,615,135,15,15)) && (%Wm.gpos  0) dec %Wm.gpos

      ;what happens when we click this ? hmm..

      if ($inrect($mouse.x,$mouse.y,10,10,620,140)) {

        var %numgames $calc($floor($calc(($mouse.y - 10) / 12)) + %Wm.gpos)

        if ($calc($line(@Wm.Games,0) - 1) >= %numgames) && ($line(@Wm.Games,%numgames)) hadd Worms GameSel $calc(%numgames + 1)

      }

      ;;write a join game function here -- this has all of the pre game setup, like variable declarations and stuff like that

      /**************************************************

      ***************************************************

      **************************************************/

      }

      }

      }

      ;our keydown events for keypressing

      on *:KEYDOWN:@Worms:*: { 

      ;check if its the lobby, so we can use the chat box

      if ($Hget(Worms,Page) == Lobby) && ($hget(Worms,Connected) == True) { 

      ;if we press the space bar, replace it with '?' due to mIRC's weird space handling

      if ($keyval == 32) { hadd Worms chm $regsubex($hget(worms,chm),/(.)/g,$iif(\n == $hget(worms,cpos),$+(\t,$chr(160)),\t)) | hinc Worms CPos }

      ;if we press the backspace key we delete the last key(if there is one)

      elseif ($keyval == 8) { if ($hget(Worms,chm)) { hadd Worms chm $regsubex($hget(Worms,chm),/(.)/g,$iif(\n != $hget(Worms,Cpos),\t)) } | if ($hget(Worms,CPos) > 0) hdec Worms CPos }

      ;if we press enter, add the message to the chat window and delete it from our temp

      elseif ($keyval == 13) { if ($hget(Worms,chm)) {

        iline 1 @Wm.chat 1  $v1

        sockwrite -n WMP PRIVMSG #Worms $v1

        hdel Worms chm

        hadd Worms CPos 0

      } }

      ;if we click up, read the buffer

      elseif ($keyval == 38) {

      hinc worms buffer 

      if ($fline(@wm.chat,*~ $me $+ >*,$hget(worms,buffer)).text) { hadd -m worms chm $regsubex($v1,/^()/,) | hadd -m worms cpos $len($regsubex($v1,/^()/,)) }

      else hdec worms buffer

      } 

      elseif ($keyval == 40) && ($hget(worms,buffer)) {

      hdec worms buffer 

      if ($hget(worms,buffer) == 0) { hdel worms buffer | hdel worms chm | hdel worms cpos }

      elseif ($fline(@wm.chat,*~ $me $+ >*,$hget(worms,buffer)).text) {  hadd -m worms chm $regsubex($v1,/^()/,) | hadd -m worms cpos $len($regsubex($v1,/^()/,)) }

      } 

      ;move the cursor around

      elseif ($keyval == 37) { if ($hget(Worms,CPos) > 0) hdec Worms CPos }

      elseif ($keyval == 39) { if ($hget(Worms,CPos)  Connecting to $hget(Worms,Server) $+ ...

      }

      }

      ;strip HTML from our stuffs..

      alias -l nohtml return $regsubex($1-,/(^[^|]+>|]+$)/g,$null)

      ;our socket commands for connecting to the server to chat and play 

      alias wms.connect { sockopen WMP $hget(Worms,Server) $hget(Worms,Port) }

      ;this will disconnect us with the message of "Worms for mIRC!"

      alias wms.close { if ($sock(WMP)) sockwrite -n WMP QUIT Worms for mIRC! | sockclose WMP }

      on *:SOCKOPEN:WMP: {

      ;send the data the server requires

      if (!$sock(WMP)) halt

      sockwrite -n $sockname NICK Wm_ $+ $me

      sockwrite -n $sockname USER Worms. $+ $me "" $+(",$server,") :Worms_Player

      }



      on *:SOCKREAD:WMP: {

      if (!$window(@Worms)) halt

      ;if theres an error end

      if ($sockerr > 0) return

      ;our loop so we can stay connected

      :1

      if (!$window(@Worms)) || (!$sock(WMP)) halt

      sockread %wmp

      tokenize 32 %wmp

      ;if we didnt read anything, end

      if ($sockbr == 0) return

      ;if theres nothing that we read, set the var to a - so we dont have an error

      if (!%wmp) %wmp = -

      ;this is for when we connect, join #Worms, and add welcome to the chat box

      if ($2 == 001) { 

      iline 1 @Wm.chat 1  Welcome to the Worms lobby. 

      hadd Worms Connected True 

      sockwrite -n WMP JOIN #Worms

      }

      ;if we have a bad nickname

      if ($2 == 455) iline 1 @Wm.chat 1  Connect failed! Invalid nickname. A better nick would be $regsubex($me,/[^[:alnum:]]/g,) $+ .

      ;send a PONG when we are PING'd

      if ($1 == PING) sockwrite -n WMP PONG $2

      ;create variables for our nick and our message

      var %Wnick = $right($gettok($1,1,33),-1), %Wmsg = $right($4-,-1) 

      ;when someone says something and they're a Worms player add their message

      if ($2 == PRIVMSG) && (WM_* iswm %Wnick) && (WM* !iswm %wmsg) iline 1 @Wm.chat 1  %Wmsg

      if ($2 == PRIVMSG) && (WM.Create* iswm %Wmsg) && (%wnick != WM_ $+ $me) { 

      aline 1 @Wm.Games $remove($gettok(%wmsg,2,58),WM.Create ) hosted by $remove($gettok(%wmsg,1,58),WM.Create ) $+ . Up to $gettok(%wmsg,3,58) players can play.

      iline 1 @Wm.Chat 1  $& 

        $remove($gettok(%wmsg,1,58),WM.Create ) has just created a game: $remove($gettok(%wmsg,2,58),WM.Create ) $+ . Up to $gettok(%wmsg,3,58) players can play.

      }

      ;when someone deletes a game

      if ($2 == PRIVMSG) && (WM.Del* iswm %Wmsg) && (%wnick != WM_ $+ $me) && ($hget(Worms,Game)) { 

      if ($me isin $gettoK($hget(Worms,Game),2,59)) {

      hdel Worms Game

      iline 1 @Wm.chat 1  $remove(%Wnick,WM_) has ended their game. You are no longer part of their game.

      }

      }

      ;when someone ends their game in general

      if ($2 == PRIVMSG) && (WM.Del* iswm %Wmsg) && (%wnick != WM_ $+ $me) { 

      iline 1 @Wm.chat 1  $remove(%Wnick,WM_) has ended their game.

      }

      ;when someone joins the channel, add their nick to the list, and tell everyone

      if ($2-3 == JOIN :#Worms) && (WM_* iswm %Wnick) && (%wnick != WM_ $+ $me) {

      aline -l @Wm.chat $remove(%Wnick,WM_)

      iline 1 @Wm.chat 1  $remove(%Wnick,WM_) has connected to the lobby.

      }

      ;this is for when someone quits

      if ($2 == PART) || ($2 == QUIT) && (WM_* iswm %Wnick) { 

      iline 1 @WM.chat 1  $remove(%Wnick,WM_) has left the lobby. $&

        $iif($hget(Worms,Game) && $me isin $gettok($hget(Worms,Game),2,59), You are no longer part of their game., )

      if ($hget(Worms,Game)) && ($Me isin ($gettok$(hget(Worms,Game,2,59)) {



      }

      var %1 1 | while (%1 

Link to comment
Share on other sites



×
×
  • Create New...