PDA

View Full Version : Pulling Pushblocks



Joe123
11-04-2007, 07:45 AM
Would it be possible to script pulling a pushblock with the L button?
And if so, how?

Joe123
11-06-2007, 02:03 PM
Any help please?
If someone can tell me how to do it, then I can try and do it myself, but as of the moment I have no idea how it would be done. It could really help tidy up some points in my game, and I'm sure other people would find it just as useful.

C-Dawg
11-06-2007, 02:21 PM
Hm.

Well, I guess you could do it by:

(1) Checking if player is pulling on a push block;
(2) If so, make Link invisible with an offset item, moving him to the other side of the block. FFC that looks like Link pulling is left where he was. Player is then pushing. Make sure solid push blocks rule is on!
(3) Put Link back on the other side of the block.

That would generally work, but it has limitations. Like, if there is a solid block on one side of the block being pushed, can Link push it?

-C

Joe123
11-06-2007, 02:27 PM
Hmm, interesting.
I'll have a look into this later, thanks.

Joe123
11-07-2007, 12:53 PM
OK, I'm working on this now and it's going quite well.
I have the Pulling Left direction mostly set up, I just need to sort out interaction with combo types on the far side of the block (which isn't going too well but I'm slowly making progress with), make sure it meshes properly with block triggers, make sure he can't pull whilst on the edge of the screen (which would result in him dissapearing) and sort out it's interaction with the roll script which at the moment is abysmal.

One problem I'm having, however, is moving Link whilst the block moves (so that it doesn't land on top of my DrawTile Link).
I have this:

for(timer = 0; timer < 16; timer++){
Link->X = Link->X-1;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputDown = false;
Link->InputUp = false;
Screen->DrawTile(2, Link->X-32, Link->Y, 54805, 1, 1, 6, 1, 0, 0, 0, 0, true, 128);
Waitframe();
}
Which makes Link move left one pixel every frame for 16 frames, whilst keeping up the DrawTile function and all that nonsense.
What I need though, is for Link to move left one pixel every other frame. How would I go about doing this? I can't seem to work it out without making 16 for loops, which I am just not doing.

C-Dawg
11-07-2007, 04:58 PM
Use a counter. Like this:

if ( int movement_counter == 1){

Link->X = Link->X - 1;
movement_counter = 0;

}
else
{movement_counter++}

That way, Link will only get moved every other frame. Or increase the "1" if you want him to move every three or whatever.


OF COURSE you could short-circut this nonsense by setting up an FFC to act as a block. Make the FFC faux unwalkable, have it pullable and pushable. You'd need to script your own switches and so forth though. The way you're doing it lets the player use garden variety push blocks.

Joe123
11-07-2007, 06:28 PM
You mean put that counter inside the for loop?

And I know I could do it via an FFC, but I'm all for minimal set-up and minimal use of screen resources.

Thanks :)

It's working pretty much perfect now, I just need to duplicate for all directoins.

Praethus
11-07-2007, 11:35 PM
A boolean would be easier than a counter.



boolean moveLink = true;

for i = 0 to 15
if movelink
//move link
movelink = !movelink
end for


Every time through the loop it will flip the movelink variable. When its true, Link moves, when its false, he doesn't.

Joe123
11-08-2007, 03:59 AM
Urrrr
I don't really understand booleans
Are they like integers, but only with two states, true and false?

Praethus
11-08-2007, 10:32 AM
Exactly.

Joe123
11-08-2007, 11:52 AM
Wait, assuming that the syntax for what you posted earlier would be:

for(timer = 0; timer < 32; timer++){
if(movelink){Link->X = Link->X -1;}
movelink = !movelink;
}

Won't that activate once, then set movelink to false so it won't happen again?

Praethus
11-08-2007, 04:50 PM
No. movelink starts as true. Then its get set to not true (! = not) aka false. Then it gets set to not false (! = not again) aka true. ! means set it to not whatever, not set it to false.

C-Dawg
11-08-2007, 05:10 PM
Why use the for loop at all? Just put this in your general "while(true)" loop:

linkmoves = !linkmoves;

if(linkmoves){ Link->X = Link->X++;}


That'll execute once and only once each time through the while loop.

Joe123
11-08-2007, 06:37 PM
Ohhh, thanks Preathus.
However, if I do it like that I can't then only have Link move every 3 frames or something, so I'll stick to the counter for my current purposes.

And because I want the rest of the script to stop while I use the for loop, makes it less confusing, I have 3 or 4 tiers of if statments or something like that so for means I don't have to worry about the rest of the script while that part's running.

shadowfall1976
01-03-2008, 04:04 PM
has any progress been made Joe?, I would love to use this when
you get it done.

Joe123
01-03-2008, 04:58 PM
Blimey, I left off on this one months ago.

I'd got it working quite nicely in one direction, but when I duplicated the script for the other directions I ran into endless problems.

There were also quite a few bugs with it, and especially with it's interaction with Beefster's Roll script.

And no-one drew me sprites for DoR Link pulling the blocks in the end aswell, which wasn't great either.

I might well go back and have a look at it again sometime though, it'd definately be worth completing I think.

It will take a long time to re-work it and find out how I was doing it again though, I might well end up re-writing it.

beefster09
01-07-2008, 06:45 PM
Hey, do you think it would be possible to make blocks pulled with the hookshot? That would be pretty cool.

Joe123
01-07-2008, 07:01 PM
I'd say yes, provided that you re-scripted the hookshot.

pkmnfrk
01-07-2008, 07:19 PM
Actually, not necessarily. Remember, the combos that you set on FFCs can have flags (inherent, for sure, maybe regular), and can be triggered. FFCs have a "WasTriggered()" function which indicates this very condition. So, if you make the FFC react to hookshots, then you can have a script like this:


while(this->WasTriggered() == false) {
Waitframe();
}

if(abs(Link->X - this->X) > abs(Link->Y - this->Y)) {
//from the top or bottom
if(Link->Y < this->Y) { //top
//move me up
} else {
//move me down
}
} else {
//from the left or right
if(Link->X < this->X) { //left
//move me left
} else {
//move me right
}
}


So, this is perfectly viable. The catch is that they can only be pulled once, since I don't think you can reset WasTriggered() anyway.

Gleeok
01-08-2008, 12:19 AM
Hey, do you think it would be possible to make blocks pulled with the hookshot? That would be pretty cool.

Hey that's not a bad idea. I'm sure you could get it to pull enemies as well, or, maybe just certain kinds of them set with enemy->Tile. It would probably look stupid reeling in a Gleeok.


Instead of wastriggered() howabout just using is_walkable type functions and let the player pull it around wherever it will fit, untill it triggers something.

Russ
01-08-2008, 01:34 AM
Hey, do you think it would be possible to make blocks pulled with the hookshot? That would be pretty cool.
Pineconn did it in Link to the Heavens. And he didn't use scripts! Just careful use of hookshot flags and combo cycling. But I think someone made a script for hookshotable bridges (like where the hookshot pulls the bridge out). Check the last page of the script showcase forum.

pkmnfrk
01-08-2008, 06:56 PM
Instead of wastriggered() howabout just using is_walkable type functions and let the player pull it around wherever it will fit, untill it triggers something.

Because you have no means of tracking the hookshot itself. If that was possible, then I could easily write a script that did that.