AGS Support > AGS Engine & Editor Releases

AGS 3.6.0 - Beta 14

<< < (2/54) > >>

shaun9991:
Amazing work! So many wonderful features here!!!

Stranga:
Having a strange problem since updating to the new beta, I think it may have something to do with the new keyboard handling system. I reverted back to the old via General settings but still doesn't seem to fix the problem.

My keyboard movement script is entirely done in repeatedly_execute(), which previously never interfered with hotspot.runinteraction, strangely if you hold down a movement key while interacting with a hotspot after the interaction completes the player is jolted in the direction of the key being held across the room. Seems to only happen if the game has entered a blocking sequence of some sort, maybe remembering key inputs during the hotspot interactions and playing them right after.

Keyboard Movement Script:
Spoiler: ShowHide
--- Code: Adventure Game Studio ---// Main script for module '8 Direction Movement' import int  KeyUp[2];import int  KeyDown[2];import int  KeyLeft[2];import int  KeyRight[2];import int  KeyAction[2];import int  KeyBack;import int  KeyMenu;import int  KeySprint[2];  //required values int xm;int ym;int _xspeed=9; //Player Speedint _yspeed=9; //Player Speedint xwidth=1;int ywidth=1;int slide=3;int a;int c;int dir;bool diagslowdown=true;int walkanispeed=2;bool thrust;int walkingani=2;bool disablemove;bool nodirset;bool eightdir = false;int animticks;int animticks2;bool standing; static function EightDir::SetSpeed(int x, int y) {  _xspeed = x;  _yspeed = y;} static function EightDir::SetSize(int x, int y) {  xwidth = x;  ywidth = y;} static function EightDir::WalkViewSpeed(int speed) {  walkanispeed = speed;}     static function EightDir::SetWalkView(int view) {  walkingani = view;}   static function EightDir::SetSlide(int value) {  slide = value;}   static function EightDir::Disable(bool value) {  disablemove = value;}   static function EightDir::NoDirSet(bool value) {  nodirset = value;}   static function EightDir::DiagSlow(bool value) {  diagslowdown = value;}   static function EightDir::Thrust(int x, int y) {  xm=x;  ym=y;    thrust=true;}   static function EightDir::EightLoopsMode(bool value) {  eightdir = value;} static function EightDir::IsMoving() {  if ((xm!=0)||(ym!=0)) {return 1;}  if ((xm==0)&&(ym==0)) {return 0;}} static function EightDir::IsThrusting() {  return thrust;} bool isInactive() {  if(player.Room == 0) return true;  return false;} int moveto(int val, int incr, int target){  bool lt = val<target;  bool gt = val>target;  int old = val;  if(lt) val += incr;  else if(gt) val -= incr;        if(((old<=target && val>=target) || (old>=target && val<=target)))                val = target;  return val;} #sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINEfunction repeatedly_execute() {if (!InDialogue)// <-----This was a test to see if I could use a global variable to stop being able to move/take inputs in whilst in an interaction...didn't work as well as I'd hoped {int wasdir = dir;int wasx = player.x;int wasy = player.y;    if(isInactive()) return;   bool up=false;  bool down=false;  bool left=false;  bool right=false;    if ((IsInterfaceEnabled()==true)&&(IsGamePaused()==false))   {    if (IsKeyPressed(KeyRight[0])||IsKeyPressed(KeyRight[1]))  {    right=true;  }  else if (IsKeyPressed(KeyLeft[0])||IsKeyPressed(KeyLeft[1]))  {    left = true;  }  else if (IsKeyPressed(KeyUp[0])||IsKeyPressed(KeyUp[1]))  {    up = true;  }    else if (IsKeyPressed(KeyDown[0])||IsKeyPressed(KeyDown[1]))  {    down = true;  }     else  {    walkanispeed=1;    return;  }  }   if(!up && !down && !left && !right)  {    return;    player.StopMoving();  }   if ((IsInterfaceEnabled()==false)||(disablemove==true)) {xm=0;ym=0;}    bool speedup = false;     if(IsKeyPressed(KeySprint[0])||IsKeyPressed(KeySprint[1])) speedup = true;        int xspeed = _xspeed;  int yspeed = _yspeed;     if(speedup)//RUN_________________________________RUN  {    if (player.View!=68)    {      player.LockView(68);    }    walkanispeed=4;    xspeed = 15;    yspeed = 15;  }  else  {   if (player.View!=2)   {     player.LockView(2);   }   walkanispeed=2;   }    int accel = 20;   if ((player.Moving==false)&&(IsInterfaceEnabled()==true)&&(IsGamePaused()==false)&&(disablemove==false)) {     int b=0;        if ((xm==0) && (ym==0)) {thrust=false;}      //moving values       while (b<slide){         if (thrust==false){                    if ((right==true) && (xm < xspeed))  {xm=moveto(xm,accel, xspeed);}   //right          if ((left==true) && (xm > xspeed*(-1)))  {xm=moveto(xm, accel, -xspeed);}   //left           if ((down==true) && (ym < yspeed))  {ym=moveto(ym, accel, yspeed);}   //down          if ((up==true) && (ym > yspeed*(-1)))  {ym=moveto(ym, accel, -yspeed);}   //up           if ((left==false) && (right==false)) xm = moveto(xm,accel, 0);          if ((up==false) && (down==false)) ym = moveto(ym,accel,  0);                }         if (thrust==true) {                if (xm != 0){xm=moveto(xm, accel, 0);}        if (ym != 0){ym=moveto(ym, accel, 0);}      }     //slowdown     if (thrust==false){      if (xm > xspeed){xm=moveto(xm, accel,  xspeed);}      if (xm < xspeed*(-1)){xm=moveto(xm, accel, -xspeed);}      if (ym > yspeed){ym=moveto(ym, accel, yspeed);}      if (ym < yspeed*(-1)){ym=moveto(ym, accel,  -yspeed);}    }   b=b+1;  }   //diagslowdown   if (diagslowdown==true){     int slow=0;    while (slow <slide+1){      if ((right==true)&&(down==true)) {       if (xm>(xspeed*70)/100) {xm=(xm*70)/100;}       if (ym>(yspeed*70)/100) {ym=(ym*70)/100;}     }      if ((left==true)&&(down==true)) {       if (xm<((xspeed*70)/100)*(-1)) {xm=((xspeed*70)/100)*(-1);}       if (ym>(yspeed*70)/100) {ym=(ym*70)/100;}     }      if ((left==true)&&(up==true)) {       if (xm<((xspeed*70)/100)*(-1)) {xm=((xspeed*70)/100)*(-1);}       if (ym<((yspeed*70)/100)*(-1)) {ym=((yspeed*70)/100)*(-1);}     }      if ((right==true)&&(up==true)) {       if (xm>(xspeed*70)/100) {xm=(xm*70)/100;}       if (ym<((yspeed*70)/100)*(-1)) {ym=((yspeed*70)/100)*(-1);}     }   slow=slow+1;   }  }   //right   int loop=0;   if (xm>0){     while (loop <xm) {      a=a+1;      if (a>9) {a=0;}      if (a==5){        player.x = player.x +xwidth;        if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())>0) {player.x=player.x +1;}        player.x = player.x -xwidth;      }    loop=loop+1;    }  }    //left   loop=0;   if (xm<0){     while (loop > xm) {      a=a+1;      if (a>9) {a=0;}      if (a==5){        player.x = player.x -xwidth;        if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())>0) {player.x=player.x -1;}        player.x = player.x +xwidth;      }    loop=loop-1;   }  }    //down   loop=0;   if (ym>0){     while (loop <ym) {      c=c+1;      if (c>9) {c=0;}      if (c==5){        player.y = player.y +ywidth;        if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())>0) {player.y=player.y +1;}        player.y = player.y -ywidth;      }    loop=loop+1;    }  }    //up   loop=0;   if (ym<0){    while (loop >ym) {      c=c+1;      if (c>9) {c=0;}      if (c==5){        player.y = player.y -ywidth;        if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())>0) {player.y=player.y -1;}        player.y = player.y +ywidth;      }    loop=loop-1;    }  }    //outpush   player.x = player.x -xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x +1;}  player.x = player.x +xwidth;   player.x = player.x +xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x -1;}  player.x = player.x -xwidth;   player.y = player.y -ywidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y +1;}  player.y = player.y +ywidth;   player.y = player.y +ywidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y -1;}  player.y = player.y -ywidth;   //outpush #2   player.y = player.y -ywidth;   player.x = player.x -xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x +1;}  player.x = player.x +xwidth;   player.y = player.y +ywidth;  player.y = player.y +ywidth;   player.x = player.x -xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x +1;}  player.x = player.x +xwidth;   player.y = player.y -ywidth;     player.y = player.y -ywidth;   player.x = player.x +xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x -1;}  player.x = player.x -xwidth;   player.y = player.y +ywidth;   player.y = player.y +ywidth;   player.x = player.x +xwidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.x=player.x -1;}  player.x = player.x -xwidth;   player.y = player.y -ywidth;     player.x = player.x +xwidth;   player.y = player.y -ywidth;  if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y +1;}  player.y = player.y +ywidth;   player.x = player.x -xwidth;     player.x = player.x -xwidth;   player.y = player.y -ywidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y +1;}  player.y = player.y +ywidth;   player.x = player.x +xwidth;     player.x = player.x -xwidth;   player.y = player.y +ywidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y -1;}  player.y = player.y -ywidth;   player.x = player.x +xwidth;      player.x = player.x +xwidth;   player.y = player.y +ywidth;    if (GetWalkableAreaAt(player.x - GetViewportX(),player.y - GetViewportY())==0) {player.y=player.y -1;}  player.y = player.y -ywidth;   player.x = player.x -xwidth;    //animations   //set direction   if (eightdir==false){     if ((left==true)||(right==true)||(up==true)||(down==true)){       if (thrust==false){         if (ym>0) {if ((left==false)&&(right==false))  {dir=0;}}        if (xm<0) {if ((up==false)&&(down==false))  {dir=1;}}        if (xm>0) {if ((up==false)&&(down==false))  {dir=2;}}        if (ym<0) {if ((left==false)&&(right==false))  {dir=3;}}         if ((ym>0) && (player.Loop==3))  {dir=0;}        if ((ym<0) && (player.Loop==0))  {dir=3;}        if ((xm>0) && (player.Loop==1))  {dir=2;}        if ((xm<0) && (player.Loop==2))  {dir=1;}      }    }  }    if (eightdir==true){     if ((left==true)||(right==true)||(up==true)||(down==true)){       if (thrust==false) {            if ((xm>0)&&(ym==0)) {dir=2;}        if ((xm<0)&&(ym==0)) {dir=1;}        if ((xm==0)&&(ym>0)) {dir=0;}        if ((xm==0)&&(ym<0)) {dir=3;}         if ((xm>0)&&(ym>0)) {dir=4;}        if ((xm<0)&&(ym>0)) {dir=6;}        if ((xm<0)&&(ym<0)) {dir=7;}        if ((xm>0)&&(ym<0)) {dir=5;}      }    }  }}    bool any = (left==true)||(right==true)||(up==true)||(down==true);          if(any)  {    if(dir != wasdir || player.Loop != dir || standing)    {      player.Loop = dir;                                                //only reset this if we were standing previously                        if(standing)                                    {                                //NOT 0 -- start nudging forward rather than slide in walk frame                                player.Frame = 1;                        }    }    else    {      animticks++;      if(animticks>=walkanispeed)      {        animticks=0;           animticks2++;                int limit = 2;        if(speedup) limit=1;                         ViewFrame* tmp = Game.GetViewFrame(player.View, player.Loop,  player.Frame);                if(animticks2 > limit)        {          animticks2 = 0;          player.Frame = player.Frame+1;          if(tmp.LinkedAudio != null)          {            tmp.LinkedAudio.Play();            if(player.Frame >= Game.GetFrameCountForLoop(player.View,  player.Loop))              player.Frame = 1;          }        }      }    }  }  else  {    player.Frame = 0;                standing = true;                animticks = 0;                animticks2 = 0;                                 return;  }  if(any) standing = false;   if (player.Moving==true) {dir=player.Loop;}   if (nodirset>0) {dir=player.Loop;}   if (IsInterfaceEnabled()==false) {dir=player.Loop;}    //LogMessage(String.Format("%d, yspeed=%d",player.y, yspeed));}else{  return;}}#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE  
Interaction Script:
Spoiler: ShowHide
--- Code: Adventure Game Studio ---//----------------------------------------------------------------------------------------------------// on_key_press//----------------------------------------------------------------------------------------------------import int  KeyUp[2];import int  KeyDown[2];import int  KeyLeft[2];import int  KeyRight[2];import int  KeyAction[2];import int  KeyBack;import int  KeyMenu;import int  KeySprint[2];import int KeyInventory[2]; function on_key_press(eKeyCode keycode) {     if (IsGamePaused()) keycode = 0;     // Action Key--------------------------------------------------------------------------------------------------------------    if (keycode == KeyAction[0] || keycode == KeyAction[1])     {      int px = player.x - GetViewportX(),py = player.y - GetViewportY();      Hotspot*h = Hotspot.GetAtScreenXY(px, py);      Object*o = Object.GetAtScreenXY(px, py);      if (h.ID > 0 ) {        if (player.ActiveInventory != null)        {           player.StopMoving();//These may be redundant           h.RunInteraction(eModeUseinv);        }        else        {          player.StopMoving();//These may be redundant           h.RunInteraction(eModeInteract);        }      }    }} 

Crimson Wizard:

--- Quote from: Stranga on 22 Mar 2022, 23:04 ---if you hold down a movement key while interacting with a hotspot after the interaction completes the player is jolted in the direction of the key being held across the room. Seems to only happen if the game has entered a blocking sequence of some sort, maybe remembering key inputs during the hotspot interactions and playing them right after.

--- End quote ---

If it were in on_key_press, i would assume that maybe it does not process and clear the key buffer each frame during a blocking action.
But since the action keys are processed in rep-exec, i'm not certain. I will have to do some tests.

Stranga:
Well, strangely I did convert the system to on_keypress and didn't seem to find that issue (besides the very jittery/slow/clunky movement of the player character). If I could convert it to run as smoothly as on repeat_exe I would to be honest but this still may cause other problems down the line, possibly for others. I did also notice that it halted an animation after moving to another room  and partly froze the game too whilst doing the same thing (Holding ANY keys down during interactions or cutscenes e.c.t)

vga256:
Great to see a beta out - with all the new features, this was enough to push me over the edge into upgrading my project!

I'm seeing an autocomplete bug with this version, but since I did not use any earlier versions of 3.6.0 I can't say where/when it might have emerged.

Behaviour:
Autocomplete does not continue working past the first word in a variable under ... unknown conditions.
Example:

--- Code: Adventure Game Studio ---/// reactor pressure and temp constraintsfloat ReactorMaxPressure = 1000.0; // a made-up number in kpafloat ReactorMinPressure = 1.0;float ReactorMaxTemp = 1500.0; // a made-up number in *Cfloat ReactorMinTemp = 1.0; // in *Cfloat AmbientTemperature = 25.0; // SATP in *Cfloat AmbientPressure = 100.0; // SATP in kPa 

--- Code: Adventure Game Studio ---function PlantSystemsToggleSysOps(){  Reactor...} 
When "Reactor" is entered, the autocomplete dropdown box correctly pops up and preselects ReactorMaxPressure. However, if I continue typing the variable name, "ReactorM..." the autocomplete box deselects ReactorMaxPressure and will not autocomplete with any variable name when I hit tab.

Workaround:

--- Code: Adventure Game Studio ---function PlantSystemsToggleSysOps(){    int anyTempVariable;    Reactor...} 
With the above code, the simple insertion of any new variable causes the autocomplete to work as expected for "ReactorM..." words.

Possible Cause (?):
I tested this behaviour throughout my script, and determined that this function definition causes autocomplete to fail:

--- Code: Adventure Game Studio ---int NormalizeFlowRateWithinRange(int flowRate){  for (int i = 0; i < MAX_ANIM_SPEED_GROUPS; i++)  {    if (flowRate <= animationSpeedRanges[i])      return animationSpeedRanges[i];  }} 
In *any* function below that piece of code, autocomplete will no longer properly autocomplete the word "ReactorM". Any function above this function autocompletes properly. I cannot see anything obvious about the above function that would cause a problem with autocomplete. Even commenting-out the entire function does not help.

Let me know if I can provide any more detail. It's a strange bug.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version