PDA

View Full Version : Tricky Item Scripts (copied from PureZC)



Schwa
09-03-2007, 08:54 PM
Hi guys! This is my first post at AGN. (I hail from PureZC.) You guys seem to have a slightly more formidable force of scripters here than at PureZC (no offense to my homies ;) )... ShadowMancer, I envy you and your skill. :O Ahem... Anyway, I'll just copy-paste my post from PureZC to save time, if that's alright with you guys.


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

That pretty much sums it up. Think any of you could assist me? Thanks in advance. :)

C-Dawg
09-03-2007, 09:28 PM
Sounds like the problem may not be with your script, but with your sub-screen setup. I know there were some bugs involved with custom items in earlier alpha releases, too. Might want to make sure you're using the latest version.

If it is a scripting problem, we can't tell without seeing your script. Post it and we'll check it out.

beefster09
09-03-2007, 10:46 PM
I think it has to do with the way you disabled sword beams. If you did it by making the percentage over 100, then it probably won't work. Try setting the beam hearts without percentage to 25.

And Hi Schwa!

Schwa
09-04-2007, 12:19 AM
Okay, here's the scripts I wrote. Both of them compile fine in the editor yet cease to function remotely in the actual game.

Here's the script I gave the Potion... Item[126] is the Level 2 Peril Beam Scroll.

import "std.zh"

int BeamCount = 0;

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

And here's the script I gave each of the swords.

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;
}
}
}
}

Do you think it has something to do with the Initial Global Variable declaration? If so, I have no idea any other way to do it... Scripting is immensely difficult without a *complete* list of code commands...

Also, I'm sure I have the latest version. That's a mistake you'll never catch me make.

And hi Beefster. :P

beefster09
09-04-2007, 08:13 PM
That's odd. The code should work as long as the global variable declaration is at file scope and the two scripts are loaded into the same buffer.

If it still doesn't work, try checking the item editor for oversights.

ShadowMancer
09-04-2007, 09:14 PM
Humm, script looks solid to me only thing I can think of is (as beefster said) check that you only loaded the script into the buffer once (a common mistake is to import 2 scripts seperately thus causeing the 1st script to be erased) Also make sure you Loaded the scripts into the proper slots and finally make sure you set the item use script (not item pickup script)

All together now ;)


import "std.zh"

int BeamCount = 0;

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



ShadowMancer, I envy you and your skill Thanx :redface:
(C-Dawg is probley the real top scripter here, i've just been showing my face alot lately, check out Zodiac you'll be blown away by the scripts there :) )