Jump to content

Photo

refill arrows to 99 when touching script flag 98


  • Please log in to reply
18 replies to this topic

#1 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 06:20 AM

I want my arrows to refill to 99 when touching water specifically, using flag 98, and make an "item pick up 2" chime when it happens.
Can someone make that for me please?

I'm not good with Zscript.

Edited by Hot Water Music man, 11 November 2009 - 09:08 AM.


#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 11 November 2009 - 08:47 AM

Uhh sure. Off the top of my head:
CODE

ffc script refillerupper
{
  void run(int flag, int ammo, int amount, int sfx)
  {
    while(true)
    {
       Waitframe();
      for(int i; i< 176;i++)
      {
         if(Screen->ComboF[i] == flag)
         {
            if(CollisionRect(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16)
             {
                   doRecharge(ammo, amount);
                   Game->PlaySound(sfx);
                   Waitframes(60);
              }
          }
      }
   }
  void doRecharge(int ammo, int amount)
  {
    Game->Counter[ammo] = amount;
  }
}



Untested. Someone's might have to spice it for you later.

EDIT:edited it a little.

Edited by Gleeok, 11 November 2009 - 08:52 AM.


#3 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 08:53 AM

Error on void doRecharge(int ammo, int amount)

#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 11 November 2009 - 08:55 AM


Well poop.

CODE

ffc script refillerupper
{
  void run(int flag, int ammo, int amount, int sfx)
  {
    while(true)
    {
       Waitframe();
      for(int i; i< 176;i++)
      {
         if(Screen->ComboF[i] == flag)
         {
            if(CollisionRect(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16)
             {
                   Game->Counter[ammo] = amount;
                   Game->PlaySound(sfx);
                   Waitframes(60);
              }
          }
      }
   }
}




#5 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 09:04 AM

line 15: syntax error, unexpected lbrace, expecting rperen or or, on token {
icon_frown.gif

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 11 November 2009 - 08:45 PM

The devil is in the details.
..I think this will work.

CODE
ffc script refillerupper
{
  void run(int flag, int ammo, int amount, int sfx)
  {
    while(true)
    {
       Waitframe();
      for(int i; i< 176;i++)
      {
         if(Screen->ComboF[i] == flag)
         {
            if(RectCollision(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16))
             {
                   Game->Counter[ammo] = amount;
                   Game->PlaySound(sfx);
                   Waitframes(60);
              }
          }
      }
   }
}


arg2 (ammo) is in the range of 0-6. For arrows look in std.zh for C_ARROWS or whatever it is.
...I'm obviously too lazy to be bothered with such tasks. icon_razz.gif

#7 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 11 November 2009 - 09:08 PM

You forgot a closing right brace '}' as well. So that you don't have to go through the pain of posting the edited script a fourth time, I'll do it for you icon_razz.gif
(by the way, CR_ARROWS is 3, HWM man, so you would use that in D1 to accomplish what you originally requested.)

CODE

import "std.zh"
ffc script refillerupper
{
    void run(int flag, int ammo, int amount, int sfx)
    {
        while(true)
        {
            Waitframe();
            for(int i; i< 176;i++)
            {
                if(Screen->ComboF[i] == flag)
                {
                    if(RectCollision(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16))
                    {
                        Game->Counter[ammo] = amount;
                        Game->PlaySound(sfx);
                        Waitframes(60);
                    }
                }
            }
        }
    }
}

Edited by Elmensajero, 11 November 2009 - 09:10 PM.


#8 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 09:34 PM

Can this be an global instead of a FFC combo?

something like

QUOTE

import "std.zh"
global script refillerupper
{
const int flag = 98
const int ammo = 3
const int amount = 99
const int sfx = 25
{
while(true)
{
Waitframe();
for(int i; i< 176;i++)
{
if(Screen->ComboF[i] == flag)
{
if(RectCollision(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16))
{
Game->Counter[ammo] = amount;
Game->PlaySound(sfx);
Waitframes(60);
}
}
}
}
}
}


Something like that?
So far it works great though ,thanks, but the sound keeps going off. It needs an if statement to check if it's already at the current amount of ammo.

Edited by Hot Water Music man, 11 November 2009 - 09:58 PM.


#9 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 11 November 2009 - 09:57 PM

If it were an item script, Link would have to touch or use an item with the script attached before it would run, which isn't exactly what you want I believe. Try this to see if it works better...

CODE

import "std.zh"
ffc script refillerupper
{
    void run(int flag, int ammo, int amount, int sfx)
    {
        while(true)
        {
            Waitframe();
            for(int i; i< 176;i++)
            {
                if(Screen->ComboF[i] == flag)
                {
                    if(RectCollision(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16))
                    {
                        if(Game->Counter[ammo] != amount)
                        {
                            Game->Counter[ammo] = amount;
                            Game->PlaySound(sfx);
                        }
                    }
                }
            }
        }
    }
}


#10 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 09:59 PM

I mean global.

That script is exactly what I needed

Thanks for all your help.
If someone is willing to make it a global script instead of an ffc it would be perfect.

Edited by Hot Water Music man, 11 November 2009 - 10:04 PM.


#11 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 11 November 2009 - 10:07 PM

QUOTE(Elmensajero @ Nov 11 2009, 06:08 PM) View Post

You forgot a closing right brace '}' as well. So that you don't have to go through the pain of posting the edited script a fourth time, I'll do it for you icon_razz.gif


Yeah, thanks. I'm lost without my tab key. icon_unsettled.gif



edit: ok, slightly optimized for a global.

CODE
import "std.zh"
global script slot2{
void run(){
while(true){
  Waitframe();
   SetCounter(98,3, 99, 25);
  }
}
}
  
    void SetCounter(int flag, int ammo, int amount, int sfx)
    {
           if(Game->Counter[ammo] != amount)
           {
            for(int i; i< 176;i++)
            {
                if(Screen->ComboF[i] == flag)
                {
                    if(RectCollision(Link->X,Link->Y,Link->X+16,Link->Y+16,ComboX(i),ComboY(i),ComboX(i)+16,ComboY(i)+16))
                    {
                            Game->Counter[ammo] = amount;
                            Game->PlaySound(sfx);
                    }
                }
            }
        }
    }

Edited by Gleeok, 11 November 2009 - 10:13 PM.


#12 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 10:30 PM

Perfect. Thanks everyone.

#13 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 11 November 2009 - 10:35 PM

For a global script, checking variables and calling functions 176 times seems slightly inefficient to me. Gleeok's script of course should work, but here is how I would have wrote it. Granted, I haven't messed with ZScript for several months, and I don't know if custom arrays are working properly, but checking data for only the four combos Link is touching instead of all of them seems to make more sense to me, and if you are running other global scripts as well, the efficiency could possibly make a difference...

CODE

import "std.zh"

global script slot2
{
    void run()
    {
        while(true)
        {
            Waitframe();
            SetCounter(98,3,99,25);
        }
    }
}

void SetCounter(int flag, int ammo, int amount, int sfx)
{
    //If counter is already set, return to global function
    if(Game->Counter[ammo] != amount) return;
    
    //Get the four combos that Link is touching
    int combo[4];
    combo[0] = ComboAt(Link->X,Link->Y);
    combo[1] = ComboAt(Link->X+16,Link->Y);
    combo[2] = ComboAt(Link->X,Link->Y+16);
    combo[3] = ComboAt(Link->X+16,Link->Y+16);
    
    //If any of those 4 combos have the specified flag, update the counter and play the sound
    for(int i=0; i< 4;i++)
    {
        if(Screen->ComboF[combo[i]] == flag)
        {
            Game->Counter[ammo] = amount;
            Game->PlaySound(sfx);
            return;
        }
    }
}


#14 Lemmy Koopa

Lemmy Koopa

    We are the champions

  • Members
  • Location:Ohio

Posted 11 November 2009 - 11:22 PM

I just noticed flags set by combo properties don't work with scripts.

Edited by Hot Water Music man, 11 November 2009 - 11:23 PM.


#15 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 12 November 2009 - 12:23 AM

QUOTE(Elmensajero @ Nov 11 2009, 07:35 PM) View Post

For a global script, checking variables and calling functions 176 times seems slightly inefficient to me.


Yes, it is indeed VERY inefficient to set that on every screen. I was more or less picturing a fairy type room, in which case it wouldn't matter much at all for that purpose.


QUOTE(Hot Water Music man @ Nov 11 2009, 08:22 PM) View Post

I just noticed flags set by combo properties don't work with scripts.



...are you sure?

Does this do anything?

CODE
global script testyMctestDeathChanceHaha
{
    void run()
    {
        while(true)
        {
            Waitframe();
            for(int i; i< 176;i++){
               if(Screen->ComboF[i] != 0)
                           {
                            Link->HP -= Rand(2);
                Trace(i);
                           }
            }
        }
    }
}


EDIT: Damnitall, I have to stop editing these.. ..My zscript is getting rusty... icon_sweat.gif

Edited by Gleeok, 12 November 2009 - 12:27 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users