Enemies that cling and slow the hero down.

Started by Hibiro, May 03, 2018, 12:15:28 AM

Previous topic - Next topic
Alright, here's the next tricky thing I need to figure out, if it's possible.

I need an enemy like the Gels from the Oracle games that don't hurt the hero, but cling to him and slow his movements, as well as prevent the use of items while stuck to him. It's only meant for a short amount of time, of course.

I'm not sure if there's anything on this already, or if it's in one of the main projects. (More in the mood to create, rather than play.) So any help would be appreciated.

I think there's an event called enemy:on_attacking_hero(). You could call some code here that sets the hero's speed to something lower, then removes the attack ability of the hero. Then you could set a timer that after 5 seconds sets the hero's speed back and gives the track ability back.

There's probably a better way to do this. I also have no idea what would happen if the player saved or reset the game or died in this state, you'd need some way to reset the hero's abilities since in these cases, the timer that would give the hero's abilities back would get destroyed.

In CoS you have examples of scripts that allow different sprites of 1 enemy inflict different damages, even no damage. I am still working on it to allow jumping combat where collisions depend on if the hero and enemy are on the ground or not.

Be careful with timers reseting hero stats. If the hero is teleported before the timer has finished, or if the player saves the game with the savegame value modified... problems on board!!! IDK which would be the cleanest way to do it, but there is probably no clean way. I suggest to initialize the correct walking speed when you start a game, to prevent this problem, and attach the timer somewhere that is not destroyed when the map changes.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

You could also use a metaevent for on_map_changed, or on world changed, that resets the hero's stats (walking speed and abilities) to savegames variables, besides doing this whenever the game is loaded up. This could be figured out and perhaps exploited by the player, but would help safeguard against potential bugs.

I've given this a little thought because I was thinking about potential temporary-stat-boosting potions, but it does open up a lot of bugs. I can't think of a way to have like something like "this boosts your attack for 15 minutes" carry over if the game is paused and restarted, all effects would need to be reset upon quitting the game. And perhaps upon dying, too, I'm not sure if timers with the context "game" are destroyed or not when you die and are reset. Probably depends on how death is handled by your game.

Tip: you could try to use menus or even items (they have many useful events) to manage the timers (with context on the game) and other stuff you need.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."