Skip to content

Conversation

RSamaium
Copy link
Owner

@RSamaium RSamaium commented Jun 27, 2025

✨ Description

This PR introduces a real-time, Zelda-style Action RPG combat system for version 5 of the project, implemented as a plugin.

The system is based on assigning behaviors to events, enabling events to act as active enemies.

image

⚙️ Main Features

✅ Vision

Each enemy can detect the hero within a certain radius / field of vision.

Pursuit begins when the hero is spotted.

✅ Movement

Enemy automatically moves toward the hero.

Obstacle/pathfinding handling (if applicable in this version).

✅ Attack

Once in range, the enemy attacks the hero.

Attack deals damage and knocks the hero back.

✅ Damage Display

Lost HP is shown as damage numbers (“hits”) above the hero.

Clear visual feedback for the player.

🧩 Plugin Architecture

New dedicated plugin for version 5, toggleable in settings.

Modular system allowing enemy behaviors to be defined via parameters or event notes.

Compatible with the event system for easy configuration by creators.

📌 Technical Notes

Behavior is assigned to an event via a tag or plugin parameter.

Movements and attacks are real-time (not turn-based).

Knockback strength depends on attack power.

Configurable damage display (color, duration, etc.).

- Introduced the `@rpgjs/action-battle` package with dependencies linked to the workspace.
- Updated `pnpm-lock.yaml` to include new dependencies for action-battle.
- Enhanced player capabilities in `Player.ts` by initializing level to 1 and modifying item handling.
- Added new properties for items in `Item.ts`, including attack and defense attributes.
- Updated `BattleManager.ts` and `MoveManager.ts` to improve battle and movement management functionalities.
- Enhanced `ParameterManager.ts` with comprehensive parameter management features, including experience and level progression.
- Updated sample project to integrate action-battle features, including AI behavior and item management.
- Added detailed JSDoc comments throughout the codebase for better documentation and usage examples.
const distance = this.getDistance(this.event, this.target);

// Check if target is still in vision range
if (distance > this.visionRange * 1.2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why this 20% buffer is needed as in my opinion would only lead to the missunderstanding what is going on. I think that game developer could himself define some buffer if needed.

// Calculate attack hitbox based on player direction
switch (direction) {
case "up":
hitboxes = [{ x: -16, y: -48, width: 32, height: 32 }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to have this configurable

const dirY = dy / distance;

// Create attack hitbox in front of the event
const attackDistance = 30;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const attackDistance = 30;
This could be parameterizable

RSamaium added 2 commits June 28, 2025 09:25
- Translated and updated the Battle AI system documentation to provide clearer guidance in English.
- Added new features including configurable parameters for attack distance and vision range buffer.
- Improved AI behavior with enhanced detection and pursuit mechanisms.
- Updated the BattleAi class to manage health directly through the event object.
- Introduced new examples for AI usage and player combat integration.
- Enhanced the physics system to prevent sensor bodies from passing through walls during knockback.
- Added comprehensive JSDoc comments for better understanding and usage examples throughout the codebase.
- Fixed the indentation of the `this.event.moveTo(player);` line in the `pursue` method of the `BattleAi` class to ensure proper code formatting and readability.
- This change enhances the maintainability of the codebase by adhering to consistent coding standards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants