Some tricky Item Scripts
#1
Posted 03 September 2007 - 07:48 PM
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.
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
Posted 04 September 2007 - 09:51 AM
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.
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
Posted 04 September 2007 - 10:59 AM
The script for the Potion, where Item[126] equals the Level 2 Peril Beam Scroll:
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:
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
Posted 04 September 2007 - 02:44 PM
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:
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:
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
Posted 04 September 2007 - 02:54 PM
I'll try this new method and tell you if it works. Thanks.
#6
Posted 04 September 2007 - 03:17 PM
#7
Posted 04 September 2007 - 04:36 PM
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. I'll have to remember this trick about importing global variables.
I know! I can be your sidekick! "Schwa-Boy".
Edit: Schwa's 400th Post is at hand.
Edited by Schwa, 04 September 2007 - 04:37 PM.
#8
Posted 04 September 2007 - 04:50 PM
#9
Posted 04 September 2007 - 10:32 PM
If you guys like, I'll show you what I did...
#10
Posted 05 September 2007 - 05:54 AM
Truly awesome.
#11
Posted 05 September 2007 - 09:24 AM
#12
Posted 05 September 2007 - 11:29 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.)
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
Posted 05 September 2007 - 12:39 PM
#14
Posted 05 September 2007 - 01:13 PM
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
Posted 08 September 2007 - 03:48 PM
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.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users