Jump to content

Photo

Gradual Drain/Increase coding possible?


  • Please log in to reply
2 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

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

Posted 04 April 2020 - 05:24 PM

Preferably with sound until conditions are met?

 

 

 

#1: Like would the following code

import "std.zh"
int decrease_hp_amount = 4;
int drain_hp_amount = 0;
bool decrease_hp = false;
 
 
 
global script what_is_needed_every_second_in_game
{
  void run()
  {
    while(true)
    {
      if (decrease_hp == true)
      {
        if (drain_hp_amount != 5)
        {
          Link->HP -= 1;
          drain_hp_amount += 1;
          Screen->SoundPlay(SFX_HPDrain);
        }
        else if (drain_hp_amount == 5)
        {
          drain_hp_amount += 0;
        }
      }
    }
    else if (decrease_hp == false)
    {
      drain_hp_amount = 0;
    }
      Waitframe();
  }
}
 
 
 
item script DrainHPPotion
{
  void run()
  {
    while(true)
    {
      decrease_hp = true;
      drain_hp_amount = 5;
      Waitframe();
    }
  }
}

work properly or no?

 

 

 

If no how do I change up above code to work properly please? Thank you.

 

 

 

#2: What do I replace in up above code if I want Rupees drained instead of HP please? Thank you.



#2 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 04 April 2020 - 05:29 PM

...if you want to drain hp, you can just use a DCounter.

item script drainHP
{
    void run(int hpToDrain)
    {
        Game->DCounter[CR_LIFE] -= hpToDrain;
    }
}

To drain rupees? 'CR_RUPEES' instead of 'CR_LIFE'. You can do this for any 'Counter'. You can find a list of the 'CR_' things in 'std_constants.zh'. Any of them will work.



#3 LikeLike888

LikeLike888

    Spicy food lover!!

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

Posted 04 April 2020 - 06:23 PM

Thank you all so super much


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users