new module stuff mystery chest

This commit is contained in:
2024-03-15 20:38:18 -04:00
parent efb3b611ff
commit 5d77d78729
4 changed files with 68 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -129,4 +129,5 @@ interface Stat {
value: number,
updated: number,
loaded: boolean
}
}

View File

@@ -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 = <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);

View File

@@ -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));