Godot Version
4.5
Question
I am creating a 2D, top-down action game with gameplay similar to the Devil May Cry series. In this sense, the player has 5 weapons, of which they are freely able to switch between at any time. All the weapons have unique attacks, but can be controlled using the same control scheme. For example, holding the movement directions away from the cursor and attacking results in a unique move that differs depending on the weapon that is being used- if the sword is equipped, then the player will launch an attack in a direction that knocks an enemy airborne, and if daggers are equipped, then the player will dash through the enemy closest to the cursor before unleashing a series of stabs. In a similar vein, if the player holds down the attack button, then a unique charge attack will be carried out, with the sword carrying out a spin attack, while the daggers would release an onslaught of slabs right in front of the player.
With these varying properties and actions, the structure approach I tried was to give the player node a weapons manager node. The player code manages the player’s behaviors and controls, such as moving, jumping, and dashing. The weapons manager holds each of the 5 weapons, which each has the correlating attacks, hitboxes, and attack behaviors. Depending on the inputs the player receives when attacking, the specific move will change (such as hold, or holding back and attacking). The weapon selected is managed in the player code, and will let the weapons manager know which hitboxes, animations, and attacks to use.
This seemed to be a good code structure, but once the player’s behaviors and actions during the unique attacks began getting integrated, I began to realize that a very large portion of the attacks will require the player to carry out unique actions- for example, floating in the air before slamming into the ground and knocking the surrounding enemies around, or rapidly dashing between any airborne enemies within a certain radius. Should all of these player behaviors be managed in the weapons’ code? Or should these functions be kept in the player code? What would be the best practice for managing these behaviors that affect the player, as well as the enemies? Should the weapons have functions to modify the enemy/player’s states, movements, and behaviors, or should those remain in the respective entity’s code? What would be the best structure for this sort of design? I’m not sure if this is enough information, or if it’s helpful enough of a description, but that’s the gist of the current design of the system. Would love any advice or thoughts for best practices!