Planeshift
Public Member Functions | Protected Attributes

LootRandomizer Class Reference

This class stores an array of LootModifiers and randomizes loot stats. More...

#include <lootrandomizer.h>

List of all members.

Public Member Functions

void AddLootModifier (LootModifier *entry)
 This adds another item to the entries array.
void ApplyModifier (psItemStats *baseItem, RandomizedOverlay *overlay, csArray< uint32_t > &modifiersIds)
 Applies modifications to a randomized overlay depending on the requested ids.
float CalcModifierCostCap (psCharacter *chr)
 Runs the LootModifierCap mathscript and returns the result, used by other function to determine if a modifier can be added.
LootModifierGetModifier (uint32_t id)
 Gets a loot modifier from it's id.
float GetModifierPercentProbability (int modifierID, int modifierType)
 Returns the percent probability of a modifier based on the total number of modifiers available of that type.
bool GetModifiers (uint32_t itemID, csArray< psGMSpawnMods::ItemModifier > &mods)
 Gets a loot modifier from it's id.
 LootRandomizer (CacheManager *cachemanager)
 Constructor.
psItemRandomizeItem (psItem *item, float cost, bool lootTesting=false, size_t numModifiers=0)
 This randomizes the current loot item and returns the item with the modifiers applied.
psItemSetModifiers (psItem *item, csArray< uint32_t > &mods)
 Validates and sets the loot modifiers with the given ids.
 ~LootRandomizer ()
 Destructor.

Protected Attributes

float adjective_max
csArray< LootModifier * > adjectives
 Keeps all the loot modifiers of type "adjective".
CacheManagercacheManager
 A reference to the cachemanager.
csHash< LootModifier *, uint32_t > LootModifiersById
 Keeps all the lootmodifiers for faster access when we know the id.
MathScriptmodifierCostCalc
 A cached reference to the LootModifierCap math script.
float prefix_max
csArray< LootModifier * > prefixes
 Keeps all the loot modifiers of type "prefix".
float suffix_max
csArray< LootModifier * > suffixes
 Keeps all the loot modifiers of type "suffix".

Detailed Description

This class stores an array of LootModifiers and randomizes loot stats.

Definition at line 69 of file lootrandomizer.h.


Constructor & Destructor Documentation

LootRandomizer::LootRandomizer ( CacheManager cachemanager)

Constructor.

Parameters:
cachemanagerA pointer to the cache manager.
LootRandomizer::~LootRandomizer ( )

Destructor.


Member Function Documentation

void LootRandomizer::AddLootModifier ( LootModifier entry)

This adds another item to the entries array.

void LootRandomizer::ApplyModifier ( psItemStats baseItem,
RandomizedOverlay overlay,
csArray< uint32_t > &  modifiersIds 
)

Applies modifications to a randomized overlay depending on the requested ids.

Parameters:
baseItemThe basic item which will have the overlay generated for.
overlayA pointer to the overlay where we will save the modifications to apply to this item.
modifiersIdsAn array with all the ids of the modifiers which we will need to apply to the overlay.
float LootRandomizer::CalcModifierCostCap ( psCharacter chr)

Runs the LootModifierCap mathscript and returns the result, used by other function to determine if a modifier can be added.

Parameters:
chrThe psCharacter which is being analyzed.
Returns:
A number determining the cost cap for the random modifiers.
LootModifier* LootRandomizer::GetModifier ( uint32_t  id)

Gets a loot modifier from it's id.

Parameters:
idThe id of the item we are searching for.
Returns:
A pointer to the loot modifier which is referenced by the id we were searching for.
float LootRandomizer::GetModifierPercentProbability ( int  modifierID,
int  modifierType 
)

Returns the percent probability of a modifier based on the total number of modifiers available of that type.

Parameters:
modifierIDthe ID of the modifier to evaluate.
modifierType0=prefix, 1=suffix, 2=adjective
Returns:
the float percentage, or 0 if the modifier is invalid or has no probability
bool LootRandomizer::GetModifiers ( uint32_t  itemID,
csArray< psGMSpawnMods::ItemModifier > &  mods 
)

Gets a loot modifier from it's id.

Parameters:
idThe id of the basic item stats we are searching for.
modsThe list of modifiers returned
Returns:
True if the array was filled in.
psItem* LootRandomizer::RandomizeItem ( psItem item,
float  cost,
bool  lootTesting = false,
size_t  numModifiers = 0 
)

This randomizes the current loot item and returns the item with the modifiers applied.

Parameters:
itemThe item instance which we will be randomizing.
costThe maximum "cost" of the randomization we can apply
See also:
CalcModifierCostCap
Parameters:
lootTestingSays if we really are applying the modifiers.
numModifiersForces the amount of modifiers to apply.
Returns:
A pointer to the resulting item (it's the same pointer which was passed to the function).
psItem* LootRandomizer::SetModifiers ( psItem item,
csArray< uint32_t > &  mods 
)

Validates and sets the loot modifiers with the given ids.

Parameters:
itemThe item instance being modified.
modsThe ids of the item modifiers to set.
Returns:
A pointer to the modified item.

Member Data Documentation

Definition at line 79 of file lootrandomizer.h.

Keeps all the loot modifiers of type "adjective".

Definition at line 74 of file lootrandomizer.h.

A reference to the cachemanager.

Definition at line 168 of file lootrandomizer.h.

csHash<LootModifier*, uint32_t> LootRandomizer::LootModifiersById [protected]

Keeps all the lootmodifiers for faster access when we know the id.

Definition at line 75 of file lootrandomizer.h.

A cached reference to the LootModifierCap math script.

Definition at line 167 of file lootrandomizer.h.

Definition at line 78 of file lootrandomizer.h.

Keeps all the loot modifiers of type "prefix".

Definition at line 72 of file lootrandomizer.h.

Definition at line 80 of file lootrandomizer.h.

Keeps all the loot modifiers of type "suffix".

Definition at line 73 of file lootrandomizer.h.


The documentation for this class was generated from the following file: