Neat. So, a few questions, please:
For one, these Combo scripts will be global, in that wherever the combo is placed, each iteration of the combo will have the script running on its own individual combo? Or will it affect every instance of that combo on the entire screen? (In which case, to make them work individually, we'd just duplicate the combo and place the duplicates on the screen.)
Each combo will be running the script. Combos on layers can run the script, depending on QRs.
while(1)
Does "1" just mean "true?" If so, does that work elsewhere, so we can replace "true" with "1" ?
In this case, they are identical. In general, it is better to use 'true', because functions can be overloaded with multiple versions which take different parameters.... the main thing is, `int` casts implicitly to `bool`, meaning `bool foo = 1;` will be `true`. Generally it's better for readability to use `true` or `false` for booleans, though.
if ( ( Abs(Hero->X - this->PosX()) < 8 )
The need for the Abs implies that the player won't be somewhere off-screen, or we don't care if they are? What's their purpose here, please?
It's not Abs'ing the hero's position, it's Abs'ing the difference of position. So, if the hero is 4 pixels LEFT of the combo, then it's `Abs(-4)`. If he's 4 pixels RIGHT of the combo, it's `Abs(4)`. This is a basic distance formula, and has nothing to do with being offscreen, but being left/up of the combo.
if ( ( Abs(Hero->X - this->PosX()) < 8 )
&& ( Abs(Hero->Y - this->PosY()) < 8 )
This is specifically for when the player attempts to occupy the middle'ish region of the combo, yes? Though this does beg the question, is this a solid combo? (Like a Lockblock.) Do scripts get activated when the player attempts to push themselves into the combo?
This detects if you are stepping on the combo; not pushing into the side. Pushing would need different logic.
Because I would expect some bit of code that says, to the effect, "If Link is Y-8 pixels below this combo and presses "up" for half a second, do the rest of this code." But I never see any. Why is that? :huh:
Because this code doesn't do that. A lot of code checks if you are on a combo, not next to one.
It's easy enough to figure out the rest of the directions of interaction though. The Y-8 thing would only effect the south direction due to the way the grid system works. Or is X-8 just a tradition of the system. ... or have I completely misunderstood why X-8 and Y-8 (As appropriate) are written.
There's no `-8` here, but `<8`. This means you are within 8 pixels of the combo, so you are mostly standing ON the combo. Distance.
this->PosX()
Remind me again why PosX needs parentheses? ... or blank ones, at least?
Thanks much!
It's a FUNCTION. All function calls need parentheses, because that's how you call a function. This function has empty ones, because it doesn't take any parameters. `Screen->LoadFFC(5)` is a function, which takes one integer parameter.
This much I know: yes.
As an ordinary statement, any expression that "while" evaluates as "true" will cause it to run its block, and any non-zero value will register as "true" (which is apparently just a macro for "1" in C anyway).
`true` isn't a macro for `1` in ZScript, it is in C. However, int/float cast implicitly to bool; meaning that if you do `while(2)`, it converts that 2 to a true/false. By definition, `int == 0` is false, `int != 0` is true.