Quake 2 is another classic from id software.While not modded quite as much as it's predecessor or Q3A, it is still a blast to play and the mod's on offer are bundles of fun. Just step into Quake 2 Rocket Arena, armed with the new and almighty rocket and rail gun and you will be gibbing for hours on end.If you dig fast paced action, then load up the good ole Quake 2, fire up a mod or two and have some fun!

Post tutorial Report RSS Class/Team-Based addon: Armor Values

Want different armor values in your mod? Tired of the normal values? This is for you.

Posted by on - Basic Client Side Coding

[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.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: