mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 06:42:08 +00:00
Made the damage of polyobjects customizable..
The damage done by polyobjects can now be changed by altering the health value of the start spots. A health of 1 (Default) is the default damage of 3, anything above 1 is instant death, and negative health values are the exact damage the polyobject does with every collision with an actor.
This commit is contained in:
parent
9ff1193dab
commit
f2451ff44b
2 changed files with 22 additions and 6 deletions
|
@ -152,7 +152,7 @@ private:
|
||||||
// Polyobjects
|
// Polyobjects
|
||||||
void InitSideLists();
|
void InitSideLists();
|
||||||
void IterFindPolySides(FPolyObj *po, side_t *side);
|
void IterFindPolySides(FPolyObj *po, side_t *side);
|
||||||
void SpawnPolyobj(int index, int tag, int type);
|
void SpawnPolyobj(int index, int tag, int type, int damage);
|
||||||
void TranslateToStartSpot(int tag, const DVector2 &origin);
|
void TranslateToStartSpot(int tag, const DVector2 &origin);
|
||||||
void InitPolyBlockMap(void);
|
void InitPolyBlockMap(void);
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,22 @@ static int posicmp(const void *a, const void *b)
|
||||||
return (*(const side_t **)a)->linedef->args[1] - (*(const side_t **)b)->linedef->args[1];
|
return (*(const side_t **)a)->linedef->args[1] - (*(const side_t **)b)->linedef->args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapLoader::SpawnPolyobj (int index, int tag, int type)
|
int SetPolyobjDamage(int type, int damage)
|
||||||
|
{
|
||||||
|
int dam;
|
||||||
|
if (type != SMT_PolySpawn)
|
||||||
|
{
|
||||||
|
if (damage == 1)
|
||||||
|
dam = 3;
|
||||||
|
else if (damage > 1)
|
||||||
|
dam = TELEFRAG_DAMAGE;
|
||||||
|
else if (damage < 0)
|
||||||
|
dam = abs(damage);
|
||||||
|
}
|
||||||
|
return (type != SMT_PolySpawn) ? dam : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapLoader::SpawnPolyobj (int index, int tag, int type, int damage)
|
||||||
{
|
{
|
||||||
unsigned int ii;
|
unsigned int ii;
|
||||||
int i;
|
int i;
|
||||||
|
@ -181,8 +196,9 @@ void MapLoader::SpawnPolyobj (int index, int tag, int type)
|
||||||
sd->linedef->args[0] = 0;
|
sd->linedef->args[0] = 0;
|
||||||
IterFindPolySides(&Level->Polyobjects[index], sd);
|
IterFindPolySides(&Level->Polyobjects[index], sd);
|
||||||
po->MirrorNum = sd->linedef->args[1];
|
po->MirrorNum = sd->linedef->args[1];
|
||||||
po->crush = (type != SMT_PolySpawn) ? 3 : 0;
|
po->crush = SetPolyobjDamage(type,damage);
|
||||||
po->bHurtOnTouch = (type == SMT_PolySpawnHurt);
|
po->bHurtOnTouch = (type == SMT_PolySpawnHurt);
|
||||||
|
|
||||||
po->tag = tag;
|
po->tag = tag;
|
||||||
po->seqType = sd->linedef->args[2];
|
po->seqType = sd->linedef->args[2];
|
||||||
if (po->seqType < 0 || po->seqType > (MAX_SNDSEQS - 1))
|
if (po->seqType < 0 || po->seqType > (MAX_SNDSEQS - 1))
|
||||||
|
@ -222,7 +238,7 @@ void MapLoader::SpawnPolyobj (int index, int tag, int type)
|
||||||
qsort(&po->Sidedefs[0], po->Sidedefs.Size(), sizeof(po->Sidedefs[0]), posicmp);
|
qsort(&po->Sidedefs[0], po->Sidedefs.Size(), sizeof(po->Sidedefs[0]), posicmp);
|
||||||
if (po->Sidedefs.Size() > 0)
|
if (po->Sidedefs.Size() > 0)
|
||||||
{
|
{
|
||||||
po->crush = (type != SMT_PolySpawn) ? 3 : 0;
|
po->crush = SetPolyobjDamage(type,damage);
|
||||||
po->bHurtOnTouch = (type == SMT_PolySpawnHurt);
|
po->bHurtOnTouch = (type == SMT_PolySpawnHurt);
|
||||||
po->tag = tag;
|
po->tag = tag;
|
||||||
po->seqType = po->Sidedefs[0]->linedef->args[3];
|
po->seqType = po->Sidedefs[0]->linedef->args[3];
|
||||||
|
@ -359,13 +375,13 @@ void MapLoader::PO_Init (void)
|
||||||
// Find the startSpot points, and spawn each polyobj
|
// Find the startSpot points, and spawn each polyobj
|
||||||
for (int i=polythings.Size()-1; i >= 0; i--)
|
for (int i=polythings.Size()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
// 9301 (3001) = no crush, 9302 (3002) = crushing, 9303 = hurting touch
|
// 9301 (3001) = no crush, 9302 (3002) = crushing, 9303 = hurting touch, Health = crusher/hurter damage
|
||||||
int type = polythings[i]->info->Special;
|
int type = polythings[i]->info->Special;
|
||||||
if (type >= SMT_PolySpawn && type <= SMT_PolySpawnHurt)
|
if (type >= SMT_PolySpawn && type <= SMT_PolySpawnHurt)
|
||||||
{
|
{
|
||||||
// Polyobj StartSpot Pt.
|
// Polyobj StartSpot Pt.
|
||||||
Level->Polyobjects[polyIndex].StartSpot.pos = polythings[i]->pos.XY();
|
Level->Polyobjects[polyIndex].StartSpot.pos = polythings[i]->pos.XY();
|
||||||
SpawnPolyobj(polyIndex, polythings[i]->angle, type);
|
SpawnPolyobj(polyIndex, polythings[i]->angle, type, polythings[i]->Health);
|
||||||
polyIndex++;
|
polyIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue