Jump to content

Photo

Some tricky Item Scripts


  • Please log in to reply
14 replies to this topic

#1 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 03 September 2007 - 07:48 PM

Okay, first things first: I'm still working on Molka Elite, though what I'm trying to accomplish isn't for that project. Basically I've been monkeying around with 2.5b trying to teach myself ZScript... Not going so well.

I want to make it so when you use the Potion item, you're able to shoot sword beams for 48 slashes. (By default, none of the swords can shoot beams.) I tried to accomplish this by writing a script that gives Link a Level 2 Peril Beam Scroll when he uses the Potion, and the Scroll is set to 32 Hearts Max (meaning literally always active). The scroll also sets a global variable called "BeamUse" to 48. Then I tried assigning a script to each sword that, if "BeamUse" is higher than 0, lowers that variable by 1 each time the sword is used, and if it's equal to 0, it removes the Level 2 Scroll from Link's inventory.

Complete and utter failure. The Scroll doesn't even show up in Link's inventory when he drinks the Potion. icon_cry.gif

I know some of you are decent scripters-- I've seen some of Matthew's work at AGN, which is actually what inspired me to learn it myself. But it's not working out. Could anyone compose this script for me so I can see where I messed up?

Again, this has nothing to do with Molka Elite... More than anything I just want to see if it's possible, but I might use this in a future project or something. I'm not sure at this point.

Any assistance would be highly appreciated. Thanks guys. --Schwa

#2 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 04 September 2007 - 09:51 AM

QUOTE(Schwa @ Sep 3 2007, 08:48 PM) View Post

Okay, first things first: I'm still working on Molka Elite, though what I'm trying to accomplish isn't for that project. Basically I've been monkeying around with 2.5b trying to teach myself ZScript... Not going so well.

I want to make it so when you use the Potion item, you're able to shoot sword beams for 48 slashes. (By default, none of the swords can shoot beams.) I tried to accomplish this by writing a script that gives Link a Level 2 Peril Beam Scroll when he uses the Potion, and the Scroll is set to 32 Hearts Max (meaning literally always active). The scroll also sets a global variable called "BeamUse" to 48. Then I tried assigning a script to each sword that, if "BeamUse" is higher than 0, lowers that variable by 1 each time the sword is used, and if it's equal to 0, it removes the Level 2 Scroll from Link's inventory.

Complete and utter failure. The Scroll doesn't even show up in Link's inventory when he drinks the Potion. icon_cry.gif

I know some of you are decent scripters-- I've seen some of Matthew's work at AGN, which is actually what inspired me to learn it myself. But it's not working out. Could anyone compose this script for me so I can see where I messed up?

Again, this has nothing to do with Molka Elite... More than anything I just want to see if it's possible, but I might use this in a future project or something. I'm not sure at this point.

Any assistance would be highly appreciated. Thanks guys. --Schwa

Lol, glad to hear I've been inspiring people. XD Give me the script you have now, and I'll take a look at it. BTW, remember that you can't use Waitframe or While loops in Item Scripts. Waitframes equal Quit()s in Item scripts, and since While loops NEED Waitframe to work... You get the idea. Basically, what you need is an FFC script. Have the item script set a variable on the FFC script to "activate" it, then let it go to work. But... I don't think it can check for usage of Link's items yet... I may be wrong, though.

#3 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 04 September 2007 - 10:59 AM

No, I'm not looking for an FFC script... Otherwise I'd have to put the FFC in every room in the game. And I knew the rule about Waitframe() and While Loops... Here's what I got so far.

The script for the Potion, where Item[126] equals the Level 2 Peril Beam Scroll:
CODE
import "std.zh"

int BeamCount = 0;

item script goldpotion
{
  void run()
  {
    Link->Item[126] = true;
    BeamCount = 48;
  }
}


And the script I gave each sword to take the Scroll away after 48 slashes:
CODE
import "std.zh"

int BeamCount = 0;

item script magicbeam
{
  void run()
  {
    if (Link->Item[126] == true)
    {
      if (BeamCount > 0)
      {
        BeamCount -= 1;
      }
      else
      {
        Link->Item[126] = false;
      }
    }
  }
}


I think the problem might have something to do with setting global variables at the beginning of each script, but I don't know a better way to do it... >_<

#4 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 04 September 2007 - 02:44 PM

QUOTE(Schwa @ Sep 4 2007, 11:59 AM) View Post

No, I'm not looking for an FFC script... Otherwise I'd have to put the FFC in every room in the game. And I knew the rule about Waitframe() and While Loops... Here's what I got so far.

The script for the Potion, where Item[126] equals the Level 2 Peril Beam Scroll:
CODE
import "std.zh"

int BeamCount = 0;

item script goldpotion
{
  void run()
  {
    Link->Item[126] = true;
    BeamCount = 48;
  }
}


And the script I gave each sword to take the Scroll away after 48 slashes:
CODE
import "std.zh"

int BeamCount = 0;

item script magicbeam
{
  void run()
  {
    if (Link->Item[126] == true)
    {
      if (BeamCount > 0)
      {
        BeamCount -= 1;
      }
      else
      {
        Link->Item[126] = false;
      }
    }
  }
}


I think the problem might have something to do with setting global variables at the beginning of each script, but I don't know a better way to do it... >_<

Yes, that's your problem. First off, define BeamCount as a Global variable before "void run". Then, modify it wherever you want. In the sword's script, "import (filename of previous script)". That'll allow it to use its global variables. Unfortunately, you also have to take out import std.zh, too. But it'll still get used in the sword's script. Do NOT define BeamCount in the sword script. Simply use it with "(filename for potion).BeamCount [stuff here]". That should work, then. I think. If it doesn't, let me know...

#5 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 04 September 2007 - 02:54 PM

So for the Sword script, importing "goldpotion.z" won't run that script every time the sword is used? I thought the Import command ran a script inside a script... Mind telling me what it actually does?

I'll try this new method and tell you if it works. Thanks.

#6 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 04 September 2007 - 03:17 PM

Importing doesn't run a script. It basically just imports the global variables and constants. See std.zh. It's nothing BUT constants.

#7 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 04 September 2007 - 04:36 PM

I got everything to work except the sword beam firing, but I KNOW this isn't because of the script-- it's a problem with the game, because I went into an empty Quest file and tried every possible combination with sword and Peril Beam settings, and it did absolutely nothing. I reported it as a possible bug at AGN.

But the SCRIPT works perfectly! You get the Scroll when you use the Potion, and you lose it when you've slashed the sword 48 times!

Thanks for the help. icon_biggrin.gif I'll have to remember this trick about importing global variables.

I know! I can be your sidekick! "Schwa-Boy". icon_xd.gif

Edit: Schwa's 400th Post is at hand. icon_sly.gif

Edited by Schwa, 04 September 2007 - 04:37 PM.


#8 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 04 September 2007 - 04:50 PM

This script is full of possibilities. You could do a simple change to make it count in frames, which are 1/60 of a second, instead of sword slashes and make a potion that makes you virtually invincible for the next 30 seconds. The manipulation is ENDLESS.

#9 Schwa

Schwa

    Enjoy the Moment more. This strengthens Imagination.

  • Members
  • Real Name:Hunter S.
  • Location:Redmond Subspace (I had a Potion)

Posted 04 September 2007 - 10:32 PM

I improved the script a little. I made 4 new swords which look just like their Levels 1-4 counterparts, only their icons are flashing, they do twice as much damage and they can shoot a beam (none of the normal swords can shoot beams). Then I made the script give you each sword's counterpart depending on which sword you carry. This way, no matter which sword you carry, it's assured you do double damage when you drink the potion (plus shoot a beam), plus the flashing effects are good at showing you when your sword is in "hyper mode" or not. icon_biggrin.gif

If you guys like, I'll show you what I did... icon_wink.gif

#10 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 05 September 2007 - 05:54 AM

Schwa, how were you able to increase item damage? I tried this and failed. What's worse is no-one knew why. It would be awesome if you posted how that. icon_smile.gif

Truly awesome.

#11 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 05 September 2007 - 09:24 AM

Gleeok: Item Editor, increase Power. 1 = 1 Heart worth of damage. (On enemies in the Enemy Editor, 2 is 1/2 of a Heart, 1 is 1/4 of a heart, so 4 is one whole heart.)

#12 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 05 September 2007 - 11:29 AM

QUOTE(Matthew @ Sep 5 2007, 08:24 AM) View Post

Gleeok: Item Editor, increase Power. 1 = 1 Heart worth of damage. (On enemies in the Enemy Editor, 2 is 1/2 of a Heart, 1 is 1/4 of a heart, so 4 is one whole heart.)


LOL!!! ...Umm, no that's not what I mean..hehe.

I'm referring to a script where it can temporarally increase power. ie wooden sword (power 2) -->insert script trigger here<--- wooden sword power 97!! You get the picture.

#13 Titanium Justice

Titanium Justice

    Justice is served!

  • Members
  • Real Name:Jared
  • Location:Ontario

Posted 05 September 2007 - 12:39 PM

icon_blink.gif yay i have 2.50 im not realy scripting anything cause that's not my quest's version but i would like to know some scripts icon_cool.gif

#14 Nimono

Nimono

    Ultra Miyoa Extraordinaire!

  • Members
  • Real Name:Matthew
  • Location:Static Void Kingdom

Posted 05 September 2007 - 01:13 PM

QUOTE(Gleeok @ Sep 5 2007, 12:29 PM) View Post

LOL!!! ...Umm, no that's not what I mean..hehe.

I'm referring to a script where it can temporarally increase power. ie wooden sword (power 2) -->insert script trigger here<--- wooden sword power 97!! You get the picture.

Oh. I think you can only do that by giving the player a new item with that power. Then again, I haven't made any scripts for the new builds, so.... I'll get back to you on that, okay?

#15 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 08 September 2007 - 03:48 PM

QUOTE(Gleeok @ Sep 5 2007, 11:29 AM) View Post


LOL!!! ...Umm, no that's not what I mean..hehe.

I'm referring to a script where it can temporarally increase power. ie wooden sword (power 2) -->insert script trigger here<--- wooden sword power 97!! You get the picture.
He's not changing the original items at all... Schwa's just replacing the original wooden sword with a more powerful item.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users