Inventory Problem

Started by Digital Mosaic Games, Sun 20/12/2015 13:43:28

Previous topic - Next topic

Digital Mosaic Games

Hey guys,

It's been 3 years since I worked on my John Sinclair game. Now I want to finish it but I have a bug.
A Zombie-Dog wants to kill John and chases him. John has to jump over a fence and use his cross on the dog.
When he has defeated the zombie-dog in a mini-battle he climbs back over the fence again.

Now the bug: Suddenly when I try to open the inventory with a right click it it doesn't work. I click the right
mouse button again and again and the 10th time the inventory-window shows up.

Next problem: When I select an item the cursor-graphic becomes the graphic of the item. Now I close the
inventory window through clicking outside the inventory-window. Now I movie the item-cursor a bit and suddenly the
item-cursor becomes the normal cursor again.

I have no idea how to get rid of this bug because it's been such a long time since I scripted this. Here is
the script of the room. Maybe I can also sent you the game file if needed.

Code: ags

// room script file

 int x, y;
 int angle;

int GetDistanceFrom(this Character*, Character*c) {

  float dx = IntToFloat(c.x - this.x);
  float dy = IntToFloat(c.y - this.y);

  float dis = Maths.Sqrt(dx*dx + dy*dy);

  angle = FloatToInt(Maths.RadiansToDegrees(Maths.ArcTan2(dy, dx)), eRoundNearest);

  return FloatToInt(dis, eRoundNearest);
}

function Attack()
{
  stalked=true;
  stalking=false;
  if( (angle > 135) && (angle <= 315) ){
    cDog.ChangeRoom(1);
    cJohn.LockView(36);
    cJohn.ManualScaling=true;
    cJohn.Scaling=100;
    cJohn.Animate(104, 3, eOnce, eBlock);//enemy from DOWN
}
else if( (angle > 45) && (angle <= 135) ){
  cDog.ChangeRoom(1);
 cJohn.LockView(36);
 cJohn.ManualScaling=true;
    cJohn.Scaling=100;
 cJohn.Animate(105, 3, eOnce, eBlock);//enemy from RIGHT
}
else {
  cDog.ChangeRoom(1);
 cJohn.LockView(36);
 cJohn.ManualScaling=true;
    cJohn.Scaling=100;
 cJohn.Animate(106, 3, eOnce, eBlock);//enemy from UP
}
    lLoose.Text = "Ein wahrer H*llenhund des Satan! Gegen solch eine Bestie sollte man gewappnet sein.";
    mouse.Mode = eModePointer;
    gIconbar.Visible = false;
    PauseGame();
    gLoose.Centre();
    Death = true;
    Button6.NormalGraphic = 3683;
    gLoose.Visible = true;
}

function room_Load()
{
  Clips=true;
  cJohn.ManualScaling=false;
  cJohn.ChangeView(32);
  cJohn.SpeechView=33;
  cJohn.x=328; 
  cJohn.y=150; 
  cJohn.Solid=false;
  cDog.ManualScaling=true;
  cDog.Scaling=100;
  cDog.ChangeView(140);
  gIconbar.Visible=true;
  Verbcoin_Available=true;
  cDog.ChangeRoom(36, 339, 133);
  mouse.Mode=eModeWalkto;
  Inventory_Available=true;
}

function room_AfterFadeIn()
{
     if(trimartolod==false) {
     cJohn.Walk(237, 185, eBlock, eAnywhere);   
     cJohn.FaceLocation(cJohn.x-100, cJohn.y, eBlock);
     cDog.Walk(306, 163, eBlock, eAnywhere);     
     cJohn.LockView(36);
     cJohn.ManualScaling=true;
     cJohn.Scaling=61;
     cJohn.Animate(23, 3, eOnce, eBlock);
     cJohn.FaceLocation(cJohn.x+100, cJohn.y, eBlock);
     cJohn.ManualScaling=false;
     cJohn.UnlockView();
     cJohn.Think("&760 Uh-Oh!");
     stalking=true;
     trimartolod=true;
     hide=true;
     //AUTO-SAVE!!!_______________________________________________
       Overlay* Savy = Overlay.CreateGraphical(130, 116, 2453, false);
       Wait(120);
       DeleteSaveSlot(99);
       SaveGameSlot(99, "Autosave");
       Savy.Remove();
       //__________________________________________________________
       }
     else {
       cJohn.Walk(237, 185, eBlock, eAnywhere); 
     }
}

function room_RepExec()
{
    if(stalking==true) {
      cJohn.Solid=false;
     cDog.FollowCharacter(player, 0, 0);
     stalking=false;
    }
    if(player.GetDistanceFrom(cDog) <= 10 && gLoose.Visible==false && gLoad.Visible==false && stalked == false){
      gBattle.Visible = false;
      Lost=true;
      mouse.Mode=eModeWalkto;
      Verbcoin_Available=true;
      Inventory_Available=true;
      gIconbar.Visible=true;
      Attack();
      stalked=true;
    }
    if(hidden==true && combattle==true ){
      if(cDog.x < 253) {
      //John arm weg :O
      cDog.x=cDog.x+4;
      gBattle.Visible=false;
       oHand.Animate(10, 8, eRepeat, eNoBlock);
       cDog.Animate(11, 4, eOnce, eBlock);
       cDog.Animate(12, 4, eRepeat, eNoBlock);
       PauseGame();
       lLoose.Text = "Ein wahrer H*llenhund des Satan! Gegen solch eine Bestie sollte man gewappnet sein.";
    mouse.Mode = eModePointer;
    gIconbar.Visible = false;
    gLoose.Centre();
    Death = true;
    Button6.NormalGraphic = 3683;
    gLoose.Visible = true;
      hidden=false;}
      else
      if(cDog.x > 295) {
        Win=false; 
        Lost=false;
        GiveScore(1);
        cDog.StopMoving();
        gBattle.Visible=false;
        gIconbar.Visible=true;
        aHowling.Play();
        cDog.Animate(6, 4, eOnce, eBlock);
        oDog.Visible=true;
        cDog.ChangeRoom(0, 0, 0);//Nimmerland;)
        cDog.FollowCharacter(cJohn, 10000, 250);
        oHand.Animate(9, 4, eOnce, eBlock);
        oHand.Animate(7, 4, eOnce, eBlock);
        oHand.Visible=false;
        cJohn.x=241;
        cJohn.Animate(108, 3, eOnce, eBlock, eBackwards);
        cJohn.x=253;
        cJohn.y=150;
        cJohn.FaceLocation(cJohn.x-100, cJohn.y, eBlock);
        cJohn.Scaling=61;
        mouse.Mode=eModeWalkto;
        cJohn.Animate(23, 3, eOnce, eBlock);
        cJohn.ManualScaling=false;
        cJohn.UnlockView();
        hidden=false;
        cJohn.ManualScaling=false;
        Hund_tot=true;
        cJohn.Think("&759 Endlich ist diese tollw/tige Bestie vernichtet. Als w&re der normalsterbliche Sch&ferhund nicht schon bissig genug gewesen.");
        cJohn.Think("&761Hier geht es gar nicht mehr mit rechten Dingen zu und eines ist klar: Ohne das Kreuz w&re ich jetzt blutiger Brei!");
        Wait(20);
        cJohn.LockView(36);
        cJohn.ManualScaling=true;
        cJohn.Scaling=55;
        cJohn.Animate(47, 5, eOnce, eBlock);
        cJohn.FaceLocation(cJohn.x, cJohn.y+100, eBlock);
        cJohn.ManualScaling=false;
        cJohn.UnlockView();
        cJohn.Think("&762 Mich beschleicht das unheimliche Gef/hl das ganz in der N&he noch ein paar von der Sorte sind! Nur wo?");
        Verbcoin_Available=true;
        hide=false;
      }
    }
    


}
function hWindow_UseInv()
{
     if(player.ActiveInventory==iStone && Verbcoin_Available==true){
       if(Seen==true){
         GiveScore(1);
       cJohn.Walk(10, 182, eBlock, eWalkableAreas);
       cJohn.FaceLocation(cJohn.x+100, cJohn.y-100, eBlock);
       Wait(20);
       cJohn.Think("&765 Sesam *ffne dich!");
       cJohn.LockView(36);
       cJohn.ManualScaling=true;
       cJohn.Scaling=100;
       cJohn.Animate(113, 4, eOnce, eBlock);
       aGlassbreaks.Play();
       cJohn.ChangeRoom(37, 198, 317);
     }
     else {
       cJohn.FaceLocation(33, 138, eBlock);
       cJohn.Think("&835 Fenster benutze ich nur im schlimmsten Notfall als Eingang!"); 
     }
     }
     else {
       cJohn.FaceLocation(33, 138, eBlock);
       int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
     }
}

function hFence_Interact()
{
  if(lost==false) {
    GiveScore(1);
    hide=true;
  cJohn.Walk(253, 137, eBlock, eWalkableAreas);
  cJohn.Walk(241, 148, eBlock, eAnywhere);
  cJohn.FaceLocation(cJohn.x-100, cJohn.y, eBlock);
  cJohn.LockView(36);
  cJohn.ManualScaling=true;
  cJohn.Scaling=100;
  cJohn.Animate(108, 3, eOnce, eBlock);
  cJohn.Animate(109, 3, eOnce, eBlock);
  hidden=true;
  lost=true;
  cJohn.x=1000;
  Verbcoin_Available=false;
  }
  else if(lost==true) {
    cJohn.FaceLocation(234, 122, eBlock);
    cJohn.Think("&836 Da springe ich nicht nochmal r/ber");
  }
}

function region1_WalksOnto()
{
    if(hidden==true) {
      cDog.Walk(253, 143, eBlock, eAnywhere);
      cDog.FaceLocation(cDog.x-100, cDog.y, eBlock);
      cDog.StopMoving();
      cDog.LockView(139);
      cDog.Animate(4, 4, eRepeat, eNoBlock);
    }
}

function hClimber_Interact()
{
    cJohn.Walk(224, 160, eBlock, eWalkableAreas);
    cJohn.FaceLocation(cJohn.x-100, cJohn.y-100, eBlock);
    cJohn.LockView(36);
  cJohn.ManualScaling=true;
  cJohn.Scaling=100;
  cJohn.Animate(110, 3, eOnce, eBlock);
  cJohn.FaceLocation(cJohn.x-100, cJohn.y-100, eBlock);
  cJohn.ManualScaling=false;
  cJohn.UnlockView();
}

function hWindow_Look()
{
  if(Hund_tot==true) {
    cJohn.Walk(31, 182, eBlock, eWalkableAreas);
    cJohn.FaceLocation(cJohn.x+100, cJohn.y-100, eBlock);
    cJohn.LockView(36);
  cJohn.ManualScaling=true;
  cJohn.Scaling=100;
  cJohn.Animate(111, 4, eOnce, eBlock);
  cJohn.Think("&763 Oh mein Gott! Mac und seine Familie werden von Untoten angefallen!");
    cJohn.Think("&764 Muss handeln schnell!");
    //Cutscene(Zombies with Baby)etc.
    cJohn.Animate(111, 4, eOnce, eBlock, eBackwards);
    cJohn.FaceLocation(cJohn.x+100, cJohn.y-100, eBlock);
  cJohn.ManualScaling=false;
  cJohn.UnlockView();
  Seen=true;}
  else {
    int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
  }
}

function hWindow_Mode8()
{ 
    cJohn.FaceLocation(34, 138, eBlock);
    cJohn.Think("&848 Da ist au&en nirgends ein Griff!"); 

}

function hDoor_Mode8()
{
    cJohn.Walk(72, 165, eBlock, eWalkableAreas);
    cJohn.LockView(36);
    cJohn.Animate(2, 5, eOnce, eBlock);
    cJohn.FaceLocation(cJohn.x-100, cJohn.y);
    cJohn.Think("&766 Abgeschlossen!");
    cJohn.UnlockView();
    
}

function oDog_Look()
{
      cJohn.FaceLocation(oDog.X, oDog.Y, eBlock);
      cJohn.Think("&837 Um ein Haar h/tte diese Bestie mich zu Geisterj&gerkonfetti verarbeitet.");
}

function oDog_PickUp()
{
      cJohn.FaceLocation(oDog.X, oDog.Y, eBlock);
      cJohn.Think("&838 Wenn ich den anfasse, kriege ich warscheinlich Zombietollwut oder sowas.");
}

function oDog_Talk()
{
      cJohn.FaceLocation(oDog.X, oDog.Y, eBlock);
      int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
}

function hClimber_Look()
{
      cJohn.FaceLocation(216, 125, eBlock);
      cJohn.Think("&849 Kletterpflanzen. Ich frage mich ob man da hochkommt.");
}

function hClimber_PickUp()
{
      cJohn.FaceLocation(216, 125, eBlock);
      int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
}

function hDoor_Look()
{
      cJohn.FaceLocation(70, 145, eBlock);
      cJohn.Think("&315 Es ist eine T/r.");

}


function hDoor_PickUp()
{
       cJohn.FaceLocation(70, 145, eBlock);
       int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
}

function hWindow_Talk()
{
      cJohn.FaceLocation(33, 138, eBlock);
       int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
}


function hFence_Look()
{
    if(lost==false) {
  cJohn.FaceLocation(234, 122, eBlock);
    cJohn.Think("&850 Ein kleiner morscher Zaun.");
  }
  else if(lost==true) {
    cJohn.FaceLocation(234, 122, eBlock);
    cJohn.Think("&851 Das kleine morsche Ding hat mir das Leben gerettet.");
  }
}

function hFence_PickUp()
{
     cJohn.FaceLocation(234, 122, eBlock);
     int i;
    i = Random(9);
    if (i == 0) cJohn.Think("&53 N*."); 
    if (i == 1) cJohn.Think("&54 Oh nein.");
    if (i == 2) cJohn.Think("&55 Keine gute Idee.");
    if (i == 3) cJohn.Think("&56 Hmm...Ich glaube nicht.");
    if (i == 4) cJohn.Think("&57 Das geht nicht.");
    if (i == 5) cJohn.Think("&58 Das wird nicht funktionieren.");
    if (i == 6) cJohn.Think("&59 Hm...");
    if (i == 7) cJohn.Think("&60 Nein.");
    if (i == 8) cJohn.Think("&61 Lieber nicht.");
}

function hExit1_AnyClick()
{
  if(player.HasInventory(iStone)) {
          mouse.Mode=eModeWalkto;
        }
        else {
  if(Verbcoin_Available==true) {
    cJohn.Walk(320, 163, eBlock, eWalkableAreas);
    cJohn.Walk(327, 163, eBlock, eAnywhere);
    player.ChangeRoom(22, 316, 177);
  }
  }
}

function hExit1_MouseMove()
{
        if(player.HasInventory(iStone)) {
          mouse.Mode=eModeWalkto;
        }
        else {
          if(hide==false && Verbcoin_Available==true){
        mouse.Mode=eModeExitRigh;}
}
}

function hNix_MouseMove()
{ 
     if(hide==false && Verbcoin_Available==true) {
     mouse.Mode=eModeWalkto;}
}


Thanks for your help!

SMF spam blocked by CleanTalk