Spawn Objects
Suppose you want the player to shoot a fireball by pressing Enter. Traditionally, this could be done by placing a fireball event on every map and then moving it to the player's location. The advantage of this method is that it doesn't require an Action Combat plugin. However, the drawbacks are significant:- You would need to replicate the same fireball event across ALL maps, which is tedious.
- If you want to allow shooting multiple fireballs, you'd have to create additional fireball events and again, copy them to ALL maps, making management cumbersome.
Let's create the shooting fireball using Action Combat plugin command Spawn Event.
The Benefits:
- You only need to create the fireball event once, eliminating the need for further modifications.
- No more repetitive copying and pasting across maps, simplifying maintenance.
- You can spawn as many fireballs as needed without additional setup, making the system highly scalable for dynamic gameplay.
Firstly let's create an event called Fireball and put it on a map. You need to assign this map to Action Combat plugin parameter. This map will store all template events for spawning.
Then:
- Create a common event that runs in parallel to continuously check if the Enter button is pressed.
- When the Enter button is triggered, we'll execute a plugin command called Spawn Event.
- Since the fireball event is named "Fireball", we'll specify this name in the command.
- For the X and Y coordinates, we'll use player to spawn the fireball directly at the player's current position.
- We'll set the permanent event option to false because it's fine if the fireball disappears when the player moves to another map and comes back.
Now when you test your project, pressing enter will spawn Fireball event from the template map.
Dynamic Events
Dynamic Events are similar to spawning events from a template map, but with a key difference: they don't require the creation of a template event. Instead, these events are generated spontaneously, "out of thin air." However, they come with limitations, serving only specific, restricted purposes.
Example: When your character swings a sword, it will spawn a hitbox event tagged with notetag <swordAttack> and this event will delete itself after x frames to match with the attacking animation. Any enemy events that collide with this notetag will take damage.
You could achieve this by creating an event with the <swordAttack> tag in a template map and then spawning it when your character swings the sword, but this method involves two steps:
- Creating the event in the template map.
- Spawning it.
The one above will create an event with notetag <dmg: 5 - 10> and <swordAttack> at the current event position. It'll destroy itself after 3 frames.