Walking/Clicking

Started by ncw14, Fri 04/01/2008 00:18:57

Previous topic - Next topic

ncw14

They have the hand icon for clicking on a button, but on many major adventure games they only have one cursor.
thats what i want

i want that when you walk you also can click on buttons, they have


setcursor mode 0 //for walking
setcursor mode 2// for clicking

is there anyway to link the two together so you can walk and click

kookaburra

#1
Are you saying you want the cursor to change from a walk icon to an action icon when you're over a hotspot? Or are you asking how to get a character to walk somewhere when you click on an object. If that's what you're asking, use a "walk-to point".

From the manual :
Walk-to points

Ok, since we're back at the Areas screen, let me quickly explain the "Set walk-to point" button. This allows you to set a position for each hotspot where the character will walk to whenever the player interacts with the hotspot - just like the way the LucasArts games like Monkey Island (tm) worked.

If you set a walk-to point, then whenever the player clicks interact or talk on the hotspot, the main character will first walk to that point before the relevant event is triggered. If you want, the man can also walk there when the LOOK mode is used - this option is configurable in the game General Settings pane.

-----
If you want it to change when you're over a hotspot, try this post
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20222.0

Galen

I think he may have been asking on how to make the cursor change to a "clicky"-er one when it's over a button/gui.

ncw14

Im asking how can i make is so that one cursor you can click on objects with (offgui) and walk around if you dont click on an object, so if you click on walkable area you walk there, if you click on button you activate a command

Galen

You should still be able to click on GUI buttons in walkmode? ???

.M.M.

I think your problem can be fixed with
Code: ags
 mouse.Mode=eModeWalkTo/ eModeInteract
. Write that code to Mouse move over hotspot but everywhre must be some hotspot.

monkey0506

#6
What he wants is (something like):

Code: ags
function on_mouse_click(MouseButton button) { // should be found in the global script; replace with this version
  if ((button == eMouseLeft) || (button == eMouseRight)) { // support left and right mouse-buttons
    Character* cat = Character.GetAtScreenXY(mouse.x, mouse.y); // check if there's a Character at (mouse.x, mouse.y)
    Object* oat = Object.GetAtScreenXY(mouse.x, mouse.y); // check if there's an object
    Hotspot* hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y); // check if there's a hotspot
    // inventory items are handled separately below
    if ((cat != null) && (oat != null)) { // if there's a Character AND an Object at (mouse.x, mouse.y)
      int cbase = cat.Baseline; // then check the baselines
      int obase = oat.Baseline;
      if (cbase == 0) cbase = cat.Y; // if the baseline is 0, use the Y instead
      if (obase == 0) obase = oat.Y;
      if (cbase >= obase) cat.RunInteraction(eModeInteract); // the Character (should be...I think) is in front so run its interactions
      else oat.RunInteraction(eModeInteract); // the object is in front so run its interactions
    }
    else if (cat != null) cat.RunInteraction(eModeInteract); // we just have a Character (no Object), so run its interactions
    else if (oat != null) oat.RunInteraction(eModeInteract); // just an Object (no Character), so run its interactions
    else if ((hat != null) && (hat != hotspot[0])) hat.RunInteraction(eModeInteract); // we have a Hotspot so run its interactions
    else ProcessClick(mouse.x, mouse.y, eModeWalkto); // there's nothing there, try walking
  }
  else if ((button == eMouseLeftInv) || (button == eMouseRightInv)) { // inventory items
    InventoryItem* iat = InventoryItem.GetAtScreenXY(mouse.x, mouse.y); // check if there's one under the mouse
    if (iat != null) iat.RunInteraction(eModeInteract); // if there is, run its interactions
  }
}


Your global script should already have an "on_mouse_click" function. Just replace it with this one.

This code is untested, and I may have messed up on Character/Object baselines (I was trying to make sure it runs the interaction for whichever one is in front if you have a Character standing directly in front of/behind an object.

Other than that, I've completely ignored what mode the cursor is set to (so you can disable all modes (uncheck "Standard cursor mode") except eModeWalkto). If you click on a Character/Object/Hotspot then it will run the appropriate interaction for eModeInteract. Otherwise it will walk to (mouse.x, mouse.y). So make sure that all of your interactions (pick up, talk to, etc.) are set as the 'eModeInteract' interaction.

-Added support for InventoryItems.

Also, GUI-clicks are handled separately anyway. AGS 2.7+ uses the event handlers such as: gMygui_Click(); AGS 2.62 and earlier used interface_click. The manual should explain how to set up GUI[Control]-clicks.

.M.M.

Yes, I forgot (but not only on that :-) ) on invenory items! :o ;D

SMF spam blocked by CleanTalk