Jump to content

Photo

Combo12CanKillLink Script Freezes Game Link Is Seen But Can't Move


  • Please log in to reply
5 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 21 June 2018 - 12:19 AM

Here

 
import "std.zh"
int Bleu = 11;
global script Combo12CanKillLink
{
  void run()
  {
    Waitframe();
    while (Bleu)
    {
      if (Link->X == ComboX(12) && Link->Y == ComboY(12))
      {
        Game->DCounter[CR_LIFE] -= 4;
      }
    }
  }
}

is the code. How can I fix up above code so Link can move but still if Link's X and Y position are on a Combo 12 CR_LIFE gets drained by 4?



#2 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 21 June 2018 - 12:44 AM

I don't believe global scripts run any commands after Waitframe();

#3 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 21 June 2018 - 12:47 AM

They do for me.

#4 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 21 June 2018 - 06:55 AM

I don't know exactly. But I feel like the issue is in the

if(Link->X == ComboX(12) && Link->Y == ComboY(12))


But in the in the other thread where you asked a similar question, the other coders put in...

Abs before Link and used - between Link->X and ComboX(12)

Try something like...




if (Abs(Link->X - Combo(12)) < 4 && Abs(Link->Y - Combo(12)) < 4)




for that line.

I could be wrong since that was kind of different. But if so, someone else will come in and do it more correctly.


Another immediate possibility in my mind is that it could be how CR_LIFE works.


For instance, in game, when you use a potion, the screen freezes while it fills up your hearts. In which case I don't know how to code this, but if that is the case, this could constantly be draining Link's HP and never giving him that chance to move.


In which case, my best guess would be put on someone else on how to code Link to either gain invincibility frames or to have the game wait to check again between each time he loses life.

Edited by Shoshon the Elegant, 21 June 2018 - 07:00 AM.


#5 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 21 June 2018 - 12:48 PM

So, I talked it over with some of the other scripters, and your Waitframe(); is DEFINITELY what's causing your problem. Basically, as they explained it to me, you have an infinite loop that doesn't start, because the Waitframe() isn't in the right position (It apparently doesn't HAVE to  be at the end, but instructions that run after Waitframe() are run at the top of the loop, which, for whatever reason, isn't working out here for you). Apparently, when active global scripts hang ZC it's almost always because of a problem with the loop and Waitframe()

 

Try this (I haven't tested it):
 

import "std.zh"
int Bleu = 11;
global script Combo12CanKillLink
{
  void run()
  {
    while (Bleu)
    {
      if (Abs(Link->X - Combo(12)) < 4 && Abs(Link->Y - Combo(12)) < 4)
      {
        Game->Counter[CR_LIFE] -= 4;  //This is a quarter-heart damage. Full hearts are 16. Keep note that if you're attempting to set this every frame, you should probably use Game->Counter[], rather than Game->DCounter[]
      }
    Waitframe();
    }
  }
}

Edited by Binx, 21 June 2018 - 12:51 PM.

  • cavthena likes this

#6 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 21 June 2018 - 06:14 PM

To expand on what Binx said here. Your Waitframe was in a different scope from your loop that's why it was not affecting your loop. When you use Waitframe to continue the game while in a loop, the Waitframe needs to be inside the loop.

 

I also want to point out DCounter[]. DCounter only needs to be set once per frame. If you set DCounter to -16 it will remove 1 per frame until 16 has been taken. If you use "Game->DCounter[CR_LIFE] -= 4;" This will set the drain to 4 on the first frame then on the next frame set it to 7, then 10, 13, etc.

Game->Counter[CR_LIFE] will instantly drain the amount you set. It allows you more control but you don't get the drain sounds and visual effects that you get with DCounter[].




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users