// Caskey, Damon V.
// 2011-02-25
// Universal doattack event function.
// target: Caller entity.
void z_datk(void target)
{
int attack_id = 0; // ID of collision event.
int hit_id = 0; // ID of most recent collision event on an entity.
int which = 0; // Which type of event (giving/taking) fired this script.
void other = NULL(); // Opposing entity.
int parry; = 0; // Parry success.
attack_id = getlocalvar("attackid");
hit_id = getentityproperty(vEnt, "hitbyid");
other = getlocalvar("other");
// Default to self as target.
if(!target)
{
target = getlocalvar("self");
}
// Hit ID and attack ID must be different. See below.
if(hit_id != attack_id)
{
// Was this event triggered by incoming attack?
which = getlocalvar("which");
if(which == openborconstant("EXCHANGE_RECIPIANT"))
{
// Parry logic.
parry = dc_parry(target, other);
// If the attack was parried, skip all engine hit behaviors here.
if(parry)
{
changeopenborvariant("lasthitc", 0);
}
}
}
// If the ID of a collision matches the collision ID
// assigned to an entity, the engine knows this collision
// has already been handled and ignores it on subsequent
// cycles. Since we skipped the hit code, we'll have to
// make sure that assignment happens here.
changeentityproperty(target, "hitbyid", attack_id);
}