Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Wyz on Wed 19/01/2011 02:39:55

Title: [Tech demo] AGS chat client - with source!
Post by: Wyz on Wed 19/01/2011 02:39:55
I don't really know where to post this but I'm going to give it a try.

A while back I was working on a IRC client for the AGS awards ceremony to spice it a bit up. The idea got cancelled and since I promised to release the source afterwards I might as well do it now. :P
Since it is not finished in any way I will release it as a tech demo.

Bit of history: A while back Duals and JimReed made an interactive chat game which looked very fly but had a few connection issues. When someone had the idea to actually use it for the awards I decided to help out and redesign the connection part for IRC, it would also mean people with both the regular and special client could join the same server, a bit more convenient. Well the IRC part including a custom built TCP plugin are finished. There's a bit more but you should see that yourself! :D

My thanks go to JimReed and Dualnames for the initial idea, and Dualnames for testing it.

have fun!

- Wyz

Ps.
The TCP plugin was a rush job, I wouldn't advise you using it for other projects. I will make a better version in the future though.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: DoorKnobHandle on Wed 19/01/2011 02:54:48
Awesome, works fine! Excellent work! I will check out the source code and use it for my purposes. Evil purposes MAHAHAHA.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Phemar on Wed 19/01/2011 05:50:35
Nice, I was playing with it just now when WHAM...

QuoteError: Error running function 'repeatedly_execute':
Error: Script appears to be hung (a while loop ran 150001 times). The problem may be in a calling function; check the call stack.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: deadsuperhero on Wed 19/01/2011 06:08:50
My god. Does it work across the AGS Mac and Linux runtimes as well?

Oh, man, the sheer potential of this...
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Eggie on Wed 19/01/2011 18:45:27
Quote from: DeadSuperHero on Wed 19/01/2011 06:08:50Oh, man, the sheer potential of this...

AGSCluedoAGSCluedo!!
Title: Re: [Tech demo] AGS chat client - with source!
Post by: DoorKnobHandle on Wed 19/01/2011 18:48:10
I have zero knowledge about IRC but how is the character moving implemented? I briefly checked out the source but wasn't able to tell, are the move commands send over IRC somehow as well or via TCP/IP on its own somehow?
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Calin Leafshade on Wed 19/01/2011 20:44:57
Quote from: Eggie on Wed 19/01/2011 18:45:27
Quote from: DeadSuperHero on Wed 19/01/2011 06:08:50Oh, man, the sheer potential of this...

AGSCluedoAGSCluedo!!

+1,

Someone do this, plz.

kthxbai.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Wed 19/01/2011 21:18:03
(http://www.marasaw.com/Facebook_like_button.jpg) (http://www.facebook.com/plugins/like.php?) ;D
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Thu 20/01/2011 00:43:20
Quote from: dkh on Wed 19/01/2011 02:54:48
Awesome, works fine! Excellent work! I will check out the source code and use it for my purposes. Evil purposes MAHAHAHA.
Thanks! Uh-oh, is the world ready for it? :D

Quote from: Phemar on Wed 19/01/2011 05:50:35
Nice, I was playing with it just now when WHAM...
Did this happen when you reopened the chat window after a while? Sometimes AGS stops processing when the game window isn't selected.

Quote from: DeadSuperHero on Wed 19/01/2011 06:08:50
My god. Does it work across the AGS Mac and Linux runtimes as well?
All but the TCP plugin, but it can be ported in the future. Hmm it might work on wine and such though.

Quote from: dkh on Wed 19/01/2011 18:48:10
I have zero knowledge about IRC but how is the character moving implemented? I briefly checked out the source but wasn't able to tell, are the move commands send over IRC somehow as well or via TCP/IP on its own somehow?
IRC is a message based protocol, the character movements are sent using plain readable chat messages using the IRC protocol. It isn't the most efficient way, but it's convenient for testing. it looks something like this:
* WyzX is at 322 588
* WyzX walks to 579 498
* WyzX walks to 478 331

Quote from: Eggie on Wed 19/01/2011 18:45:27
Quote from: DeadSuperHero on Wed 19/01/2011 06:08:50Oh, man, the sheer potential of this...

AGSCluedoAGSCluedo!!
Yes please, that would be epic!
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Fri 21/01/2011 07:20:21
Hey, I've incorperated it into my game, however i've noticed that the server side view of the characters goes wherever the char clicks including on walls and ceilings, Walkable areas are ignored. and also if if I use

(button==eMouseLeft) {
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));
}

In global script, all the modes, look,talk,interact cause the player to walk to the clicked x,y coords ignoring walkable areas except the walk function, it works correctly client side, but the serverside error posted above occurs.

Also I'm using multiple characters and something in the way you scripted it is causing their images to be randomized server side.

If you could shine some light it would be great.

PS. Great job!

Thanks in advance.
-Jar
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sat 22/01/2011 00:36:34
I just found out the games can talk to each other.

I tried the following together :

my game

and the tech demo.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Dualnames on Sat 22/01/2011 02:06:52
Quote from: Studio3 on Sat 22/01/2011 00:36:34
I just found out the games can talk to each other.

I tried the following together :

my game

and the tech demo.


I usually have Disquiet talk to McCarthy Chronicles. They talk for hours and hours and hours. Man those games speak more than me.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Moogle on Sat 22/01/2011 02:57:55
That's funny :D
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Sat 22/01/2011 15:20:45
Quote from: GrimReapYou on Fri 21/01/2011 07:20:21
Hey, I've incorperated it into my game, however i've noticed that the server side view of the characters goes wherever the char clicks including on walls and ceilings, Walkable areas are ignored.
Check Chat.asc line 305 and you'll understand why. :D

Quote from: GrimReapYou on Fri 21/01/2011 07:20:21
In global script, all the modes, look,talk,interact cause the player to walk to the clicked x,y coords ignoring walkable areas except the walk function, it works correctly client side, but the serverside error posted above occurs.
That's general laziness, I didn't need it for the demo so I haven't implemented mouse modes. Check the global script for that. (don't forget to change the room script mouse-click event too)

Quote from: GrimReapYou on Fri 21/01/2011 07:20:21
Also I'm using multiple characters and something in the way you scripted it is causing their images to be randomized server side.
There is no way to be certain who joins the server and in what order. The first character is considered to be the player character, the others are the NPCs in random order. Well it is not random actually but expect them to be. If you want to specify views for certain users it must be in the communication protocol. It is not a very easy concept but try to see how I maintain a position for each user.

Quote from: Studio3 on Sat 22/01/2011 00:36:34
I just found out the games can talk to each other.
I tried the following together: my game and the tech demo.
Yes they can communicate if they are connected to the same IRC server. Note that the server the demo is set to use is the default AGS IRC server. If you are going to do some testing, please mind to use a different server and channels so you doesn't bother the IRC folks.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sat 22/01/2011 16:16:43
I just use my game and tech demo.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Sat 22/01/2011 17:01:21
Oh right, I misunderstood that. Nice :)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sat 22/01/2011 17:45:06
Aha, indeed wyz.
Thanks for the reply.
I modified the enoblock and blocking functions work correctly now :D
I'm digging into the scripting language you used and its very complicated,however im getting a basic grasp of it.
You wouldnt know by chance how i could implement it in multiple rooms without having to disconnect/reconnect for each room would you?
I'll be working on displaying multiple chars and i'll send you the source to add to yours if you want it.
Thanks-Jar
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Mon 24/01/2011 19:09:04
Well, we've sucessfully implemented multiple characters client and server side.
Does anyone have any good or innovative ideas about how I can create another meta channel to load another room, or perhaps apply the same room settings to the next room.
So that the character can continue to synchronize room to room.
This is not as simple as it sounds.In-depth knowledge on the current subject will be required.
I'm testing a few ideas now, Will post back if I solve the issue.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Fri 28/01/2011 05:37:19
All confusions about this source have been solved.
This source is A-OK!!!
;D Million thumbs up.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Akatosh on Sat 29/01/2011 21:03:51
Time for my yearly post!

This... is actually really awesome. I mean, if you have a reliably working message exchange (and be it via IRC), that pretty much takes care of the biggest obstacle to multiplayer AGS games right there.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Sun 06/02/2011 02:06:35
Thanks, it will now come down to finding interesting ways to use this technology. ;D
Yes and of course documented plugins and modules, well they are going to be there later this year.

I found out how to fix the connection issues for minimized windows, there is a function that makes AGS also run in the background. That should fix it I guess.

Somewhere before the game starts:

SetMultitaskingMode(1);

Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Wed 16/02/2011 12:07:36
Quote from: Wyz on Sun 06/02/2011 02:06:35
Thanks, it will now come down to finding interesting ways to use this technology. ;D
Yes and of course documented plugins and modules, well they are going to be there later this year.

I found out how to fix the connection issues for minimized windows, there is a function that makes AGS also run in the background. That should fix it I guess.

Somewhere before the game starts:

SetMultitaskingMode(1);


AHA, I added that just to have multitasking mode enabled and didnt even notice that it got rid of that bug. good call!
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Monsieur OUXX on Wed 16/02/2011 13:51:02
Quote from: Akatosh on Sat 29/01/2011 21:03:51
that pretty much takes care of the biggest obstacle to multiplayer AGS games right there.

Yep. That and Dualnames Cold Virtual Beer. T'will be slow, but who cares?
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Dualnames on Wed 16/02/2011 14:18:33
Quote from: Ouxxey_games on Wed 16/02/2011 13:51:02
Quote from: Akatosh on Sat 29/01/2011 21:03:51
that pretty much takes care of the biggest obstacle to multiplayer AGS games right there.

Yep. That and Dualnames Cold Virtual Beer. T'will be slow, but who cares?

Actually I have great expectations that the ceremony will be quite fast. Who knows though. It all depends really.  ;)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 08/04/2012 06:51:28
Thought I'd open a bit of my source that is compatible with this plugin.

If you would like to adjust your characters speed with this plugin you locate the script below and add what you see i have added here.

//--------------------------------------------------------------------------------

void Act(this Character *, String action)
{
   if (action.Length < 1)
     return;
   
   String msg[] = action.IRCSplit();
   if ((msg[0] == "walks") && (msg[1] == "to"))
   {
     if (this.Room == player.Room)
       this.Walk(msg[2].AsInt, msg[3].AsInt, eNoBlock);
     else
     {
       this.x = msg[2].AsInt;
       this.y = msg[3].AsInt;
     }
   }
   else if ((msg[0] == "is") && (msg[1] == "at"))
   {
     if (!this.Moving)
     {
       this.x = msg[2].AsInt;
       this.y = msg[3].AsInt;
     }
   }
   else if ((msg[0] == "looks") && (msg[1] == "like"))
   {
     this.ChangeView(msg[2].AsInt);
   }
////--------------------------------------------------------------------    
       else if ((msg[0] == "speed") && (msg[1] == "is"))
   {
     this.SetWalkSpeed(msg[2].AsInt, msg[3].AsInt);
   }    
////--------------------------------------------------------------------    
   
   
}

And you send this message within your game code:

CafeDo(String.Format("speed is %d %d", 3, 3));


The number being the speed at which you would like your character to move.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Terrorcell on Sun 08/04/2012 16:13:37
This is very impressive. If you get the chance, you should write up some documentation for it, perhaps even expand on it :)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Mon 09/04/2012 19:01:26
Thanks :D
I have wyz to thank being he spent the grueling time writing this plugin.
If i ever finish GQ I plan to coordinate with him and help him release an easy to use template :)
Until then I'll just release tidbits of new source as i come up with it .
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Mon 09/04/2012 20:35:17
I like that idea. I know I would benefit from some small stuff.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Thu 12/04/2012 21:43:35
Creating a character select.

Create a button on your start screen with a standing position of your main character named "Fighter" and put this script in it.


#sectionstart Male fighter  // DO NOT EDIT OR REMOVE THIS LINE
function acview_Click(GUIControl *control, MouseButton button) {
  gGui3.Visible=false; // closes startup gui, if you have one

   player.ChangeView(16); ////Changes the players view client side.
   player.SpeechView=13;


gChat.Visible=false; ///your chat gui

CafeDo(String.Format("looks like %d", 16)); ////Changes the players view ServerSide

aIntro.Stop();///stop intro music

Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Thu 12/04/2012 22:47:52
The best server setup:

Get Yarcanox's server http://eloxoph.de/weircd/

Install it.

Edit the file "Chat.ASC" in your game.

You'll see:

#define SERVER "Your IP Address here"
//////Put your IP address there ^.
At the top.

Find the weircd.exe file, Make a shortcut of it and place it where you like.

Edit the shortcuts properties by right clicking and going to properties.

Edit the field that says Target: and add -F with Capital F as shown below.
This will disable the flood control keeping your players from being kicked from the server.
(http://gamersplanet.tk/ex.png)

Very stable for long periods of time :)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sat 14/04/2012 21:39:20
I feel the best place to ask this is here. So I was working on something and I came to this problem.

(http://www.pictureshoster.com/files/l5nba85excz2xb9cx5wk.png)

I can't figure out how to update the X,Y of another player on the players screen. See Dave in the picture for example.

I needed this, CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));


I also don't know how to get the plugin to make the game select the character the player has chosen to appear on the other players screen.
It seems it just goes down to the character after you(or something like that. But Tifa should show up both screens as Tifa, not Christen. P.S. Dave just happened to be lucky to show up on both screens.

My last question is how do I successfully get 2 games to chat with one another? Like 2 nights ago I was able to get this and PMQ legends to "connect" together and it allowed me to cross chat using both games.
"Yes they can communicate if they are connected to the same IRC server" = answer

The message label stops scrolling once it reaches the bottom right above @tifa. 
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 15/04/2012 01:28:17
Put this next to your normal changeview but change the number 16 to the number of your view.
CafeDo(String.Format("looks like %d", 16)); ////Changes the players view ServerSide
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 15/04/2012 01:31:43
Oh and for the chat question, try using the stock chatbox data, there's not a whole lot of editing you can do without interfering with the necessary code besides the images/font/etc unless you want to reprogram all the chat actions.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sun 15/04/2012 01:53:00
Thanks dude, I'm still a bit confused tho, cause I don't change the characters view's I just swip swap between 4 characters.

maybe I could have the game constantly check that line of code in my S3 script

I also figured out why the chat thing won't work right, It's text is going of screen or past the box X so when I just keep typing random latter's at a some point they start to move up as they should.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sun 15/04/2012 02:12:05
I have tried this but it seems that line seems to stop me from registering to the server.
if(player.ID == Dave.ID){
CafeDo(String.Format("looks like %d", 5));
}
else if(player.ID == chris.ID){
CafeDo(String.Format("looks like %d", 6));
}

else if(player.ID == muffy.ID){
CafeDo(String.Format("looks like %d", 11));
}

else if(player.ID == tifa.ID){
CafeDo(String.Format("looks like %d", 14));
}
 
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 15/04/2012 03:02:07
Just put your login script in the Game_start section in global.asc

Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sun 15/04/2012 04:08:21
Well the the thing is you start in the main menu then you move to the pub were you are promted to select a character/job then you can log in.

Would you like to see the G_script.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 15/04/2012 04:39:33
Sure, What ya got?
to the post above, decrease the height of the chat label
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sun 15/04/2012 04:54:20
I think the problem is AGS it's self, I just edited over AGSirc and I had to shrank it down to 320x240. It seemed to mess up the whole screen thing. Cause I imported a new font after the change and it looks way smaller(which it should) in the editor than in the game which makes it look like it's 12 or 10 size font.

// main global script file
String nick;
// called when the game starts, before the first room is loaded

Button10_OnClick is were the character selecting takes place.

questing_OnClick is were the login takes place.
function game_start()
{
Label9.Visible = false;
Label10.Visible = false;
Label11.Visible = false;
Label12.Visible = false;
SetMultitaskingMode(1);

questing.Visible = false;
KeyboardMovement.SetMode(eKeyboardMovement_None);
 
}

// put anything you want to happen every game cycle in here
function repeatedly_execute()
{

}

// called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode)
{
  if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
 
  if (keycode == eKeyEscape) gGui4.Visible = true; // Ctrl-Q
  if (keycode == eKeyCtrlC) gChat.Visible = true; // F9
  if (keycode == eKeyCtrlX) gChat.Visible = false;  // F12
  if (keycode == eKeyW) {
if(player.HasInventory(potion)){
player.ActiveInventory = potion; // Ctrl-S, give all inventory
}
}
  if (keycode == eKeyCtrlE)  {
if(player.HasInventory(ether)){
player.ActiveInventory = ether;// Ctrl-S, give all inventory
}
}
  if (keycode == eKeyCtrlR)  {
if(player.HasInventory(elixer)){
player.ActiveInventory = elixer;// Ctrl-S, give all inventory
}
} // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlQ) if(playerHP <= 50){
player.Say("Help me! Help me please!");

}// Ctrl-X, teleport to room


}

// called when a mouse button is clicked.
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
   
  }
  else if (button == eMouseMiddle) {
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
     
  }
}

function dialog_request(int param)
{
}

function btnSend_OnClick(GUIControl *control, MouseButton button)
{
  Chat(txtInput.Text);
  txtInput.Text = "";
}

function txtInput_OnActivate(GUIControl *control)
{
  Chat(txtInput.Text);
  txtInput.Text = "";
}

function Button3_OnClick(GUIControl *control, MouseButton button)
{

}

function ListBox1_OnSelectionChanged(GUIControl *control)
{

if(ListBox1.SelectedIndex == 0){
  Display("Welcome Pub member. When ever your ready to venture out just take a look at the quest board downstairs.");
}

if(ListBox1.SelectedIndex == 1){

}

if(ListBox1.SelectedIndex == 2){

}

if(ListBox1.SelectedIndex == 3){

}

if(ListBox1.SelectedIndex == 4){

}

if(ListBox1.SelectedIndex == 5){

}





}

function Button10_OnClick(GUIControl *control, MouseButton button)
{
Label9.Visible = true;
Label10.Visible = true;
Label11.Visible = true;
Label12.Visible = true;
Label13.Text = "Can use Knight skills";
//String nick;
 
  nick = "Dave";
if(Dave.Room == 0){
Dave.ChangeRoom(1, player.x, player.y);

}
if(Dave.Room == 1){
//Display("Job already set");

}

Dave.SetAsPlayer();
tifa.ChangeRoom(0);
muffy.ChangeRoom(0);
chris.ChangeRoom(0);

player.ChangeView(5);
questing.Visible = true;


}

function Button11_OnClick(GUIControl *control, MouseButton button)
{
Label9.Visible = true;
Label10.Visible = true;
Label11.Visible = true;
Label12.Visible = true;
Label13.Text = "Can use BLK magic abilities";
//String nick;
 
  nick = "Muffy";

if(muffy.Room == 0){
muffy.ChangeRoom(1, player.x, player.y);
}
if(muffy.Room == 1){
//Display("Job already set");

}

muffy.SetAsPlayer();
tifa.ChangeRoom(0);
Dave.ChangeRoom(0);
chris.ChangeRoom(0);

player.ChangeView(11);
questing.Visible = true;
}

function Button12_OnClick(GUIControl *control, MouseButton button)
{
Label9.Visible = true;
Label10.Visible = true;
Label11.Visible = true;
Label12.Visible = true;
Label13.Text = "Can use WHT magic abilites";
//String nick;
 
  nick = "Tifa";
if(tifa.Room == 0){
tifa.ChangeRoom(1, player.x, player.y);

}
if(tifa.Room == 1){
//Display("Job already set");

}
tifa.SetAsPlayer();
muffy.ChangeRoom(0);
Dave.ChangeRoom(0);
chris.ChangeRoom(0);

player.ChangeView(14);
questing.Visible = true;
}

function Button13_OnClick(GUIControl *control, MouseButton button)
{
Label9.Visible = true;
Label10.Visible = true;
Label11.Visible = true;
Label12.Visible = true;
Label13.Text = "Can absord/reuse monster abilities";
//String nick;
 
  nick = "Chris";
if(chris.Room == 0){
chris.ChangeRoom(1, player.x, player.y);

}
if(chris.Room == 1){
//Display("Job already set");

}
chris.SetAsPlayer();
Dave.ChangeRoom(0);
muffy.ChangeRoom(0);
tifa.ChangeRoom(0);

player.ChangeView(6);
questing.Visible = true;
}

function questing_OnClick(GUIControl *control, MouseButton button)
{



 
  nick = Game.InputBox("Enter screen name or use default");
 
  Connect(nick);
gGui2.Visible = false;
KeyboardMovement.SetMode(eKeyboardMovement_Pressing);




gChat.Visible = true;
gGui3.Visible = true;
}


I have figured out the problem for the chat box, I had to change the 40 to 15 count. This way it would start rising right after 15 lines.

void PushLine(String line)
{
  if (line.Length > LINE_WIDTH)
  {
    PushLine(line.Truncate(LINE_WIDTH));
    PushLine(line.Substring(LINE_WIDTH, line.Length - LINE_WIDTH));
    return;
  }
 
  String text;
  text = String.Format("%s[%s", lblOutput.Text, line);
 
  int i = text.Length;
  int count = 0;
  int pos = -1;
  while (i)
  {
    if (text.Chars[i] == '[')
      count++;
   
    if (count == 15)
    {
      pos = i;
      i = 0;
    }
    else
      i--;
  }
 
  lblOutput.Text = text.Substring(pos + 1, text.Length - pos - 1);
}
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Construed on Sun 15/04/2012 17:05:32
Ah, I see.
Yea you can also adjust the chat that way.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Monsieur OUXX on Sun 13/05/2012 20:39:08
Hey Wyz,
The TCP plugin underlying the IRC module is often compared by AGSers to the old TCP/IP plugin.
But the TCP/IP plugin was using mostly integers, and could "listen".
Your plugin uses Strings, and I only saw instructions to connect to a host (and process its answers).

So, do you think your plugin is suitable for an AGS-based server, meant to process something else that \r\n strings?
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Yuri Patrick on Thu 21/06/2012 04:00:22
Actually, I have a very similar question to OUXX... The server. Does it have to be simplistic like IRC, or could a server be written in AGS? I have an old, old idea about using PennMUSH (http://www.pennmush.org) as the server to a game idea of mine but was never able to get the old TCP/IP plugin to connect to it properly.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Moox on Fri 22/06/2012 08:45:17
Without looking at the code, does the plugin allow for the client to join multiple channels simultaneously? As in, could the player be in one channel for chat and another for behind the scenes instructions, etc...?
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Mon 25/06/2012 13:47:52
Apologies fro my late reaction.
Yes my plugin is capable of both listening and connecting TCP sockets and UDP as well only I might have forgot to implement SentTo and RecvFrom  :-[ . I keep telling people that I want to rewrite it, but it is hard for me to find a free time slot to do so. I basically threw together this plugin in two days or so and never really optimized it. Well I still want to do it, and eventually I will.

As for servers in AGS, well there are some advantages using a stand alone server; it depends on how many connection you want it to have. If you want something like four play multi-play and both the client and server be part of the same structure then the plugin will cope. For MMO type of stuff obviously not; a stand alone server that can take advantage of threading will be a much better solution.

I guess the plugin is not binary safe at this moment; well actually only '\0' (the null character) will fail because of the way c-strings work. This will require additional function like reading from and to arrays. I can definitely see that happen in the future.

The Tech-demo is hard coded to only work for two channels but I've been working on a module that allows multiple channels. The only real struggle I have there is AGS' lack of doing callbacks. I want AGS to call certain functions when messages arrive but I've yet to find an elegant way of doing this.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Moox on Wed 04/07/2012 10:13:15
As it interfaces with IRC textually, wouldn't it be possible to make the client dumb and have some calculations performed by a custom IRC bot? That would certainly reduce some strain.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Yuri Patrick on Mon 09/07/2012 15:12:23
Quote from: Wyz on Mon 25/06/2012 13:47:52The only real struggle I have there is AGS' lack of doing callbacks. I want AGS to call certain functions when messages arrive but I've yet to find an elegant way of doing this.

Just a silly idea, Wyz, but couldn't we hack the AGS source code? It is available. I forgot where I found it but it was somewhere under the downloads section.

I was already thinking about attempting to hack my own networking directly into the engine and use PennMUSH (http://www.pennmush.org) for the server after some hacking on that source code as well. I love open source. :)

Sorry for pushing the PennMUSH link so much, but lately when I ask, nobody seems to remember text-only gaming. ;)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Thu 12/07/2012 23:52:06
I was thinking the same thing but I didn't think it was possible so I didn't post the question.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Sat 25/08/2012 17:21:43
I'm working on a new version of the sockets plugin and I'm half way there. It will support binary data as opposed to strings, is threaded, ipv6 ready and can handle UDP and both listening and connecting TCP. It can potentially support even more protocols since I intend to wrap BSD sockets as tight as possible but that will probably never be used.

In simpler words: I'm making a new plugin to add networking capabilities to AGS that is both more stable and efficient as the previous one I made. It can be used to access websites, files, mail and IRC among others. Those will not come in the package but will be available as modules in the future.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Yuri Patrick on Thu 20/09/2012 03:27:46
Nice, Wyz.

The server I was thinking about using was a MUD server. SImple telnet protocol. I just have to figure out how to get AGS to read what comes up from the server and translate it into rooms and such. ;)
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Crimson Wizard on Thu 20/09/2012 09:47:06
Quite late to make this reply, anyway, couple of notes -

Quote from: Wyz on Mon 25/06/2012 13:47:52
The only real struggle I have there is AGS' lack of doing callbacks. I want AGS to call certain functions when messages arrive but I've yet to find an elegant way of doing this.
JJS recently mentioned he wants to invent an event system in AGS. I am not sure about details. But plugin interface is a bit limited IMO. Probably you might start some discussion on how it may be developed further to provide more freedom for plugin-writers?
We are also putting some utility classes into use, like Stream, String, etc. There's yet a problem of maintaining backwards compatibility, that's the reason we cannot change parameter types in plugin interface members, like FILE pointer to Stream; some solution has to be found there.

Quote from: wolverine79936 on Mon 09/07/2012 15:12:23
Just a silly idea, Wyz, but couldn't we hack the AGS source code? It is available. I forgot where I found it but it was somewhere under the downloads section.
If you are still interested, AGS engine is being actively developed by JJS for quite a while now (he does ports to other platforms as well as adding ability to run games made by older versions) and I was doing code clean-up since June; now we are finally up to merging our versions into one branch. FYI our AGS code may be found here: https://github.com/adventuregamestudio. You may use Git to make your own personal copy and do whatever you like with that (just a hint).
Regarding adding networking to AGS, that may be an interesting feature request. I just wonder what other people would say about this. Will this be appropriate addition to the engine, or should rather be made as a plugin? After all, networking is not so common for adventure games...
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Thu 20/09/2012 11:12:25
@ wolverine79936
That can done with the current plugin since telnet uses TCP these days. The are however a lot of characters in the protocol that are not human-readable so that might be a challenge.

@ Crimson Wizard
Yes, I really wish I could get involved but I'm still pretty busy. An event system that is also exposed to the scripting language would really be nice; they simply have to be functions that are stored in a special lookup table. You know what; I'll make a proposal for a system and post it on the forums so people can discuss.
I don't think utility classes are really needed; object orientated programming is nice but is very error prone when trying to export it to an external library like a DLL. There however a number of changes I really could use for the plugin API, also to make it a bit more portable. It's a bit frustrating that things are finally in motion and now my schedule filled up. :D
I agree; networking in adventure games is too much of a niche to validate networking support by default. I do hope that in the future plugins can also be linked statically; I actually prepare my future plugins for that. The socket plugin also supports linux btw.

On a different note: the new version of the plugin is nearing completion. I will let you know when it goes beta.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: JJS on Thu 20/09/2012 16:12:06
About static-linking plugins: the refactored engine can do this. Plugins still communicate over their normal interface but they are linked into the engine. This is simply done by putting them into their own namespace and binding the function calls in the plugin loading code of the engine.

This is necessary for platforms that don't support shared libraries, e.g. non-jailbroken iOS.


E: There is already an event system in place. The plugins can register a notifier for different events. All that is needed is generalizing this so that events can be fired to in-engine functions.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Fri 21/09/2012 01:59:09
Quote from: JJS on Thu 20/09/2012 16:12:06
About static-linking plugins: the refactored engine can do this. Plugins still communicate over their normal interface but they are linked into the engine. This is simply done by putting them into their own namespace and binding the function calls in the plugin loading code of the engine.
Splendid, good to know! :D

Quote from: JJS on Thu 20/09/2012 16:12:06
E: There is already an event system in place. The plugins can register a notifier for different events. All that is needed is generalizing this so that events can be fired to in-engine functions.
Well yes but is it also exposed to the scripting language? I need this support for modules mainly; I was already achieving event like functionality with the plugin interface but good to know there is a dedicated system now!
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Radiant on Tue 12/02/2013 19:58:21
The links are down. Can anyone do a re-upload please?
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Yuri Patrick on Sun 25/08/2013 14:47:44
Grr! I can't find any links that work anymore for this, Wyz. Do you even still have the source for the plugin? I wanted to use it for a template to my own networking protocol.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Icey on Sun 25/08/2013 17:40:02
Umm there was a link somewhere around here :\ but I can't seem to find it. I tried googling it but I can't find it dude.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: Wyz on Mon 26/08/2013 14:31:55
Sorry guys, I completely forgot about the links; I've re-uploaded it and the links in the first post should now work.

I'm still working on the new sockets plugin btw; I've got one week left to finish it basically. If I do make it I'm sure it will lack proper testing still but I might release an alpha version. I'll open a new topic when I do.
Title: Re: [Tech demo] AGS chat client - with source!
Post by: DoorKnobHandle on Mon 26/08/2013 14:56:43
Please make it happen, Wyz! Pleeeease! :)