Skip to content

Commit

Permalink
fix: fixed secondary weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
Picoseconds committed Aug 1, 2020
1 parent eaa7c85 commit 1f41f1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/moomoo/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ export default class Game {
for (let hitPlayer of hitPlayers) {
if (hitPlayer.clanName == player.clanName && hitPlayer.clanName != null) continue;

let dmg = getWeaponDamage(player.weapon, player.weaponVariant);
let dmg = getWeaponDamage(
player.selectedWeapon,
player.selectedWeapon == player.weapon ?
player.primaryWeaponVariant :
player.secondaryWeaponVariant
);

hitPlayer.health -= dmg;
if (hitPlayer.health <= 0 && hitPlayer.client) {
Expand Down
13 changes: 10 additions & 3 deletions src/moomoo/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export default class Player extends Entity {
public weapon: PrimaryWeapons = 0;
public secondaryWeapon: SecondaryWeapons = -1;
public selectedWeapon: Weapons = 0;
public weaponVariant = WeaponVariant.Normal;
public primaryWeaponVariant = WeaponVariant.Normal;
public secondaryWeaponVariant = WeaponVariant.Normal;
public buildItem = -1;
public items: ItemType[] = [ItemType.Apple, ItemType.WoodWall, ItemType.Spikes, ItemType.Windmill];

Expand Down Expand Up @@ -323,7 +324,11 @@ export default class Player extends Entity {
this.dead = true;
this.kills = 0;
this.weapon = 0;
this.weaponVariant = WeaponVariant.Normal;
this.secondaryWeapon = -1;
this.primaryWeaponVariant = WeaponVariant.Normal;
this.secondaryWeaponVariant = WeaponVariant.Normal;
this.age = 1;
this.xp = 0;
this.buildItem = -1;
this.autoAttackOn = false;
this.disableRotation = false;
Expand Down Expand Up @@ -360,7 +365,9 @@ export default class Player extends Entity {
this.angle,
this.buildItem,
this.selectedWeapon,
this.weaponVariant,
this.selectedWeapon == this.weapon ?
this.primaryWeaponVariant :
this.secondaryWeaponVariant,
this.clanName,
this.isClanLeader ? 1 : 0,
this.hatID,
Expand Down

0 comments on commit 1f41f1b

Please sign in to comment.