[page=Introduction]
Hello!
Now, if you've played Q2, you've noticed how the values are the same.
Jacket Armor - 50
Combat Armor - 100
Body Armor - 200
With this addon to my class-based mod starter, you can change the max armor!
Let's get started!
[page=Code]
Go to your client_persistant_t struct, and at the end, add this:
// Paril - New armor integer.
int player_armor;
Go to your Pickup_Armor function, find this block:
// calc new armor values
salvage = newinfo->normal_protection / oldinfo->normal_protection;
salvagecount = salvage * newinfo->base_count;
newcount = other->client->pers.inventory[old_armor_index] + salvagecount;
if (newcount > oldinfo->max_count)
newcount = oldinfo->max_count;
// if we're already maxed out then we don't need the new armor
if (other->client->pers.inventory[old_armor_index] >= newcount)
return false;
// update current armor value
other->client->pers.inventory[old_armor_index] = newcount;
}
}
if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
SetRespawn (ent, 20);
Below that, and before the:
return true;
}
add this new block:
// Paril - New armor will excede normal values to pers.player_armor
if ((other->client->pers.inventory[jacket_armor_index]) + (other->client->pers.inventory[combat_armor_index]) + (other->client->pers.inventory[body_armor_index]) > (other->client->pers.player_armor))
other->client->pers.inventory[old_armor_index] = other->client->pers.player_armor;
Now, in your InitClientPersistant, in each class block, add like:
client->pers.player_armor = 100;//Max Armor for Class1
As you can see, you just need to add in the player_armor variable and set it to a value, in someplace around where you gave each class it's weapons and ammo. That's it! Now your classes can have different armor values, so you can give your "heavy weapons" class a very high armor count while your light "scout" classes can have low armor values.