Player view doesn't change when walks off region during interact

Started by NuDawnII, Fri 15/05/2015 21:39:34

Previous topic - Next topic

NuDawnII

New issue following my last post.  I have a beach scene that uses a region to change the character's view from walking to wading when the character is in the ocean.  However, if the character is in the ocean wading and I click interact with an object.  When the character automatically walks out of the ocean to the object on shore, the view does not change back to the walking view when the character walks off the region.

Code: ags

function region2_WalksOnto()
{
    cEgo.ChangeView(VEGOSPLASH);
   
}

function region2_WalksOff()
{
    cEgo.ChangeView(1);
}

Khris

This is a known issue; region events do not fire until after blocking events are over.
You can use this to make walks to hotspots non-blocking: http://www.adventuregamestudio.co.uk/forums/index.php?topic=36383.msg477380#msg477380

NuDawnII

Khris,

Thanks for this, I have got it working everywhere, except for two places in the GlobalScript that I am still working on.  However, it has seemed to have introduced an unexpected side effect where certain basic functions are repeating after the script has used the GotThere and GoFace for the first time as described.  For example when I start the game, if I use look to click on an object the following code is kicked off once.

Code: ags

function oSquirrel_Look()
{
    cReader.Say("&27 There is a grey squirrel near one of the trees.  It is making you drool.");  // READ27.wav
    Wait(20);
}


But after I interact with an object with code like below the code above executes twice any time I look at that object.

Code: ags

function oLog_Interact()
{
    if (!GotThere()) GoFace(266, 94, eRight);
    else {
      cReader.Say("&21 You pick up the log.");  //READ21.wav
      cEgo.AddInventory(iLog);
      oLog.Visible = false;
      GiveScore(2);
      RestoreWalkableArea(3);
    }
}



Please let me know what you think.

NuDawnII

Khris,

I was able to work-around the previously mentioned side effect with the following.  I would however, still be interested in your thoughts if there is anything more efficient that I could do as what I have done requires many additional lines of code to the overall project.

Code: ags

function oSquirrel_Look()
{
    if (!GotThere()) GoFace(cEgo.x, cEgo.y, eUp);
    else {
        cEgo.FaceObject(oSquirrel);
        cReader.Say("&27 There is a grey squirrel near one of the trees.  It is making you drool.");  // READ27.wav
        Wait(20);
    }
}

Khris

The module hijacks left clicks, and it works by calling the interaction a second time. That's the only way to keep all code conveniently inside the _Look(), _Interact(), etc. functions.

Thankfully this is an easy fix, replace the module's repeatedly_execute() with this:
Code: ags
function repeatedly_execute() {
  if (tgx == -1000) return;
  if (!__arrived && player.x == tgx && player.y == tgy) {
    __arrived = true;
    tgx = -1000;
    face(tfd);
    if (lt == eLocationHotspot) hotspot[lid].RunInteraction(mm);
    if (lt == eLocationObject) object[lid].RunInteraction(mm);
    if (lt == eLocationCharacter) character[lid].RunInteraction(mm);
  }
}


Thanks for finding this, I've updated the module's download.


SMF spam blocked by CleanTalk