Jump to content

Photo

My first scripts.


  • Please log in to reply
35 replies to this topic

#1 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 07 February 2010 - 01:50 PM

icon_razz.gif Yeah, I'm trying to make easy scripts.
First, a script by Saffith (from the tutorial) with a D-argument put in it. I don't know why, but I love making D-arguments. icon_smile.gif
CODE
ffc script rotating_quadrat
{
     void run(int lol)
     {
      int angle;
      for(angle = 0; true; angle = (angle + lol) % 360)
      {
        Screen->Rectangle(6, Link->X - 16, Link->Y - 16, Link->X + 32, Link->Y + 32,
                          Rand(16), 1, Link->X + 8, Link->Y + 8, angle, false, 128);
        Waitframe();
      }
     }
}


It allows you to set the speed of the rectangle's rotation with D0. And it works. icon_razz.gif

Now, a self-made motion script. Motion-scripts are actually the only script I can make, and only easy ones. ^^" I don't know if it works, I haven't time to test it and my Zquest has actually a big script-compatiblity trouble, so....

CODE
ffc script rhombus
{
    void run( int side_of_it)
       {
           this->Vx += side_of_it;
           this->Vy += side_of_it;
           this->Vx  -= side_of_it;
           this->Vy += side_of_it;
           this->Vx -= side_of_it;
           this->Vy -= side_of_it;
           this->Vx += side_of_it;
           this->Vy -= side_of_it
     }
}


This one should make that the FFC makes an rhombic motion with equal sides. You can set the length. If you set a negative number, the FFC begins his motion on the bottom edge of the rhombus (if positive, on the top). I have no idea how to make a anti-clockwise motion by setting D-arguments. icon_wacky.gif

CODE
ffc script rhombic_catastrophe
{
    void run( int side1, int side2, int side3, int side4)
      {
         this->Vx += side1;
           this->Vy += side1;
           this->Vx  -= side2;
           this->Vy += side2;
           this->Vx -= side3;
           this->Vy -= side3;
           this->Vx += side4;
           this->Vy -= side4
      }
}


A second rhombus, with the possibility to make not equal sides. If the opposite sides haven't the same length, the FFC should go out of the screen after a given time. You should not make a negative number, this can result in a non-rhombus. icon_confused.gif

Question: What are the A-argument? icon_eek.gif



#2 Joe123

Joe123

    Retired

  • Members

Posted 07 February 2010 - 02:20 PM

Your rhombus scripts won't work because they have no idea of time frame. The commands are fine, but the script just calls them all in a row rather than saying 'wait for this long, then change direction'.
You need to use 'while' and 'Waitframe();'

The A arguments are used for ZASM scripts.

#3 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 08 February 2010 - 11:33 AM

Thanks Joe123! Zscript is more used than ZASM, isn't it? Can Zscript do more, or have both the same possibilities?

I've rewritten the first rhombus script yesterday:

CODE
ffc script rhombus
{
    void run( int long, int speed)
  {
     while(true)
     {
       this->Vx += speed;
       this->Vy += speed;
       Waitframe(long);
       this->Vx -= speed;
       this->Vy += speed;
       Waitframe(long);
        this->Vx -= speed;
       this->Vy -= speed;
       Waitframe(long);
        this->Vx += speed;
       this->Vy -= speed;
       Waitframe(long)
     }
  }
}


D0 is the length of the sides, D1 is the speed of the FFC. A negative speed makes the FFC begins on the bottom of the rhombus. (it SHOULD icon_sweat.gif ).

Edited by The one from the red sand, 08 February 2010 - 11:34 AM.


#4 Joe123

Joe123

    Retired

  • Members

Posted 08 February 2010 - 12:26 PM

QUOTE(The one from the red sand @ Feb 8 2010, 04:33 PM) View Post
Thanks Joe123! Zscript is more used than ZASM, isn't it? Can Zscript do more, or have both the same possibilities?
Yeah, ZScript is much more widely used.
The reason for having ZASM is that higher level languages have to be broken down into assembly code and then byte code before they're readable by the computer. ZASM is the assembly code that ZScript breaks down to (which is there the 'ASM" comes from in the name). Technically I think ZASM can probably do more than ZScript, but I don't think there'd be anything particularly notable - the reason for it's being as far as I understand is so that we can have ZScript.

#5 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 31 July 2010 - 07:28 AM

I want to make an Eweapon-spawning Freeform Combo for custom bosses.
CODE
ffc script ShootingFFC
{
     void run(int enwe)
     {
           Screen->CreateEWeapon(enwe);
     }
}

I wanted to use CreateEWeapon(enwe, this->X, this->Y), but this doesn't exist...

#6 Master Maniac

Master Maniac

    Earth, Wind, Fire, and Water.

  • Members
  • Real Name:kris

Posted 31 July 2010 - 09:59 AM

QUOTE(The one from the red sand @ Jul 31 2010, 04:28 AM) View Post
I want to make an Eweapon-spawning Freeform Combo for custom bosses.
CODE
ffc script ShootingFFC
{
     void run(int enwe)
     {
           Screen->CreateEWeapon(enwe);
     }
}

I wanted to use CreateEWeapon(enwe, this->X, this->Y), but this doesn't exist...


Nice start, but here's a bit that may help you. You can name your EWeapons, LWeapons, and FFC's. Like this:

CODE
ffc script EnemyThatShoots{
    void run(int ewnum){

        eweapon thing = Screen->CreateEWeapon(ewnum);
        thing->X=this->X;
        thing->Y=this->Y;
    }
}


But there is also a function that will allow you to specify the EWeapon's starting position, I believe..

Here it is. It's already in your STD.ZH file, so don't worry about adding it. Just showing you:
CODE
eweapon CreateEWeaponAt(int id, int x, int y) {
  eweapon ew = Screen->CreateEWeapon(id);
  ew->X = x;
  ew->Y = y;
  return ew;
}


Use CreateEWeaponAt() to make coordinates happen icon_wink.gif


#7 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 31 July 2010 - 10:58 AM

Thank you very much for the first way! icon_biggrin.gif

But this doesn't work...:
CODE
ffc script ShootingFFC
{
     void run(int enwe)
     {
           Screen->CreateEWeaponAt(enwe, this->X, this->Y);
     }
}


Thanks for reading!

#8 Master Maniac

Master Maniac

    Earth, Wind, Fire, and Water.

  • Members
  • Real Name:kris

Posted 31 July 2010 - 01:03 PM

Are you getting an error message when it compiles?

#9 Saffith

Saffith

    IPv7 user

  • Members

Posted 31 July 2010 - 03:52 PM

You don't need the Screen-> there; functions in std.zh (and any other header file) are all global.

#10 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 09 August 2010 - 05:25 AM

You mean:
CODE
ffc script ShootingFFC
{
     void run(int enwe)
     {
        CreateEWeaponAt(enwe, this->X, this->Y);
     }
}
?

There's an error: Function CreateEWeaponAt is undeclared.



#11 Joe123

Joe123

    Retired

  • Members

Posted 09 August 2010 - 05:34 AM

Make sure you
CODE
import "std.zh"
at the top of your script file.

#12 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 09 August 2010 - 06:53 AM

Oh, I forgot this! I made a test quest and I forgot to put the import ''std.zh''!
Anyway, thank you very much!
I wanted to make that the EWeapon is shooted more than once, so I write a while loop. But I forgot the waitframe and so, it crashed.
I don't know why, but only Waitframe() works....why doesn't Waitframes(120) works?



#13 Joe123

Joe123

    Retired

  • Members

Posted 09 August 2010 - 07:11 AM

Waitframes(120) should work, was it just this:
CODE
ffc script ShootingFFC
{
     void run(int wpn)
     {
          while(true)
          {
               CreateEWeaponAt(wpn, this->X, this->Y);
               Waitframes(120);
          }
     }
}
?

#14 The one from the red sand

The one from the red sand

    Experienced Forumer

  • Members

Posted 09 August 2010 - 08:12 AM

Thanks, now it works, I think I wrote something false (but no idea what).
Added a little sound effect:
CODE
ffc script ShootingFFC
{
     void run(int wpn, int SFX)
     {
          while(true)
          {
               CreateEWeaponAt(wpn, this->X, this->Y);
               Game->PlaySound(SFX);
               Waitframes(120);
          }
     }
}

So, the next step....how to make that a EWeapon like magic or arrow is shot in Link's directions, like a projectile enemy?

#15 Joe123

Joe123

    Retired

  • Members

Posted 09 August 2010 - 08:19 AM

I think if you make an EW_FIREBALL it should shoot at Link by default?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users