Replies: 2 comments 6 replies
-
Hello! I just noticed this as I pushed send on a second mail to you. I forgot to answer the most important question you had in your original email, as I answered when I was in a bit of a rush.... As I outlined in that mail, we should probably make a few extensions to accommodate what you want to do, specifically by adding a PlayerEvent that is triggered when an Item and/or a PassiveEffect ends on a player, either by expiring or otherwise. This way, you can do changes that requires cleanup, as a temp solution to things like speed (which cause gameplay bugs if not cleaned up) and a more permanent solution for things like adding a bubble sprite (which only cause a visual bug if not cleaned up) As I also mentioned in said mail, I will follow your recommendation from the first mail, about creating a grouping of effect functions into an effect type that is referenced in items, in stead of referencing function ids. This new effect type will, in addition to grouping effect functions into effects, hold modifiers to player attributes like jump force, move speed, and so on, so that we avoid bugs if effect end event is not triggered or some other circumstance cause cleanup not to be triggered. We could also extend this to hold things like sprites that should be overlaid the subject of the effect and other stuff that will be used commonly.... I said in the mail that we would only expose this to json, as we don't want to have trait implementations from scripts. This was an error on my part, however, as this would not be done with a trait but with a struct type. We will probably still have the functions in there, to some extent, though, as they allow reuse of common effect functions between effects... |
Beta Was this translation helpful? Give feedback.
-
Another question: do you like the {
"name": "Bubble Slowed",
"function_id": "movement_multiplier",
"function_options": {
"x": -0.3,
"y": 0.8
},
...
} The thing I don't like about it is that we have to deserialize the |
Beta Was this translation helpful? Give feedback.
-
Hey @olefasting I'm opening this discussion to talk about how to go about implementing passive effects with more control over the player.
The idea is to implement the following effects: "movement_multiplier", the turtle shell, and a "stuck_in_bubble" effect.
I started messing around with an idea where passive effects are essentially "middleware" for player events.
Passive effects are triggered on player events just like they already were, but now consume any events they are triggered on, and they return a vector of events to be inserted in it's place.
If there are multiple effects on one player, the effects output by one effect will be received by effects after it. This allows each effect, in turn, to modify, and possibly emit it's own events.
Here are the turtle shell and movement multiplier effect implementations:
turtle_shell:
The turtle shell event no longer needs to emit a damage block event, it can just delete any damage events that hit the shell.
movement_multiplier:
To make the movement multiplier effect work, the
update_player_state
system will no longer set the physics body velocity, but will instead emitUpdatePhysicsBody
events. These events can then be intercepted by themovement_multiplier
effect and modified.This also shows that effects can now have options as free-form JSON, which allows us to customize effects options without hard-coding the expected input format.
Does this look like it's going in the right direction?
Beta Was this translation helpful? Give feedback.
All reactions