sin-2015/armor.cpp
1999-04-22 00:00:00 +00:00

133 lines
2.2 KiB
C++

// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// DESCRIPTION:
// Standard armor that prevents a percentage of damage per hit.
//
#include "g_local.h"
#include "armor.h"
/*
========
ARMOR
========
*/
CLASS_DECLARATION( Item, Armor, NULL )
ResponseDef Armor::Responses[] =
{
{ NULL, NULL }
};
Armor::Armor
(
)
{
if ( DM_FLAG( DF_NO_ARMOR ) )
{
PostEvent( EV_Remove, 0 );
return;
}
Set( 0 );
}
void Armor::Setup
(
const char *model,
int amount
)
{
assert( model );
setModel( model );
Set( amount );
}
void Armor::Add
(
int num
)
{
// Armor never adds, it only replaces
amount = num;
if ( amount >= MaxAmount() )
amount = MaxAmount();
}
qboolean Armor::Pickupable
(
Entity *other
)
{
if ( !other->isSubclassOf( Sentient ) )
{
return false;
}
else
{
Sentient * sent;
Item * item;
sent = ( Sentient * )other;
// Mutants don't get armor
if ( sent->flags & ( FL_MUTANT | FL_SP_MUTANT ) )
{
return false;
}
item = sent->FindItem( getClassname() );
// If our armor is > than our current armor or armor has no value, then leave it alone.
if ( item )
if ( ( item->Amount() >= this->Amount() ) || !this->Amount() )
{
return false;
}
}
return true;
}
CLASS_DECLARATION( Armor, RiotHelmet, "armor_riothelmet" );
ResponseDef RiotHelmet::Responses[] =
{
{ NULL, NULL }
};
RiotHelmet::RiotHelmet()
{
Setup( "riothelm.def", MAX_ARMOR );
}
CLASS_DECLARATION( Armor, FlakJacket, "armor_flakjacket" );
ResponseDef FlakJacket::Responses[] =
{
{ NULL, NULL }
};
FlakJacket::FlakJacket()
{
Setup( "flakjack.def", MAX_ARMOR );
}
CLASS_DECLARATION( Armor, FlakPants, "armor_flakpants" );
ResponseDef FlakPants::Responses[] =
{
{ NULL, NULL }
};
FlakPants::FlakPants()
{
Setup( "flakpants.def", MAX_ARMOR );
}