More style cleanup
FossilOrigin-Name: 753ff34122c906fdba43b8c382ac52cc9f0ac3ce585ec9f4db6b1dc1f21ef86a
This commit is contained in:
parent
dd08a1069e
commit
a28209edcf
27 changed files with 525 additions and 539 deletions
145
src/monster.mm
145
src/monster.mm
|
@ -31,22 +31,22 @@ struct monstertype // see docs for how these values modify behaviour
|
|||
}
|
||||
|
||||
monstertypes[NUMMONSTERTYPES] = {
|
||||
{GUN_FIREBALL, 15, 100, 3, 0, 100, 800, 1, 10, 10, S_PAINO, S_DIE1,
|
||||
@"an ogre", @"monster/ogro"},
|
||||
{GUN_CG, 18, 70, 2, 70, 10, 400, 2, 8, 9, S_PAINR, S_DEATHR, @"a rhino",
|
||||
@"monster/rhino"},
|
||||
{GUN_SG, 14, 120, 1, 100, 300, 400, 4, 14, 14, S_PAINE, S_DEATHE,
|
||||
@"ratamahatta", @"monster/rat"},
|
||||
{GUN_RIFLE, 15, 200, 1, 80, 300, 300, 4, 18, 18, S_PAINS, S_DEATHS,
|
||||
@"a slith", @"monster/slith"},
|
||||
{GUN_RL, 13, 500, 1, 0, 100, 200, 6, 24, 24, S_PAINB, S_DEATHB, @"bauul",
|
||||
@"monster/bauul"},
|
||||
{GUN_BITE, 22, 50, 3, 0, 100, 400, 1, 12, 15, S_PAINP, S_PIGGR2,
|
||||
@"a hellpig", @"monster/hellpig"},
|
||||
{GUN_ICEBALL, 12, 250, 1, 0, 10, 400, 6, 18, 18, S_PAINH, S_DEATHH,
|
||||
@"a knight", @"monster/knight"},
|
||||
{GUN_SLIMEBALL, 15, 100, 1, 0, 200, 400, 2, 13, 10, S_PAIND, S_DEATHD,
|
||||
@"a goblin", @"monster/goblin"},
|
||||
{ GUN_FIREBALL, 15, 100, 3, 0, 100, 800, 1, 10, 10, S_PAINO, S_DIE1,
|
||||
@"an ogre", @"monster/ogro" },
|
||||
{ GUN_CG, 18, 70, 2, 70, 10, 400, 2, 8, 9, S_PAINR, S_DEATHR,
|
||||
@"a rhino", @"monster/rhino" },
|
||||
{ GUN_SG, 14, 120, 1, 100, 300, 400, 4, 14, 14, S_PAINE, S_DEATHE,
|
||||
@"ratamahatta", @"monster/rat" },
|
||||
{ GUN_RIFLE, 15, 200, 1, 80, 300, 300, 4, 18, 18, S_PAINS, S_DEATHS,
|
||||
@"a slith", @"monster/slith" },
|
||||
{ GUN_RL, 13, 500, 1, 0, 100, 200, 6, 24, 24, S_PAINB, S_DEATHB,
|
||||
@"bauul", @"monster/bauul" },
|
||||
{ GUN_BITE, 22, 50, 3, 0, 100, 400, 1, 12, 15, S_PAINP, S_PIGGR2,
|
||||
@"a hellpig", @"monster/hellpig" },
|
||||
{ GUN_ICEBALL, 12, 250, 1, 0, 10, 400, 6, 18, 18, S_PAINH, S_DEATHH,
|
||||
@"a knight", @"monster/knight" },
|
||||
{ GUN_SLIMEBALL, 15, 100, 1, 0, 200, 400, 2, 13, 10, S_PAIND, S_DEATHD,
|
||||
@"a goblin", @"monster/goblin" },
|
||||
};
|
||||
|
||||
dynent *
|
||||
|
@ -90,11 +90,12 @@ void
|
|||
spawnmonster() // spawn a random monster according to freq distribution in DMSP
|
||||
{
|
||||
int n = rnd(TOTMFREQ), type;
|
||||
for (int i = 0;; i++)
|
||||
for (int i = 0;; i++) {
|
||||
if ((n -= monstertypes[i].freq) < 0) {
|
||||
type = i;
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
basicmonster(type, rnd(360), M_SEARCH, 1000, 1);
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ monsterclear() // called after map start of when toggling edit mode to
|
|||
entinmap(m);
|
||||
monstertotal++;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -158,7 +159,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz,
|
|||
x += dx / (float)steps;
|
||||
y += dy / (float)steps;
|
||||
i++;
|
||||
};
|
||||
}
|
||||
return i >= steps;
|
||||
}
|
||||
|
||||
|
@ -203,7 +204,7 @@ monsteraction(
|
|||
if (m->enemy->state == CS_DEAD) {
|
||||
m->enemy = player1;
|
||||
m->anger = 0;
|
||||
};
|
||||
}
|
||||
normalise(m, m->targetyaw);
|
||||
if (m->targetyaw > m->yaw) // slowly turn monster towards his target
|
||||
{
|
||||
|
@ -214,29 +215,25 @@ monsteraction(
|
|||
m->yaw -= curtime * 0.5f;
|
||||
if (m->targetyaw > m->yaw)
|
||||
m->yaw = m->targetyaw;
|
||||
};
|
||||
}
|
||||
|
||||
vdist(disttoenemy, vectoenemy, m->o, m->enemy->o);
|
||||
m->pitch = atan2(m->enemy->o.z - m->o.z, disttoenemy) * 180 / PI;
|
||||
|
||||
if (m->blocked) // special case: if we run into scenery
|
||||
{
|
||||
// special case: if we run into scenery
|
||||
if (m->blocked) {
|
||||
m->blocked = false;
|
||||
if (!rnd(20000 /
|
||||
monstertypes[m->mtype]
|
||||
.speed)) // try to jump over obstackle (rare)
|
||||
{
|
||||
// try to jump over obstackle (rare)
|
||||
if (!rnd(20000 / monstertypes[m->mtype].speed))
|
||||
m->jumpnext = true;
|
||||
} else if (m->trigger < lastmillis &&
|
||||
(m->monsterstate != M_HOME ||
|
||||
!rnd(5))) // search for a way around (common)
|
||||
{
|
||||
m->targetyaw +=
|
||||
180 + rnd(180); // patented "random walk" AI
|
||||
// pathfinding (tm) ;)
|
||||
// search for a way around (common)
|
||||
else if (m->trigger < lastmillis &&
|
||||
(m->monsterstate != M_HOME || !rnd(5))) {
|
||||
// patented "random walk" AI pathfinding (tm) ;)
|
||||
m->targetyaw += 180 + rnd(180);
|
||||
transition(m, M_SEARCH, 1, 400, 1000);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
float enemyyaw =
|
||||
-(float)atan2(m->enemy->o.x - m->o.x, m->enemy->o.y - m->o.y) / PI *
|
||||
|
@ -266,9 +263,9 @@ monsteraction(
|
|||
(disttoenemy < 64 && angle < 45) || angle < 10) {
|
||||
transition(m, M_HOME, 1, 500, 200);
|
||||
playsound(S_GRUNT1 + rnd(2), &m->o);
|
||||
};
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
case M_AIMING: // this state is the delay between wanting to shoot and
|
||||
// actually firing
|
||||
|
@ -277,7 +274,7 @@ monsteraction(
|
|||
m->attacking = true;
|
||||
shoot(m, m->attacktarget);
|
||||
transition(m, M_ATTACKING, 0, 600, 0);
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
case M_HOME: // monster has visual contact, heads straight for player
|
||||
|
@ -305,11 +302,11 @@ monsteraction(
|
|||
{
|
||||
transition(m, M_HOME, 1,
|
||||
monstertypes[m->mtype].rate, 0);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
moveplayer(m, 1, false); // use physics to move monster
|
||||
}
|
||||
|
@ -317,24 +314,25 @@ monsteraction(
|
|||
void
|
||||
monsterpain(dynent *m, int damage, dynent *d)
|
||||
{
|
||||
if (d->monsterstate) // a monster hit us
|
||||
{
|
||||
if (m != d) // guard for RL guys shooting themselves :)
|
||||
{
|
||||
m->anger++; // don't attack straight away, first get
|
||||
// angry
|
||||
// a monster hit us
|
||||
if (d->monsterstate) {
|
||||
// guard for RL guys shooting themselves :)
|
||||
if (m != d) {
|
||||
// don't attack straight away, first get angry
|
||||
m->anger++;
|
||||
int anger =
|
||||
m->mtype == d->mtype ? m->anger / 2 : m->anger;
|
||||
if (anger >= monstertypes[m->mtype].loyalty)
|
||||
m->enemy = d; // monster infight if very angry
|
||||
};
|
||||
} else // player hit us
|
||||
{
|
||||
// monster infight if very angry
|
||||
m->enemy = d;
|
||||
}
|
||||
} else {
|
||||
// player hit us
|
||||
m->anger = 0;
|
||||
m->enemy = d;
|
||||
};
|
||||
transition(m, M_PAIN, 0, monstertypes[m->mtype].pain,
|
||||
200); // in this state monster won't attack
|
||||
}
|
||||
// in this state monster won't attack
|
||||
transition(m, M_PAIN, 0, monstertypes[m->mtype].pain, 200);
|
||||
if ((m->health -= damage) <= 0) {
|
||||
m->state = CS_DEAD;
|
||||
m->lastaction = lastmillis;
|
||||
|
@ -344,9 +342,8 @@ monsterpain(dynent *m, int damage, dynent *d)
|
|||
int remain = monstertotal - numkilled;
|
||||
if (remain > 0 && remain <= 5)
|
||||
conoutf(@"only %d monster(s) remaining", remain);
|
||||
} else {
|
||||
} else
|
||||
playsound(monstertypes[m->mtype].painsound, &m->o);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -368,7 +365,7 @@ monsterthink()
|
|||
conoutf(@"The invasion has begun!");
|
||||
nextmonster = lastmillis + 1000;
|
||||
spawnmonster();
|
||||
};
|
||||
}
|
||||
|
||||
if (monstertotal && !spawnremain && numkilled == monstertotal)
|
||||
endsp(true);
|
||||
|
@ -383,20 +380,22 @@ monsterthink()
|
|||
continue;
|
||||
OFVector3D v =
|
||||
OFMakeVector3D(e.x, e.y, (float)S(e.x, e.y)->floor);
|
||||
loopv(monsters) if (monsters[i]->state == CS_DEAD)
|
||||
loopv(monsters)
|
||||
{
|
||||
if (lastmillis - monsters[i]->lastaction < 2000) {
|
||||
monsters[i]->move = 0;
|
||||
moveplayer(monsters[i], 1, false);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
v.z += monsters[i]->eyeheight;
|
||||
vdist(dist, t, monsters[i]->o, v);
|
||||
v.z -= monsters[i]->eyeheight;
|
||||
if (dist < 4)
|
||||
teleport((int)(&e - &ents[0]), monsters[i]);
|
||||
if (monsters[i]->state == CS_DEAD) {
|
||||
if (lastmillis - monsters[i]->lastaction <
|
||||
2000) {
|
||||
monsters[i]->move = 0;
|
||||
moveplayer(monsters[i], 1, false);
|
||||
}
|
||||
} else {
|
||||
v.z += monsters[i]->eyeheight;
|
||||
vdist(dist, t, monsters[i]->o, v);
|
||||
v.z -= monsters[i]->eyeheight;
|
||||
if (dist < 4)
|
||||
teleport(
|
||||
(int)(&e - &ents[0]), monsters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue