Skip to content

Commit

Permalink
support all existing content
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 17, 2024
1 parent 8ca63f8 commit 98e0318
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/app/helpers/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,23 @@ export const defaultNPC: () => INPCDefinition = () => ({
messages: [''],
sfx: {
name: undefined as unknown as string,
radius: 6,
maxChance: 0,
},
},
spawn: {
messages: [''],
sfx: {
name: undefined as unknown as string,
radius: 6,
maxChance: 0,
},
},
combat: {
messages: [],
sfx: {
name: undefined as unknown as string,
radius: 6,
maxChance: 0,
},
},
Expand Down
17 changes: 13 additions & 4 deletions src/app/helpers/schemas/_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { difference, get, isNumber, isString, isUndefined } from 'lodash';
import {
Allegiance,
DamageClass,
HasIdentification,
ItemSlot,
QuestRewardType,
Expand Down Expand Up @@ -127,6 +128,11 @@ export function isStat(val: any): boolean {
return Object.values(Stat).includes(val);
}

export function isDamageType(val: any): boolean {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return Object.values(DamageClass).includes(val);
}

export function isAllegiance(val: any): boolean {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return Object.values(Allegiance).includes(val);
Expand Down Expand Up @@ -159,11 +165,14 @@ export function isRandomTraitObject(val: any): boolean {
}

export function isNPCEffect(val: any): boolean {
return (
val.endsAt === -1 &&
return val.endsAt === -1 &&
isString(val.name) &&
isObjectWithSome(['potency', 'damageType', 'enrageTimer'])(val.extra)
);
isObjectWithSome(['potency', 'damageType', 'enrageTimer'])(val.extra) &&
val.extra
? isNumber(val.extra?.potency) &&
isDamageType(val.extra?.damageType) &&
isNumber(val.extra?.enrageTimer)
: true;
}

export function isQuestReward(val: any): boolean {
Expand Down
8 changes: 7 additions & 1 deletion src/app/helpers/schemas/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const triggerValidators: SchemaProperty[] = ['leash', 'spawn', 'combat']
isObjectWithFailure(['name', 'maxChance']),
],
[`triggers.${triggerType}.sfx.name`, false, isString],
[`triggers.${triggerType}.sfx.radius`, false, isNumber],
[`triggers.${triggerType}.sfx.maxChance`, false, isNumber],
])
.flat() as SchemaProperty[];
Expand Down Expand Up @@ -74,7 +75,12 @@ export const npcSchema: Schema = [
['dropPool', false, isDropPool],
['drops', false, isArrayOf(isRollable)],
['forceAI', false, isString],
['items', false, isObjectWith(['equipment', 'sack', 'belt'])],
[
'items',
false,
isObjectWithSome(['equipment', 'sack', 'belt']),
isObjectWithSomeFailure(['equipment', 'sack', 'belt']),
],
[
'items.equipment',
false,
Expand Down
10 changes: 8 additions & 2 deletions src/app/helpers/schemas/quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Schema } from '../../../interfaces';
import {
isArrayOf,
isItemSlot,
isObjectWith,
isObjectWithSome,
isObjectWithSomeFailure,
isQuestReward,
Expand Down Expand Up @@ -32,7 +31,14 @@ export const questSchema: Schema = [
[
'messages',
false,
isObjectWith([
isObjectWithSome([
'kill',
'complete',
'incomplete',
'alreadyHas',
'permComplete',
]),
isObjectWithSomeFailure([
'kill',
'complete',
'incomplete',
Expand Down
4 changes: 2 additions & 2 deletions src/app/helpers/schemas/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const recipeSchema: Schema = [
[
'ozIngredients',
false,
isArrayOfAtMostLength(2),
() => 'ozIngredients must not have more than 2 elements',
isArrayOfAtMostLength(4),
() => 'ozIngredients must not have more than 4 elements',
],
['potencyScalar', false, isNumber],
['requireClass', false, isArrayOf(isString)],
Expand Down
4 changes: 4 additions & 0 deletions src/app/helpers/schemas/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const spawnerSchema: Schema = [
['shouldSerialize', false, isBoolean],
['alwaysSpawn', false, isBoolean],
['requireHoliday', false, isString],
['requireEvent', false, isString],
['requireDeadToRespawn', false, isBoolean],
['canSlowDown', false, isBoolean],

Expand All @@ -32,6 +33,9 @@ export const spawnerSchema: Schema = [
['eliteTickCap', false, isNumber],
['npcAISettings', false, isArrayOf(isString)],

['maxSpawn', false, isNumber],
['shouldBeActive', false, isBoolean],

['respectKnowledge', false, isBoolean],
['isDangerous', false, isBoolean],
];
3 changes: 3 additions & 0 deletions src/app/helpers/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const defaultSpawner: () => ISpawnerData = () => ({
stripOnSpawner: false,
respectKnowledge: true,
attributeAddChance: 0,
shouldBeActive: false,
requireEvent: '',
maxSpawn: undefined,
requireHoliday: undefined as unknown as string,
_paths: '',
});
12 changes: 12 additions & 0 deletions src/app/tabs/npcs/npcs-editor/npcs-editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@
<input [(ngModel)]="editingData.triggers.spawn.sfx.maxChance" min="0" max="100" type="number"
placeholder="Choose value..." class="form-input" />
</div>

<div class="form-row">
<app-input-floating-label>Spawn SFX Radius</app-input-floating-label>
<input [(ngModel)]="editingData.triggers.spawn.sfx.radius" min="0" max="20" type="number"
placeholder="Choose value..." class="form-input" />
</div>
</div>

<div class="form-column">
Expand All @@ -638,6 +644,12 @@
<input [(ngModel)]="editingData.triggers.leash.sfx.maxChance" min="0" max="100" type="number"
placeholder="Choose value..." class="form-input" />
</div>

<div class="form-row">
<app-input-floating-label>Leash SFX Radius</app-input-floating-label>
<input [(ngModel)]="editingData.triggers.spawn.sfx.radius" min="0" max="20" type="number"
placeholder="Choose value..." class="form-input" />
</div>
</div>

</div>
Expand Down
2 changes: 2 additions & 0 deletions src/app/tabs/npcs/npcs-editor/npcs-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class NpcsEditorComponent
messages: [''],
sfx: {
name: undefined as unknown as string,
radius: 6,
maxChance: 0,
},
};
Expand All @@ -155,6 +156,7 @@ export class NpcsEditorComponent

npc.triggers[triggerType].sfx ??= {
name: undefined as unknown as string,
radius: 6,
maxChance: 0,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export class RecipesEditorComponent
item.ozIngredients ??= [];
item.ozIngredients[0] ??= { filter: '', display: '', ounces: 0 };
item.ozIngredients[1] ??= { filter: '', display: '', ounces: 0 };
item.ozIngredients[2] ??= { filter: '', display: '', ounces: 0 };
item.ozIngredients[3] ??= { filter: '', display: '', ounces: 0 };
}

private assignProps(item: IRecipe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,29 @@
class="form-input" />
</div>
</div>

<div class="form-column">
<div class="form-row">
<app-input-floating-label>Max Monsters Total</app-input-floating-label>
<input [(ngModel)]="editingData.maxSpawn" type="number" min="0" placeholder="Enter total #..."
class="form-input" />
</div>
</div>
</div>

<div class="form-row">
<app-input-holiday [(holiday)]="editingData.requireHoliday"></app-input-holiday>
<div class="form-column">
<div class="form-row">
<app-input-floating-label>Required Event</app-input-floating-label>
<input [(ngModel)]="editingData.requireEvent" type="text" placeholder="Enter in-game event required..."
class="form-input" />
</div>
</div>
<div class="form-column">
<div class="form-row">
<app-input-holiday [(holiday)]="editingData.requireHoliday"></app-input-holiday>
</div>
</div>
</div>

<div class="form-row split">
Expand Down Expand Up @@ -121,6 +140,14 @@
</div>
</div>

<div class="form-row pl-1">
<label class="label cursor-pointer"
floatUi="Whether or not this spawner should always be active. Should only be set for spawners used in specific boss fights in instanced content.">
<input type="checkbox" [(ngModel)]="editingData.shouldBeActive" class="checkbox" />
<span class="label-text">Should Be Active</span>
</label>
</div>

<div class="form-row">
<app-input-floating-label>AI Settings</app-input-floating-label>
<input [(ngModel)]="editingData.npcAISettings[0]" type="text" placeholder="Enter spawner AI name..."
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export interface INPCDefinition extends HasIdentification {
messages: string[];
sfx: {
name: string;
radius: number;
maxChance: number;
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ export interface ISpawnerData extends HasIdentification {
npcAISettings: string[];
respectKnowledge?: boolean;
isDangerous?: boolean;
maxSpawn?: number;
requireEvent?: string;
shouldBeActive?: boolean;
_paths?: string;
}

0 comments on commit 98e0318

Please sign in to comment.