Skip to content

Commit 51f6121

Browse files
authored
Merge pull request #1791 from madsboddum/fix/items/weapon-hinderance
Fixed two bugs with weapon hinderance, where it was being applied at …
2 parents 5c85e07 + 74ef289 commit 51f6121

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/main/java/com/projectswg/holocore/resources/support/global/commands/callbacks/TransferItemCallback.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class TransferItemCallback : ICmdCallback {
225225

226226
when (target.moveToContainer(actor, newContainer)) {
227227
ContainerResult.SUCCESS -> if (weapon) {
228-
changeWeapon(actor, target, equip)
228+
changeWeapon(actor, target as WeaponObject, equip)
229229
}
230230

231231
ContainerResult.CONTAINER_FULL -> {
@@ -391,17 +391,25 @@ class TransferItemCallback : ICmdCallback {
391391
return tangibleTarget.template.contains("/instrument/")
392392
}
393393

394-
private fun changeWeapon(actor: CreatureObject, target: SWGObject, equip: Boolean) {
394+
private fun changeWeapon(actor: CreatureObject, target: WeaponObject, equip: Boolean) {
395395
val weaponHinderanceBuffName = "weaponHinderance" // CU permasnare buff. It doesn't reduce speed, but it prevents speed buffs from making the player run faster.
396396

397397
if (equip) {
398398
// The equipped weapon must now be set to the target object
399-
actor.equippedWeapon = target as WeaponObject
400-
BuffIntent(weaponHinderanceBuffName, actor, actor, false).broadcast()
399+
actor.equippedWeapon = target
400+
401+
if (target.type.isRanged) {
402+
BuffIntent(weaponHinderanceBuffName, actor, actor, false).broadcast()
403+
} else {
404+
BuffIntent(weaponHinderanceBuffName, actor, actor, true).broadcast()
405+
}
401406
} else {
402407
// The equipped weapon must now be set to the default weapon, which happens inside CreatureObject.setEquippedWeapon()
403408
actor.equippedWeapon = null
404-
BuffIntent(weaponHinderanceBuffName, actor, actor, true).broadcast()
409+
410+
if (actor.hasBuff(weaponHinderanceBuffName)) {
411+
BuffIntent(weaponHinderanceBuffName, actor, actor, true).broadcast()
412+
}
405413
}
406414
}
407415
}

0 commit comments

Comments
 (0)