this post was submitted on 14 Jun 2024
1 points (100.0% liked)

Godot

5388 readers
45 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 1 year ago
MODERATORS
 

For character abilities that have a certain trigger condition, eg. "OnAttack", "OnJump", "OnDamaged" etc..

Currently each of these triggers is a signal. When a signal fires, the character loops through all of its abilities and activates each one with that specific condition, so it just runs an if statement for every ability, regardless of whether it has that condition or not:

if ability.trigger_condition == Triggers.OnAttack:
  ability.activate()

My issue is that this could get a little unscalable with many characters on-screen each having many abilities of their own. A character could have 1 OnDamaged ability and 19 OnAttack abilities, but when an "OnDamaged" signal is received, it will still loop through all 19 OnAttack abilities.

Any advice on this is appreciated, thank you all.

top 1 comments
sorted by: hot top controversial new old
[–] Lmaydev@programming.dev -1 points 1 month ago

When you add a new ability you could register it in a OnAttack or whatever list for that character.

Then you can just loop that list and activate them all.