The 1.3 Buffs and Debuffs Update
🚨Important🚨
⏩The Documentation is being Updated!
In the following weeks I will update the official AP Documentation with all new changes from version 1.1 onwards! Multiple Guides and Tutorials will also be included.
❇️New Features❇️
⏩New Projectile Modifier Class
A new class designed to act as temporary projectile buffs and debuffs. Just set the enter and exit callables to easily modify your projectiles.
@onready var projectile_manager: ProjectileManager2D = $ProjectileManager2D
func _process(_delta: float) -> void:
if (Input.is_key_pressed(KEY_N)):
projectile_manager.add_projectile_modifier(0, Projectile2DModifier.new("BUFF", 1, on_modifier_enter, on_modifier_exit))
func on_modifier_enter(_modifier: Projectile2DModifier, proj: Projectile2D) -> void:
proj.instances += 1
func on_modifier_exit(_modifier: Projectile2DModifier, proj: Projectile2D) -> void:
proj.instances -= 1
The previously added Global Database now also supports both Projectile modifiers and…
@onready var projectile_manager: ProjectileManager2D = $ProjectileManager2D
func _ready() -> void:
APDatabase.set_modifier(Projectile2DModifier.new("BUFF", 1, on_modifier_enter, on_modifier_exit)
func _process(_delta: float) -> void:
if (Input.is_key_pressed(KEY_N)):
projectile_manager.add_projectile_modifier(0, APDatabase.get_projectile_2d_modifier("BUFF"))
func on_modifier_enter(_modifier: Projectile2DModifier, proj: Projectile2D) -> void:
proj.instances += 1
func on_modifier_exit(_modifier: Projectile2DModifier, proj: Projectile2D) -> void:
proj.instances -= 1
⏩News Attack Modifier Class
The Attack2DModifier acts as a quick and easy way to temporarily modify the behavior and properties of your Attacks.
@onready var projectile_manager: ProjectileManager2D = $ProjectileManager2D
func _process(_delta: float) -> void:
if (Input.is_key_pressed(KEY_N)):
projectile_manager.add_attack_modifier(0, Attack2DModifier.new("ATTACK_BUFF", 1, on_modifier_enter, on_modifier_exit))
func on_modifier_enter(_modifier: Attack2DModifier, attack: Attack2D) -> void:
attack.attack_duration_time -= 0.1
func on_modifier_exit(_modifier: Attack2DModifier, attack: Attack2D) -> void:
attack.attack_duration_time += 0.1
Attack2DModifier and its analogous Projectile2DModifer also feature a staking system with which you can add multiple copies of a single modifier in the same target; and a custom on_validation Callable that lets you configure when a modifier is added and when it is not.
# ...
func _process(_delta: float) -> void:
if (Input.is_key_pressed(KEY_N)):
projectile_manager.add_projectile_modifier(0, Projectile2DModifier.new("BUFF", 1, on_modifier_enter, on_modifier_exit, Callable(), stackable_projectile_validation))
# ...
func stackable_projectile_validation(_modifier: Projectile2DModifier, _proj: Projectile2D) -> bool:
if !(_proj.projectile_modifiers.has(_modifier.name)):
return true
if (_modifier.stacks < 5):
return true
return false
In addition both modifiers let you define them as permanent if you set their duration to -1
# ...
func _process(_delta: float) -> void:
if (Input.is_key_pressed(KEY_N)):
projectile_manager.add_projectile_modifier(0, Projectile2DModifier.new("BUFF", -1, on_modifier_enter, on_modifier_exit)
# ...
See more info in the sections below.
❇️More❇️
⏩ProjectileCaller2D Changes
Added add_projectile_modifier(index: int, modifier: Projectile2DModifier) method. ## Returns true if the modifier argument was successfully added to the projectiles property element at the given index.
Added remove_projectile_modifier(index: int, id: StringName) method. ## Returns true if the modifier with the name “id” was successfully removed from the projectiles property element at the given index.
Added remove_modifier_stacks_from_projectile(index: int, id: StringName, stacks: int = -1) method. ## Returns true if successfully removed the given number of stacks of the modifier with the name “id” from the projectiles property element at the given index. Removes all stacks if stacks is less than zero.
⏩ProjectileManager2D Changes
Added add_attack_modifier(index: int, modifier: Attack2DModifier) method. ## Returns true if the modifier argument was successfully added to the attacks property element at the given index.
Added remove_attack_modifier(index: int, id: StringName) method. ## Returns true if the modifier with the name “id” was successfully removed from the attacks property element at the given index.
Added remove_modifier_stacks_from_attack(index: int, id: StringName, stacks: int = -1) method. ## Returns true if successfully removed the given number of stacks of the modifier with the name “id” from the attacks property element at the given index. Removes all stacks if stacks is less than zero.
⏩APDatabase Changes
Added get_modifier(id: StringName, return_copy: bool = true) method. ## Returns a copy of the consulted Modifier by the given id. If “return_copy” is false, it will instead return the reference to the Modifier stored in the Database.
Added set_modifier(modifier: TimedModifier, id: StringName = modifier.name) method. ## Sets the value of the Modifier at the given id, to the given modifier parameter.
Added get_projectile_2d_modifier(id: StringName, return_copy: bool = true) method. ## Returns a copy of the consulted Projectile2DModifier by the given id. If “return_copy” is false, it will instead return the reference to the Projectile2DModifier stored in the Database.
Added get_attack_2d_modifier(id: StringName, return_copy: bool = true) method. ## Returns a copy of the consulted Attack2DModifier by the given id. If “return_copy” is false, it will instead return the reference to the Attack2DModifier stored in the Database.
⏩Projectile2D Changes
Added projectile_modifiers: Dictionary[StringName, Projectile2DModifier] property. ## Dictionary of all modifiers affecting this projectile.
Added instance_projectile_modifiers: bool property. ## If true, the projectile_modifiers dictionary property will be independent in all instances of this projectile instead of being shared among all of them.
Added add_modifier(modifier: Projectile2DModifier) method. ## Validates the given modifier argument and adds it to the projectile_modifiers property if valid.
Added remove_modifier(modifier_name: StringName) method. ## Removes the modifier with the given modifier_name at the projectiles_modifiers property if present.
⏩Attack2D Changes
Added attack_modifiers: Dictionary[StringName, Attack2DModifier] property. ## Dictionary of all modifiers affecting this attack.
Added instance_attack_modifiers: bool property. ## If true, the attack_modifiers dictionary property will be independent in all instances of this attack instead of being shared among all of them.
Added add_modifier(modifier: Attack2DModifier) method. ## Validates the given modifier argument and adds it to the attack_modifiers property if valid.
Added remove_modifier(modifier_name: StringName) method. ## Removes the modifier with the given modifier_name at the attack_modifiers property if present.
❇️Projectile2DModifier and Attack2DModifier quick use Guide ❇️
⏩Let’s create a Projectile2DModifier:
➡️From your ProjectileCaller2D or ProjectileManager2D either call add_projectile_modifier(index: int, modifier: Projectile2DModifier) or add_attack_modifier(index: int, modifier: Attack2DModifier) method
➡️These functions take two parameters: “index” is the projectile or attack element your modifier is going to affect and “modifier” is the modifier itself.
➡️Creating a Modifier takes the next parameters: _init(_name: StringName = StringName(), _duration: float = 1.0, _on_enter: Callable = Callable(), _on_exit: Callable = Callable(), _on_update: Callable = Callable(), _on_validation: Callable = Callable())
- _name: Is the modifier Global Identifier.
- _duration: Is the time of the modifier effect on its target (in seconds). Set it to (-1) to make it permanent.
- _on_enter: Is the modifier application callback.
- _on_exit: Is the modifier expiration callback.
- _on_update: Is a callback that will be called every frame.
- _on_validation: Is the callback that will defined if the modifier gets added or not.
➡️Your request should look like this:
projectile_manager.add_projectile_modifier(0, Projectile2DModifier.new("BUFF", 1, on_modifier_enter, on_modifier_exit))
⏩Modifier Properties:
copies: Array[TimedModifier] ## Stacking instances of this modifier.
duration: float ## Original modifier duration in seconds.
global_properties: Dictionary[StringName, Variant] ## This dictionary is shared between all modifiers that share this name. If you change its values, you will change them in all modifiers.
individual_properties: Dictionary[StringName, Variant] ## This dictionary is independent in all modifiers that share this name. Modifying it will only affect this instance.
is_active: bool ## Variable state for modifier update validation.
is_permanent: bool ## If true, the modifier never expires.
lifetime: float ## Remaining lifetime in seconds.
name: StringName ## Unique identifier.
on_enter: Callable ## Modifier custom application callback.
on_exit: Callable ## Modifier custom expiration callback.
on_update: Callable ## Modifier custom update callback.
on_validation: Callable ## Modifier custom validation callback.
stacks: int ## Current stack count of this modifier.
target: RefCounted ## Object being affected by this modifier.
- projectile: Projectile2D ## Property present in Projectile2DModifiers ONLY. Projectile being affected by this modifier.
- attack: Attack2D ## Property present in Attack2DModifiers ONLY. Attack being affected by this modifier.
use_custom_update_method: bool ## Does the modifier use a custom update method.
⏩Modifier Methods:
func add_global_property(property: StringName, value: Variant) ## Adds the given value to the global_properties dictionary with the property key.
func add_individual_property(property: StringName, value: Variant) ## Adds the given value to the individual_properties dictionary with the property key.
func disable() ## Disables and cleans up the modifier.
func enter() ## Applies modifier to target.
func exit() ## Removes modifier from target.
func set_property(property: StringName, value: Variant) ## Assigns the given value to the given property if valid.
func update(_delta: float) ## Called every game frame (override in subclasses)
func validate_modifier(target: TargetType) ## Default modifier validation call (Can be overwritten with a custom on_validation Callable). Returns true if its target doesn’t currently have a modifier with its name.
Files
Get All Projectiles
All Projectiles
A Projectile Engine for Godot 4.4
More posts
- The 1.2 Global Database Update15 days ago
- A Massive 1.1 Update23 days ago
Leave a comment
Log in with itch.io to leave a comment.