PDA

View Full Version : Item use scripts



pkmnfrk
07-01-2007, 11:01 PM
In an item use script, are you supposed to have access to the position of the item?

I know that in some cases, like the whistle for example, this is undefined, since it doesn't actually show up on screen. But, for an item like the bomb, knowing where the bomb is would be quite useful.

I tried this, but it doesn't work:


item script icebombuse {
void run() {
int x = this->X;
int y = this->Y;
int w = ComboAt(x,y);
Screen->ComboD[w] = 0;
}
}

x and y are both -1000, which seems to be "undefined". (I know that blindly nulling any combo you blow up is pointless, but it's just a test >_>)

Dan Furst
07-02-2007, 09:52 AM
Maybe you want to use Link->X and ->Y instead. For example, do


int x = Link->X;
int y = Link->Y;

// do the action 1 combo in front of Link
if(Link->Dir == DIR_UP)
int w = ComboAt(x, y-16);
else if(Link->Dir == DIR_DOWN)
int w = ComboAt(x, y+16);
else if(Link->Dir == DIR_LEFT)
int w = ComboAt(x-16, y);
else if(Link->Dir == DIR_RIGHT)
int w = ComboAt(x+16, y);

Screen->ComboD[w] = 0;


Though I don't know why this-> wouldn't work. Did you set the item as an equipment item? (Quest - Items - (select) - Edit - Data tab - Equipment Item)

pkmnfrk
07-02-2007, 12:16 PM
Yes, my Ice Bomb is a total clone of the normal Bomb, but with a script attached (and different tiles).

I'll probably end up doing that. I also wish there was a way to delay the script until the bomb explodes, but I'll make do.

C-Dawg
07-02-2007, 12:32 PM
this-> doesnt work because it points to the item in your inventory, not to the lit bomb item spawned by the item. We have no way of interacting with lit bombs, swords, enemy projectiles, or other action sprites yet.

Complain to Dark.

DarkDragon
07-02-2007, 01:15 PM
I know, I know. Due to feature freeze this feature won't be available until after 2.5. Until then, you'll have to fake any such effects with FFCs.

pkmnfrk
07-02-2007, 01:26 PM
Hmm... fake with a FFC... yes, that could work...

Dan Furst
07-02-2007, 01:53 PM
Hmm... fake with a FFC... yes, that could work...

It seems to be the preferred method. :laughing:

pkmnfrk
07-02-2007, 02:30 PM
Indeed, a valid method. Although, I can see how annoying it would be for some general purpose items.

In my case, the Ice Bombs (which can freeze lava, etc) only have to have an extra effect on screen where there is actually lava to freeze (which is a rather small portion of screens). So, I can omit the FFCs on other screens.

But, on the other hand, if I were to create some sort of gun, I would have to include the FFC on every screen, since:

1. You can't set an FFC's script at run time
2. FFCs don't carry over when off screen or when their combo is 0
3. You don't want the projectile on screen when you're not using it.

C-Dawg
07-02-2007, 03:10 PM
Well, Pkmnfrk, you can solve all of those by making a blank combo that's not combo 0, and setting the FFC to that when it's not in use. Also make sure the FFC interacts with NOTHING when it's set to that combo.

In Zodaic, Combo 1 is a blank combo. Custom weapons don't interact or move or anything when they're set to that combo. So you can store it in plain sight.

Then you just have to respect all of the peculilarities about carryovers.

Dan Furst
07-02-2007, 03:50 PM
It's starting to sound like we know what were talking about, regarding scripting. The horror! :D

We need more features to bring us back to our confused and frustrated state! :gavel:


Back on topic, the ice bomb sounds like a cool item. /end pun

pkmnfrk
07-02-2007, 04:34 PM
Well, Pkmnfrk, you can solve all of those by making a blank combo that's not combo 0, and setting the FFC to that when it's not in use. Also make sure the FFC interacts with NOTHING when it's set to that combo.

In Zodaic, Combo 1 is a blank combo. Custom weapons don't interact or move or anything when they're set to that combo. So you can store it in plain sight.

Then you just have to respect all of the peculilarities about carryovers.

Ah touché, didn't even think of that. Here's to stretching the limits!