The Dink Network

stalkers and invisible walls

September 29th 2012, 11:30 AM
old.gif
swampbag
Peasant She/Her Sweden
Git offa ma property! 
Alright, I think I've spent enough time trying to find the proper scripting, and yielding no results
First: How do I get a character to follow dink on and through screens?
And what do I write for: somethings happens when dink reaches x/y-value on screen?
September 29th 2012, 12:11 PM
wizardg.gif
Paul
Peasant He/Him United States
 
Dink (i.e. sprite 1) is the only one that actually persists across screens, so the only way to create the effect of a following sprite is to keep a sprite 1000 script running that recreates the "following" sprite whenever Dink enters a new screen. The standard way to do that is to check for &player_map changing, but recently I was experimenting with another method where you actually create two sprites, the second being an invisible one with a sentinel value in sp_brain, meaning something weird like 23, 666, 1337, or whatever number appeals to you. Then you repeatedly use get_sprite_with_this_brain to check if the sprite still exists, and if not, assume you have to recreate the follower as well.

For the second one, can't you just use an invisible (sp_nodraw) sprite with a touch function?
September 29th 2012, 12:17 PM
old.gif
swampbag
Peasant She/Her Sweden
Git offa ma property! 
Woah, not sure I got all of that. I'm very much a noob at dmoding. And I know I can use invisible objects, it's just that the line of objects is gonna be reeeaaally long then.
September 29th 2012, 01:14 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Nah, just use bigger objects Don't use a row of mushrooms to trigger your invisible script

If you're still a beginner, I think it will be too difficult to script an NPC following Dink around. However, if you're determined, the best way to learn these things is to explore how it was done in other d-mods. There's a bunch of them out there that have this kind of script, but the only one I can think of right off the bat is Prophecy of the Ancients.
September 29th 2012, 02:14 PM
wizardg.gif
I haven't actually tried to give dink a follower, but now I'm interested in attempting to do so.

While on-screen though, I can tell you that all the sprite needs is an sp_follow command. You would also need to set a speed, a base walk, and make sure it's not hard.

Good luck!

For invisible walls; I make an object, set it to invisible, make it hard, and that's that. I assume you want the walls to eventually go away, if not it might be easier to use hardness tiles for some of it.
September 29th 2012, 02:24 PM
spike.gif
Another method would be to use a loop. E.g.

VARÄRDINK:
int &crappyx = sp_x(1,-1)

if (&crappyx < 200)
{
//stuff you want to run here
}

wait(100)
goto varärdink


Keep in mind that's not a pixel-accurate method, since there's a short wait between each time it checks the coordinate.

If you added a script_attach(1000) there, the loop would survive screenchanges, and could be used for followers, to create the follower each time you change screens. I find using loops inherently deplorable, though, especially permanent ones, so I'd avoid it unless you absolutely need to.

Another method to create a follower would be to have a sprite/script on EVERY screen of the dmod (every one you want the follower on anyway), which then checks if the follower dude should be there. Adding a sprite on every screen is annoying, but less deplorable. The script could look like this:

void main
{
if (&ISHOULDHAVEFOLLOWER == 0)
sp_active(&current_sprite,0)

//otherwise, add follower's stats and stuff here, for example:
sp_follow(&current_sprite,1)
set_smooth_follow(1)
sp_brain(&current_sprite,16)
sp_speed(&current_sprite,1)

//wait(1)
//^ might need this so that the follower doesn't appear on the wrong side of the screen, not sure

//move follower to Dink
int &dinkx = sp_x(1,-1)
int &dinky = sp_y(1,-1)
sp_x(&current_sprite,&dinkx)
sp_y(&current_sprite,&dinky)
}

September 29th 2012, 08:03 PM
old.gif
swampbag
Peasant She/Her Sweden
Git offa ma property! 
Actually, the invisible wall goes on for...well lots of screens, but I'll try out the hints I got before falling back on invisible tables. This is good stuff, tho - I'll tell you guys what works.
A following character, though, is only needed for the introductory bit, but it is necessary. Can't tell you any more, you'll see when I'm done with it!
September 30th 2012, 04:22 AM
anon.gif
shevek
Ghost They/Them
 
before falling back on invisible tables

Invisible sprites is actually the cleanest solution IMO. However, if you have many screens, you may want to create a sprite for the purpose (in dink.ini), with a very large hardness box.

If the wall is never going to go away, you should forget about sprites and simply use tile hardness for it.