Class PetSlotRules
How many pets a character may keep out, and which one a new summon replaces. Pure.
public static class PetSlotRules
- Inheritance
-
PetSlotRules
- Inherited Members
Remarks
Two limits apply. A character has the pet slots its Pet Slots character attribute gives it (PetSlots: one unless an archetype, an item or a buff raises it), and each summon spell carries its own maximum (MaxPets): a spell that may raise three wolves still raises one for a character with one slot.
A summon past either limit replaces the oldest pet in its way rather than failing: past the spell's limit, the oldest pet of that spell; past the slots, the oldest pet of any kind. That is what a summon did when a character could only have one pet.
A pet keeps the slot it was given for as long as it is out, and the database stores each pet under its slot. A slot is not a list position: when the first of two pets dies the second stays in slot 1.
Fields
AttributeName
The character attribute that holds a character's pet slots. Its asset starts at DefaultSlots, so an archetype, an item or a buff grants slots the way it moves any other attribute.
public const string AttributeName = "Pet Slots"
Field Value
DefaultAttributeID
The template ID of the AttributeName asset, which a pet controller uses unless its prefab names another.
public static readonly int DefaultAttributeID
Field Value
DefaultSlots
Pet slots a character has unless an archetype grants more.
public const int DefaultSlots = 1
Field Value
MaxSlots
The most slots anything may grant. Bounds what the server accepts and the database stores.
public const int MaxSlots = 8
Field Value
Methods
AnyPastSlots(IReadOnlyList<int>, int)
True when a pet holds a slot at or past slots: the slots fell under it and it must go.
public static bool AnyPastSlots(IReadOnlyList<int> usedSlots, int slots)
Parameters
usedSlotsIReadOnlyList<int>The slot of each pet out.
slotsintThe character's pet slots now.
Returns
ClampSlots(int)
The character's slot count, clamped to 1..MaxSlots.
public static int ClampSlots(int slots)
Parameters
slotsint
Returns
IndexToReplace(IReadOnlyList<int>, int, int, int)
Which pet a new summon must replace, or -1 when it fits.
public static int IndexToReplace(IReadOnlyList<int> petTemplateIDs, int templateID, int spellMax, int slots)
Parameters
petTemplateIDsIReadOnlyList<int>The template of each pet out, oldest first.
templateIDintThe template being summoned.
spellMaxintThe summon spell's own maximum.
slotsintThe character's pet slots.
Returns
- int
The index into
petTemplateIDsof the pet to dismiss, or -1.
LowestFreeSlot(IReadOnlyList<int>, int)
The lowest slot no pet holds, or -1 when all slots are taken.
public static int LowestFreeSlot(IReadOnlyList<int> usedSlots, int slots)
Parameters
usedSlotsIReadOnlyList<int>The slot of each pet out.
slotsintThe character's pet slots.
Returns
SlotsFrom(bool, int)
A character's pet slots from its Pet Slots attribute: the attribute's final value, clamped, or DefaultSlots when the character has no such attribute.
public static int SlotsFrom(bool hasAttribute, int finalValue)
Parameters
Returns
SpellCap(int, int)
The most pets of one spell a character can have out: the smaller of the spell's own maximum and the character's slots, never less than one.
public static int SpellCap(int spellMax, int slots)