Hotspot-Clicking Causes Undesired Script Blocking Behavior [SOLVED]

Started by HammerBlade, Thu 30/07/2009 22:51:04

Previous topic - Next topic

HammerBlade

EDIT 08/02/2009: Read my post 4 posts down from here if the mod by KhrisMUC doesn't solve your problem (although it should)

Hey there,

To try and save some time,  my issue is demonstrated HERE.

The Short Story: Clicking on hotspots results in the game being blocked during the ProcessClick() function under the GlobalScript.  I need this to not happen.  What causes this?

The Long Story:

I'm trying to create an interface where clicking on a hotspot doesn't result in the game script being blocked.

If a player attempts to interact with a hotspot, the player character can walk towards the hotspot and interact with it upon reaching the walk-to point.  However, during this time the repeatedly_execute functions in the game should keep running, and the player should be able to "cancel" the interaction simply by clicking elsewhere.  This actually was working out fine with the Lookat cursor mode, though I've no idea what I might have changed to cause this.  

Also, there is a counter used as a sort of "timer" which counts down as a player walks around a screen, increasing the chance the player will hit a random encounter a la SNES JRPG's of yesteryear.  I don't want a player to be able to avoid such encounters by interacting with a bunch of hotspots in the room.

WHAT'S BEEN TRIED:  I initially thought it might be an issue with mouse modes, specifically the StandardMode property in the mouse cursor editing schema.  Set to true or false, the result is the same.



Akatosh

Well, you could always just utilise the repeatedly_execute_always function for code that should be executed even while the game is "blocked".

(Also, nice avatar there. Yay for Trope-Tan (...if I recall that name correctly) :P)

HammerBlade

*Shudder* I dread the day I have to resort to such drastic overrides of the engines methods.

Anyway, while that would solve the problem of players hotspot-hopping to avoid random encounters, they would still be unable to "cancel" an interaction mid-walk by clicking somewhere else on the screen.

And yes, I do have Trope-Tan as an avatar.  If development of this project goes as planned, you might have an opportunity to meet her...

Edit:  Thanks for the feedback by the way!

Khris

I think it's due to the walk-to point. Not all mouse modes behave the same, eModeWalkto isn't blocking, but all other modes are, afaik.
When clicking somewhere using eModeWalkto, ProcessClick simply calls player.Walk(mouse.x, mouse.y), which is non-blocking.

I wrote a module that emulates the LucasArts style, i.e. the player can cancel the action by clicking somewhere else.

You'll have to remove the walk-to points though and enter the coordinates in the interaction script (example in the thread I linked to).

HammerBlade

Yeah, every hotspot has a designated walk-to point.  Taking that out pretty much solves the problem.  Thanks for the module, it works a lot better than the functions I tried writing to have that effect!


HammerBlade

Okay, now my problem is solved.

There was strangeness with the .Walk() function.  Frequently, my character walks to the clicked-on spot, but stops one pixel off, either on the x or the y plane.

A demonstration -- http://img13.imageshack.us/img13/7505/walkerror.jpg

Your GotThere module requires the player stop at exactly the x and y coordinate that was clicked on, so stopping short of the destination screws everything up.  Now, I don't know what the hell I've done to cause my player to stop short of the walk to point by one effin' pixel, but compensating for my folly was relatively simple:

Code: ags
 
function repeatedly_execute() {
  if (!__arrived) {
    if (tgx>=player.x-1 && tgx<=player.x+1){  //True as long as player is within one pixel of where it's supposed to go 
      if (tgy>=player.y-1 && tgy<=player.y+1){ //Allows interaction to work even if player stops short of destination by one pixel
        __arrived = true;
        face(tfd);
        if (lt == eLocationHotspot) hotspot[lid].RunInteraction(mm);
        if (lt == eLocationObject) object[lid].RunInteraction(mm);
        if (lt == eLocationCharacter) character[lid].RunInteraction(mm);
      }
    }
  }
}



In case anybody ever runs into the same problem, I've modified your module slightly and put it HERE in case people run into the same problem I did.


SMF spam blocked by CleanTalk