ProjectSWGCore / Holocore

This is the Star Wars Galaxies server emulator for the Java Virtual Machine
https://www.projectswg.com
GNU Affero General Public License v3.0
30 stars 20 forks source link

Ranged weapon hindrance #639

Open madsboddum opened 2 years ago

madsboddum commented 2 years ago

When equipping a ranged weapon:

  1. The buff "weaponHinderance" should be applied
  2. Your movement speed should be reduced

The opposite should happen when unequipping that ranged weapon.

Ranged weapons now give a "hinderance" for wielding them. This has no effect on fighting capabilities, but it does slow down a person's walking speed. This is a balancing issue so melee professions will be able to keep up with the ranged. Before, ranged professions were able to simply kite melee professions, making melee vrs. ranged PvP futile.

Source: https://www.neoseeker.com/starwarsgalaxies/faqs/108861-star-wars-galaxies-te.html

Pointers

This method specifies additional code to run, when equipping and unequipping weapons: com.projectswg.holocore.resources.support.global.commands.callbacks.TransferItemCallback#changeWeapon

private static void changeWeapon(CreatureObject actor, SWGObject target, boolean equip) {
    if (equip) {
        // The equipped weapon must now be set to the target object
        actor.setEquippedWeapon((WeaponObject) target);
    } else {
        // The equipped weapon must now be set to the default weapon, which happens inside CreatureObject.setEquippedWeapon()
        actor.setEquippedWeapon(null);
    }
    actor.sendSelf(new PlayMusicMessage(0, "sound/pl_all_draw_item.snd", 1, false));
}

This can be used to add the "weaponHinderance" buff to the player: BuffIntent.broadcast("weaponHinderance", actor, actor, false);

Similarly, this will remove the "weaponHinderance" buff from the player: BuffIntent.broadcast("weaponHinderance", actor, actor, true);

To adjust the movement speed of the player, you must add a new entry for weapon hinderance here: com.projectswg.holocore.resources.support.objects.swg.creature.MovementModifierIdentifier

enum class MovementModifierIdentifier(val id: String) {
    BASE("base"),
    SET_SPEED("setSpeed"),
    BURST_RUN("burstRun"),
}

Example of how to apply a movement modifier:

class BurstRunCmdCallback : ICmdCallback {
    override fun execute(player: Player, target: SWGObject?, args: String) {
        val creatureObject = player.creatureObject
        creatureObject.setMovementScale(MovementModifierIdentifier.BURST_RUN, 2f, false) // <-- here
    }
}

Example of figuring out whether a WeaponObject is a ranged weapon.

WeaponObject sourceWeapon = ...
WeaponType sourceWeaponType = sourceWeapon.getType();
if (sourceWeaponType.isRanged()) { // <-- here
    return -16;
}
madsboddum commented 1 month ago

With #1590, the way to apply movement modifiers changes. Therefore, the steps above regarding movement modifiers will no longer be accurate.