diff --git a/modules/classes/server-utils.ts b/modules/classes/server-utils.ts new file mode 100644 index 0000000..b278b7f --- /dev/null +++ b/modules/classes/server-utils.ts @@ -0,0 +1,4 @@ +// A function that will take a min and a max and return a random number between them +export function rollDice(min: number, max: number): number { + return Math.floor(Math.random() * (max - min + 1) + min); +} \ No newline at end of file diff --git a/modules/classes/stats.ts b/modules/classes/stats.ts index 297ef45..377ae00 100644 --- a/modules/classes/stats.ts +++ b/modules/classes/stats.ts @@ -129,4 +129,5 @@ interface Stat { value: number, updated: number, loaded: boolean -} \ No newline at end of file +} + diff --git a/modules/gameobject/gamblechest.ts b/modules/gameobject/gamblechest.ts index a8f7c2c..11d7e44 100644 --- a/modules/gameobject/gamblechest.ts +++ b/modules/gameobject/gamblechest.ts @@ -71,9 +71,9 @@ const onKillCreature: player_event_on_kill_creature = (event: number, killer: Pl if(!map.IsDungeon() && !map.IsRaid()) { return false; } - if(!map.IsHeroic()) { - return false; - } + // if(!map.IsHeroic()) { + // return false; + // } if(killed.GetLevel() < (killer.GetLevel() - 5)) { return false; @@ -82,8 +82,7 @@ const onKillCreature: player_event_on_kill_creature = (event: number, killer: Pl const [x,y,z,o] = killed.GetLocation(); let roll = Math.floor(Math.random() * 100); - - if(roll > 4) { + if(roll > 8) { return; } @@ -104,7 +103,7 @@ const onLootStateChange: gameobject_event_on_loot_state_change = (event: number, if(LootTrapMap[gameObject.GetGUIDLow()] == true) { const creature1: Creature = PerformIngameSpawn(1, BombCreature, gameObject.GetMapId(), gameObject.GetInstanceId(), gameObject.GetX(), gameObject.GetY(), gameObject.GetZ(),gameObject.GetO(), false, 100); - const player = gameObject.GetNearestPlayer(15); + const player = gameObject.GetNearestPlayer(50); const sound = TrapSounds[Math.floor(Math.random() * TrapSounds.length)]; const players = gameObject.GetPlayersInRange(50); diff --git a/modules/gameplay/reputation-tabard.ts b/modules/gameplay/reputation-tabard.ts new file mode 100644 index 0000000..18aaba8 --- /dev/null +++ b/modules/gameplay/reputation-tabard.ts @@ -0,0 +1,57 @@ +import { rollDice } from '../classes/server-utils'; + +const startRoll: number = 10; +const endRoll: number = 35; + +const CREATURE_TYPE_CRITTER: number = 8; + +const tabardFactions = { + 23999: 946, + 24004: 947, + 31773: 941, + 31774: 978, + 31775: 970, + 31776: 933, + 31777: 989, + 31778: 1011, + 31779: 932, + 31780: 934, + 31781: 935, + 31804: 942, + 32445: 1031, + 32828: 1038, + 35221: 1077, + 43154: 1106, + 43155: 1098, + 43156: 1091, + 43157: 1090, + 46817: 1094, + 46818: 1124 +}; + +function killGetRep(event: number, killer: Player, killed: Creature): void { + + // determine the players currently equipped tabard + const tabard = killer.GetEquippedItemBySlot(EquipmentSlots.EQUIPMENT_SLOT_TABARD); + if (!tabard) { + return; + } + + // determine the reputation gain for the tabard + const factionId = tabardFactions[tabard.GetEntry()]; + + if(!factionId) { + return; + } + + if(killed.GetLevel() < (killer.GetLevel() - 3)) { + return; + } + + const currentRep = killer.GetReputation(factionId); + killer.SetReputation(factionId, currentRep + rollDice(startRoll, endRoll)); + +} + +RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_KILL_CREATURE, (...args) => killGetRep(...args)); +