Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: manored on Mon 14/05/2007 22:18:40

Title: How to change the style
Post by: manored on Mon 14/05/2007 22:18:40
Currently I got that "chose the action and click on stuff style", but I would like to have the "click the stuff and chose one of the actions that aparear" style. How can I change it?

Sorry for the noob question :)
Title: Re: How to change the style
Post by: Ashen on Mon 14/05/2007 22:43:12
Erm ... What?
Are you asking how to do a Verbcoin interface? If so, there's a module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27309.msg401114#new) that might help (currently the top thread in the Modules & Plugins forum), or at least give you an idea what to do, and I think there are several other help htreads and templates around. Try a forum search for Verbcoin, now you know what it's called.

If that's not what you're after, can you give more details on what IS?
Title: Re: How to change the style
Post by: R4L on Mon 14/05/2007 23:51:18
I think he means this:

You click on a door, and a list appears showing you what you can do, and you click on one of them, like in Lure of the Temptress.

Won't be done easily though.
Title: Re: How to change the style
Post by: Ashen on Tue 15/05/2007 00:05:22
Well, that's still a version of a Verbcoin, right? (Not having played LotT I can't be sure, but it sounds like it.) Not as easy to do as the basic version (which, thinking about it, is also in Demo Quest (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23083)), but doable, and the basic versions are still a good starting point, IMO.
Title: Re: How to change the style
Post by: manored on Tue 15/05/2007 23:14:10
What i meant is that the in the standart system you chose the action and use it on the object instead of having pre-determined actions for each object like im used too.

No problem tough, will stick to the current system if there is no other ready (dont know programing so couldnt make it).

Thanks for the info!
Title: Re: How to change the style
Post by: Khris on Wed 16/05/2007 00:27:06
You mean like in Broken Sword or Beneath a Steel Sky?
A left click will use the item in a pre-set way?

Check this thread:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31160.0
Title: Re: How to change the style
Post by: manored on Wed 16/05/2007 17:14:17
Like in callahs crosstime sallon, where each item haves diferent options that aparear then you click over then, then you chose one and your character does it.
Title: Re: How to change the style
Post by: Khris on Wed 16/05/2007 19:50:59
The code snippets below can't be put in a game and suddenly everything just works. They are meant to show that A) it isn't too hard to implement this and B) however, some "advanced" coding is necessary.
If you can't make heads or tails of them, get a basic grasp of AGS first or wait for an easy to use module.


I coded an interface like this two years ago.

Here are the relevant functions from the global script:
// set up the action menu and display it:

function setup_actions(int nr) {   // nr = how many?

  // set title & options
  thing.Text=Game.GlobalStrings[0];
  Button*b;
  int i=1;               // buttons are GUIControls 1-4
  while(i<=nr) {
    b=gAction.Controls[i].AsButton;
    b.Text=Game.GlobalStrings[i];
    b.Visible=true;
    i++;
  }
  if (i<5) {     // make button below options invisible
    b=gAction.Controls[i].AsButton;
    b.Visible=false;
  }

  int x = mouse.x-40;     // GUI position
  int y = mouse.y-6;
  gAction.Height=nr*12+13;   // resize GUI

  // adjust position
  if (x<0) x=0;
  if (x>240) x=240;
  if (y<0) y=0;
  int t=240-gAction.Height;
  if (y>t) y=t;
  gAction.SetPosition(x, y);  // move it to the mouse &
  gAction.Visible=true;          // show it
}

// code that's called when a action button is clicked
//  s_action/sa is the number of the selected action
//  run the interaction using an additional cursor mode
//  hs, obj & cha hold the clicked hotspot/object/character (set in on_mouse_click)

#sectionstart butt_Click  // DO NOT EDIT OR REMOVE THIS LINE
function butt_Click(GUIControl *control, MouseButton button) {
  s_action=control.ID;
  if (hs!=null) hs.RunInteraction(eModeMain);
  if (obj!=null) obj.RunInteraction(eModeMain);
  if (cha!=null) cha.RunInteraction(eModeMain);
  gAction.Visible=false;
}
#sectionend butt_Click  // DO NOT EDIT OR REMOVE THIS LINE


And here's an example, a box:
// room script file

int box_state=0;
// 0: open ->1
// 1: open, kick ->2
// 2: open ->3, kick
// 3: empty

#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a() {
  // script for Hotspot 1 (box): Main hotspot

  string buffer;

  if (s_action==0) {
    if (box_state==0 || box_state==3) gactions=1;
    else gactions=2;
    SetGlobalString(1, "open");
    SetGlobalString(2, "kick");
    if (box_state==3) SetGlobalString(1, "empty");
    if (box_state==4) player.Say("The box is useless now.");
    else setup_actions(gactions);
  }
  else if (s_action==1) {
    pl_go(145, 160, eUp);
    kneel();
    if (box_state==0) {
      StrCopy(buffer, "It's nailed shut. I can't pry it open with my bare hands.");
      box_state++;
    }
    else if (box_state==1) StrCopy(buffer, "I'm not Wolverine.");
    else if (box_state==2) {
      StrCopy(buffer, "Ok. The box is open now.");
      oOpenbox.Visible=true;
      box_state++;
    }
    else if (box_state==3) {
      StrCopy(buffer, "Well, there are some flares in there. I took them.");
      box_state++;
    }
    player.Say(buffer);
    st_up();
  }
  else if (s_action==2) {
    pl_go(145, 160, eUp);
    if (box_state==1) {
      player.Say("Kick!");
      player.Say("I think I heard a crack.");
      box_state++;
    }
    else if (box_state==2) player.Say("I don't think kicking the box more will do any good.");
  }
}
#sectionend hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart hotspot1_b  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_b() {
  // script for Hotspot 1 (box): Look at hotspot
  if (box_state<3) player.Say("It's a wooden box. Wonder what's in there.");
  else if (box_state==3) player.Say("There are some flares in the box.");
  else player.Say("The box is empty.");
}
#sectionend hotspot1_b  // DO NOT EDIT OR REMOVE THIS LINE


Clicking on the box will run the interaction script with s_action set to 0; this sets up the menu options and then calls setup_action() to show the menu.

Clicking on one of the menu's buttons will run the interaction script with s_action set to 1-4; the script then reacts according to the used action (using s_action and box_state to find out which one was clicked).

The box script is written to distinguish between the action no. first, then the state of the box. This could get messy if one isn't careful, I'd probably do it different now.
Title: Re: How to change the style
Post by: manored on Fri 18/05/2007 21:24:57
Thanks, but I already started the game with the standart system in mind, so maybe next time... :)