Example #1
0
void LootRandomizer::SetAttributeApplyOP(float* value[], float modifier, size_t amount,  const csString &op)
{
    // Operations  = ADD, MUL, SET
    for(size_t i = 0; i < amount; i++)
    {
        if(op.CompareNoCase("ADD"))
        {
            if(value[i]) *value[i] += modifier;
        }

        else if(op.CompareNoCase("MUL"))
        {
            if(value[i]) *value[i] *= modifier;
        }

        else if(op.CompareNoCase("VAL"))
        {
            if(value[i]) *value[i] = modifier;
        }
    }
}
Example #2
0
csArray<NPC*> Tribe::SelectNPCs(const csString &type, const char* number)
{
    int           count = atoi(number);
    csArray<NPC*> npcs;

    bool selectAny = type.CompareNoCase("any");

    // Loop all members. Check for type and if they are idle.
    for(size_t i=0; i<members.GetSize(); i++)
    {
        NPC* member = members[i];

        if((member->GetTribeMemberType() != type) && !selectAny)
        {
            // Just skip any members of wrong type.
            continue;
        }

        Behavior* currentBehavior = member->GetCurrentBehavior();
        if(!currentBehavior)
        {
            // Newly created NPC or some malfunction.
            // Just skip and try this npc next loop.
            continue;
        }

        if(strcasecmp(currentBehavior->GetName(),npcIdleBehavior.GetDataSafe())==0)
        {
            count--;
            npcs.Push(member);
        }

        // Check if we found the number requested
        if(count == 0)
            return npcs;

    }

    // Return what we found
    return npcs;
}