[Tech demo] AGS chat client - with source!

Started by Wyz, Wed 19/01/2011 02:39:55

Previous topic - Next topic

Wyz

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:
Code: ags

SetMultitaskingMode(1);

Life is like an adventure without the pixel hunts.

Construed

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:
Code: ags

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!
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Monsieur OUXX

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?
 

Dualnames

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.  ;)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Construed

#24
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.
Code: ags

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

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:
Code: ags

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


The number being the speed at which you would like your character to move.
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Terrorcell

#25
This is very impressive. If you get the chance, you should write up some documentation for it, perhaps even expand on it :)

Construed

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 .
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

I like that idea. I know I would benefit from some small stuff.

Construed

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.

Code: ags

#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

I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Construed

#29
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.


Very stable for long periods of time :)
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

#30
I feel the best place to ask this is here. So I was working on something and I came to this problem.



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. 

Construed

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
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Construed

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.
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

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.

Icey

I have tried this but it seems that line seems to stop me from registering to the server.
Code: ags
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));
}
	  

Construed

Just put your login script in the Game_start section in global.asc

I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

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.

Construed

#37
Sure, What ya got?
to the post above, decrease the height of the chat label
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

#38
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.

Code: ags
// 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.

Code: ags
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);
}

Construed

Ah, I see.
Yea you can also adjust the chat that way.
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

SMF spam blocked by CleanTalk