2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "tags.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "weapon.h"
|
2020-08-05 22:18:45 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "sprite.h"
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
ANIMATOR DoHornetCircle, InitHornetCircle;
|
|
|
|
|
|
|
|
|
|
|
|
DECISION HornetBattle[] =
|
|
|
|
{
|
|
|
|
{50, InitHornetCircle },
|
|
|
|
{798, InitActorMoveCloser },
|
|
|
|
{800, InitActorAlertNoise },
|
|
|
|
{1024, InitActorRunAway }
|
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetOffense[] =
|
|
|
|
{
|
|
|
|
{1022, InitActorMoveCloser },
|
|
|
|
{1024, InitActorAlertNoise }
|
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetBroadcast[] =
|
|
|
|
{
|
|
|
|
{3, InitActorAlertNoise },
|
|
|
|
{6, InitActorAmbientNoise },
|
|
|
|
{1024, InitActorDecide }
|
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetSurprised[] =
|
|
|
|
{
|
|
|
|
{100, InitHornetCircle },
|
|
|
|
{701, InitActorMoveCloser },
|
|
|
|
{1024, InitActorDecide }
|
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetEvasive[] =
|
|
|
|
{
|
|
|
|
{20, InitHornetCircle },
|
2021-07-10 12:25:18 +00:00
|
|
|
{1024, nullptr },
|
2015-05-19 21:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetLostTarget[] =
|
|
|
|
{
|
|
|
|
{900, InitActorFindPlayer },
|
|
|
|
{1024, InitActorWanderAround }
|
|
|
|
};
|
|
|
|
|
|
|
|
DECISION HornetCloseRange[] =
|
|
|
|
{
|
|
|
|
{900, InitActorMoveCloser },
|
|
|
|
{1024, InitActorReposition }
|
|
|
|
};
|
|
|
|
|
|
|
|
ANIMATOR InitHornetSting;
|
|
|
|
|
|
|
|
DECISION HornetTouchTarget[] =
|
|
|
|
{
|
|
|
|
{500, InitHornetCircle },
|
|
|
|
{1024, InitHornetSting }
|
|
|
|
};
|
|
|
|
|
|
|
|
PERSONALITY HornetPersonality =
|
|
|
|
{
|
|
|
|
HornetBattle,
|
|
|
|
HornetOffense,
|
|
|
|
HornetBroadcast,
|
|
|
|
HornetSurprised,
|
|
|
|
HornetEvasive,
|
|
|
|
HornetLostTarget,
|
|
|
|
HornetCloseRange,
|
|
|
|
HornetTouchTarget
|
|
|
|
};
|
|
|
|
|
|
|
|
ATTRIBUTE HornetAttrib =
|
|
|
|
{
|
|
|
|
{300, 350, 375, 400}, // Speeds
|
|
|
|
{0, 0, 0, 0}, // Tic Adjusts
|
|
|
|
0, //MaxWeapons;
|
|
|
|
{
|
|
|
|
0, 0, DIGI_HORNETSTING, DIGI_HORNETSTING, DIGI_HORNETDEATH,
|
|
|
|
0,0,0,0,0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
//
|
|
|
|
// HORNET RUN
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
#define HORNET_RUN_RATE 7
|
|
|
|
|
|
|
|
ANIMATOR DoHornetMove,NullHornet,DoStayOnFloor, DoActorDebris, NullHornet, DoHornetBirth;
|
|
|
|
|
|
|
|
STATE s_HornetRun[5][2] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R0 + 0, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[0][1]},
|
|
|
|
{HORNET_RUN_R0 + 1, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[0][0]},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R1 + 0, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[1][1]},
|
|
|
|
{HORNET_RUN_R1 + 1, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[1][0]},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R2 + 0, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[2][1]},
|
|
|
|
{HORNET_RUN_R2 + 1, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[2][0]},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R3 + 0, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[3][1]},
|
|
|
|
{HORNET_RUN_R3 + 1, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[3][0]},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R4 + 0, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[4][1]},
|
|
|
|
{HORNET_RUN_R4 + 1, HORNET_RUN_RATE, DoHornetMove, &s_HornetRun[4][0]},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
STATEp sg_HornetRun[] =
|
|
|
|
{
|
|
|
|
&s_HornetRun[0][0],
|
|
|
|
&s_HornetRun[1][0],
|
|
|
|
&s_HornetRun[2][0],
|
|
|
|
&s_HornetRun[3][0],
|
|
|
|
&s_HornetRun[4][0]
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
//
|
|
|
|
// HORNET STAND
|
|
|
|
//
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
#define HORNET_STAND_RATE (HORNET_RUN_RATE + 5)
|
|
|
|
|
|
|
|
STATE s_HornetStand[5][2] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R0 + 0, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[0][1]},
|
|
|
|
{HORNET_RUN_R0 + 1, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[0][0]}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R1 + 0, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[1][1]},
|
|
|
|
{HORNET_RUN_R1 + 1, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[1][0]}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R2 + 0, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[2][1]},
|
|
|
|
{HORNET_RUN_R2 + 1, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[2][0]}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R3 + 0, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[3][1]},
|
|
|
|
{HORNET_RUN_R3 + 1, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[3][0]}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{HORNET_RUN_R4 + 0, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[4][1]},
|
|
|
|
{HORNET_RUN_R4 + 1, HORNET_STAND_RATE, DoHornetMove, &s_HornetStand[4][0]}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
STATEp sg_HornetStand[] =
|
|
|
|
{
|
|
|
|
&s_HornetStand[0][0],
|
|
|
|
&s_HornetStand[1][0],
|
|
|
|
&s_HornetStand[2][0],
|
|
|
|
&s_HornetStand[3][0],
|
|
|
|
&s_HornetStand[4][0]
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
//
|
|
|
|
// HORNET DIE
|
|
|
|
//
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
#define HORNET_DIE_RATE 20
|
|
|
|
ANIMATOR DoHornetDeath;
|
|
|
|
STATE s_HornetDie[] =
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
{HORNET_DIE + 0, HORNET_DIE_RATE, NullHornet, &s_HornetDie[1]},
|
|
|
|
{HORNET_DEAD, HORNET_DIE_RATE, DoActorDebris, &s_HornetDie[1]},
|
|
|
|
#else
|
|
|
|
{HORNET_DIE + 0, HORNET_DIE_RATE, DoHornetDeath, &s_HornetDie[0]},
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
STATEp sg_HornetDie[] =
|
|
|
|
{
|
|
|
|
s_HornetDie
|
|
|
|
};
|
|
|
|
|
|
|
|
STATE s_HornetDead[] =
|
|
|
|
{
|
|
|
|
{HORNET_DEAD, HORNET_DIE_RATE, DoActorDebris, &s_HornetDead[0]},
|
|
|
|
};
|
|
|
|
|
|
|
|
STATEp sg_HornetDead[] =
|
|
|
|
{
|
|
|
|
s_HornetDead
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
STATEp *Stand[MAX_WEAPONS];
|
|
|
|
STATEp *Run;
|
|
|
|
STATEp *Jump;
|
|
|
|
STATEp *Fall;
|
|
|
|
STATEp *Crawl;
|
|
|
|
STATEp *Swim;
|
|
|
|
STATEp *Fly;
|
|
|
|
STATEp *Rise;
|
|
|
|
STATEp *Sit;
|
|
|
|
STATEp *Look;
|
|
|
|
STATEp *Climb;
|
|
|
|
STATEp *Pain;
|
|
|
|
STATEp *Death1;
|
|
|
|
STATEp *Death2;
|
|
|
|
STATEp *Dead;
|
|
|
|
STATEp *DeathJump;
|
|
|
|
STATEp *DeathFall;
|
|
|
|
STATEp *CloseAttack[2];
|
|
|
|
STATEp *Attack[6];
|
|
|
|
STATEp *Special[2];
|
|
|
|
*/
|
|
|
|
|
|
|
|
ACTOR_ACTION_SET HornetActionSet =
|
|
|
|
{
|
|
|
|
sg_HornetStand,
|
|
|
|
sg_HornetRun,
|
2021-07-10 12:25:18 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr, //climb
|
|
|
|
nullptr, //pain
|
2015-05-19 21:54:34 +00:00
|
|
|
sg_HornetDie,
|
2021-07-10 12:25:18 +00:00
|
|
|
nullptr,
|
2015-05-19 21:54:34 +00:00
|
|
|
sg_HornetDead,
|
2021-07-10 12:25:18 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
{nullptr},
|
2015-05-19 21:54:34 +00:00
|
|
|
{0},
|
2021-07-10 12:25:18 +00:00
|
|
|
{nullptr},
|
2015-05-19 21:54:34 +00:00
|
|
|
{0},
|
2021-07-10 12:25:18 +00:00
|
|
|
{nullptr},
|
|
|
|
nullptr,
|
|
|
|
nullptr
|
2015-05-19 21:54:34 +00:00
|
|
|
};
|
|
|
|
|
2021-11-01 07:04:23 +00:00
|
|
|
int DoHornetMatchPlayerZ(DSWActor* actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
2021-11-01 07:04:23 +00:00
|
|
|
int SetupHornet(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp u;
|
|
|
|
ANIMATOR DoActorDecide;
|
|
|
|
|
|
|
|
if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE))
|
|
|
|
{
|
2021-11-01 07:04:23 +00:00
|
|
|
u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
ASSERT(u);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 07:04:23 +00:00
|
|
|
u = SpawnUser(actor,HORNET_RUN_R0,s_HornetRun[0]);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->Health = HEALTH_HORNET;
|
|
|
|
}
|
|
|
|
|
2021-10-30 18:11:31 +00:00
|
|
|
ChangeState(actor, s_HornetRun[0]);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->Attrib = &HornetAttrib;
|
2021-10-30 10:09:34 +00:00
|
|
|
DoActorSetSpeed(actor, NORM_SPEED);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->StateEnd = s_HornetDie;
|
|
|
|
u->Rot = sg_HornetRun;
|
|
|
|
|
2021-10-31 20:17:31 +00:00
|
|
|
EnemyDefaults(actor, &HornetActionSet, &HornetPersonality);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
SET(u->Flags, SPR_NO_SCAREDZ|SPR_XFLIP_TOGGLE);
|
|
|
|
SET(sp->cstat, CSTAT_SPRITE_YCENTER);
|
|
|
|
|
|
|
|
sp->clipdist = (100) >> 2;
|
|
|
|
u->floor_dist = Z(16);
|
|
|
|
u->ceiling_dist = Z(16);
|
|
|
|
|
|
|
|
u->sz = sp->z;
|
|
|
|
|
|
|
|
sp->xrepeat = 37;
|
|
|
|
sp->yrepeat = 32;
|
|
|
|
|
|
|
|
// Special looping buzz sound attached to each hornet spawned
|
2021-11-06 09:09:53 +00:00
|
|
|
PlaySound(DIGI_HORNETBUZZ, actor, v3df_follow|v3df_init);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
int NullHornet(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (TEST(u->Flags,SPR_SLIDING))
|
2021-10-29 18:49:57 +00:00
|
|
|
DoActorSlide(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-01 07:04:23 +00:00
|
|
|
DoHornetMatchPlayerZ(actor);
|
2021-10-29 18:49:57 +00:00
|
|
|
DoActorSectorDamage(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-01 07:04:23 +00:00
|
|
|
enum { HORNET_BOB_AMT = (Z(16)) };
|
|
|
|
|
|
|
|
int DoHornetMatchPlayerZ(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
|
|
|
USERp u = actor->u();
|
2021-10-30 22:53:23 +00:00
|
|
|
SPRITEp tsp = &u->targetActor->s();
|
2019-11-17 17:02:17 +00:00
|
|
|
int zdiff,zdist;
|
|
|
|
int loz,hiz;
|
|
|
|
|
|
|
|
int bound;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// actor does a sine wave about u->sz - this is the z mid point
|
|
|
|
|
|
|
|
//zdiff = (SPRITEp_LOWER(tsp) - Z(8)) - u->sz;
|
|
|
|
zdiff = (SPRITEp_MID(tsp)) - u->sz;
|
|
|
|
|
|
|
|
// check z diff of the player and the sprite
|
2021-09-20 06:59:54 +00:00
|
|
|
zdist = Z(20 + RandomRange(200)); // put a random amount
|
2015-05-19 21:54:34 +00:00
|
|
|
if (labs(zdiff) > zdist)
|
|
|
|
{
|
|
|
|
if (zdiff > 0)
|
|
|
|
// manipulate the z midpoint
|
|
|
|
//u->sz += 256 * ACTORMOVETICS;
|
|
|
|
u->sz += 1024 * ACTORMOVETICS;
|
|
|
|
else
|
|
|
|
u->sz -= 256 * ACTORMOVETICS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// save off lo and hi z
|
|
|
|
loz = u->loz;
|
|
|
|
hiz = u->hiz;
|
|
|
|
|
|
|
|
// adjust loz/hiz for water depth
|
2021-04-18 22:24:25 +00:00
|
|
|
if (u->lo_sectp && SectUser[u->lo_sectp - sector].Data() && FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed))
|
|
|
|
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// lower bound
|
2021-10-30 22:29:54 +00:00
|
|
|
if (u->lowActor)
|
2015-05-19 21:54:34 +00:00
|
|
|
bound = loz - u->floor_dist;
|
|
|
|
else
|
|
|
|
bound = loz - u->floor_dist - HORNET_BOB_AMT;
|
|
|
|
|
|
|
|
if (u->sz > bound)
|
|
|
|
{
|
|
|
|
u->sz = bound;
|
|
|
|
}
|
|
|
|
|
|
|
|
// upper bound
|
2021-10-30 22:39:02 +00:00
|
|
|
if (u->highActor)
|
2015-05-19 21:54:34 +00:00
|
|
|
bound = hiz + u->ceiling_dist;
|
|
|
|
else
|
|
|
|
bound = hiz + u->ceiling_dist + HORNET_BOB_AMT;
|
|
|
|
|
|
|
|
if (u->sz < bound)
|
|
|
|
{
|
|
|
|
u->sz = bound;
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
u->sz = min(u->sz, loz - u->floor_dist);
|
|
|
|
u->sz = max(u->sz, hiz + u->ceiling_dist);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
u->Counter = (u->Counter + (ACTORMOVETICS << 3) + (ACTORMOVETICS << 1)) & 2047;
|
2021-01-04 11:36:54 +00:00
|
|
|
sp->z = u->sz + MulScale(HORNET_BOB_AMT, bsin(u->Counter), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
bound = u->hiz + u->ceiling_dist + HORNET_BOB_AMT;
|
|
|
|
if (sp->z < bound)
|
|
|
|
{
|
|
|
|
// bumped something
|
|
|
|
sp->z = u->sz = bound + HORNET_BOB_AMT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
int InitHornetCircle(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
u->ActorActionFunc = DoHornetCircle;
|
|
|
|
|
2021-10-30 21:12:31 +00:00
|
|
|
NewStateGroup(actor, u->ActorActionSet->Run);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// set it close
|
2021-10-30 10:09:34 +00:00
|
|
|
DoActorSetSpeed(actor, FAST_SPEED);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// set to really fast
|
|
|
|
sp->xvel = 400;
|
|
|
|
// angle adjuster
|
|
|
|
u->Counter2 = sp->xvel/3;
|
|
|
|
// random angle direction
|
|
|
|
if (RANDOM_P2(1024) < 512)
|
|
|
|
u->Counter2 = -u->Counter2;
|
|
|
|
|
|
|
|
// z velocity
|
|
|
|
u->jump_speed = 200 + RANDOM_P2(128);
|
|
|
|
if (labs(u->sz - u->hiz) < labs(u->sz - u->loz))
|
|
|
|
u->jump_speed = -u->jump_speed;
|
|
|
|
|
2021-09-20 06:59:54 +00:00
|
|
|
u->WaitTics = (RandomRange(3)+1) * 60;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
(*u->ActorActionFunc)(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
int DoHornetCircle(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2019-11-17 17:02:17 +00:00
|
|
|
int nx,ny,bound;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->ang = NORM_ANGLE(sp->ang + u->Counter2);
|
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 14);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-30 21:03:26 +00:00
|
|
|
if (!move_actor(actor, nx, ny, 0L))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 22:04:34 +00:00
|
|
|
//ActorMoveHitReact(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// try moving in the opposite direction
|
|
|
|
u->Counter2 = -u->Counter2;
|
|
|
|
sp->ang = NORM_ANGLE(sp->ang + 1024);
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 14);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-30 21:03:26 +00:00
|
|
|
if (!move_actor(actor, nx, ny, 0L))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
InitActorReposition(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// move in the z direction
|
|
|
|
u->sz -= u->jump_speed * ACTORMOVETICS;
|
|
|
|
|
|
|
|
bound = u->hiz + u->ceiling_dist + HORNET_BOB_AMT;
|
|
|
|
if (u->sz < bound)
|
|
|
|
{
|
|
|
|
// bumped something
|
|
|
|
u->sz = bound;
|
2021-10-29 18:49:57 +00:00
|
|
|
InitActorReposition(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// time out
|
|
|
|
if ((u->WaitTics -= ACTORMOVETICS) < 0)
|
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
InitActorReposition(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->WaitTics = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2021-10-29 18:49:57 +00:00
|
|
|
DoHornetDeath(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2019-11-17 17:02:17 +00:00
|
|
|
int nx, ny;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (TEST(u->Flags, SPR_FALLING))
|
|
|
|
{
|
|
|
|
u->loz = u->zclip;
|
2021-10-29 21:41:33 +00:00
|
|
|
DoFall(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_YCENTER);
|
|
|
|
u->jump_speed = 0;
|
|
|
|
u->floor_dist = 0;
|
2021-10-29 21:41:33 +00:00
|
|
|
DoBeginFall(actor);
|
2021-10-30 22:01:08 +00:00
|
|
|
DoFindGroundPoint(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
u->zclip = u->loz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(u->Flags, SPR_SLIDING))
|
2021-10-29 18:49:57 +00:00
|
|
|
DoActorSlide(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// slide while falling
|
2021-01-04 11:36:54 +00:00
|
|
|
nx = MulScale(sp->xvel, bcos(sp->ang), 14);
|
|
|
|
ny = MulScale(sp->xvel, bsin(sp->ang), 14);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-05 20:37:49 +00:00
|
|
|
u->coll = move_sprite(actor, nx, ny, 0L, u->ceiling_dist, u->floor_dist, 1, ACTORMOVETICS);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// on the ground
|
|
|
|
if (sp->z >= u->loz)
|
|
|
|
{
|
|
|
|
RESET(u->Flags, SPR_FALLING|SPR_SLIDING);
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_YFLIP); // If upside down, reset it
|
2021-10-30 21:12:31 +00:00
|
|
|
NewStateGroup(actor, u->ActorActionSet->Dead);
|
2021-10-31 17:10:59 +00:00
|
|
|
DeleteNoSoundOwner(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hornets can swarm around other hornets or whatever is tagged as swarm target
|
2021-10-29 18:49:57 +00:00
|
|
|
int DoCheckSwarm(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s(), tsp;
|
2021-10-08 08:03:14 +00:00
|
|
|
USERp tu;
|
2019-11-17 17:02:17 +00:00
|
|
|
int dist, pdist, a,b,c;
|
2015-05-19 21:54:34 +00:00
|
|
|
PLAYERp pp;
|
|
|
|
|
|
|
|
if (!MoveSkip8) return 0; // Don't over check
|
|
|
|
|
2021-10-30 22:53:23 +00:00
|
|
|
if (!u->targetActor) return 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Who's the closest meat!?
|
2021-10-30 11:05:07 +00:00
|
|
|
DoActorPickClosePlayer(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-30 13:01:38 +00:00
|
|
|
if (u->targetActor->u()->PlayerP)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-30 13:01:38 +00:00
|
|
|
pp = u->targetActor->u()->PlayerP;
|
2015-05-19 21:54:34 +00:00
|
|
|
DISTANCE(sp->x, sp->y, pp->posx, pp->posy, pdist, a, b, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// all enemys
|
2021-11-06 08:29:38 +00:00
|
|
|
SWStatIterator it(STAT_ENEMY);
|
|
|
|
while (auto itActor = it.Next())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-30 11:15:02 +00:00
|
|
|
tsp = &itActor->s();
|
|
|
|
tu = itActor->u();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!tu) continue;
|
|
|
|
|
|
|
|
if (tsp->hitag != TAG_SWARMSPOT || tsp->lotag != 2) continue;
|
|
|
|
|
|
|
|
DISTANCE(sp->x, sp->y, tsp->x, tsp->y, dist, a, b, c);
|
|
|
|
|
|
|
|
if (dist < pdist && u->ID == tu->ID) // Only flock to your own kind
|
|
|
|
{
|
2021-10-30 11:15:02 +00:00
|
|
|
u->targetActor = itActor; // Set target to swarm center
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
int DoHornetMove(DSWActor* actor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2021-10-29 18:49:57 +00:00
|
|
|
USER* u = actor->u();
|
2021-11-01 07:04:23 +00:00
|
|
|
SPRITEp sp = &actor->s();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Check for swarming
|
|
|
|
// lotag of 1 = Swarm around lotags of 2
|
|
|
|
// lotag of 0 is normal
|
|
|
|
if (sp->hitag == TAG_SWARMSPOT && sp->lotag == 1)
|
2021-10-29 18:49:57 +00:00
|
|
|
DoCheckSwarm(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (TEST(u->Flags,SPR_SLIDING))
|
2021-10-29 18:49:57 +00:00
|
|
|
DoActorSlide(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (u->track >= 0)
|
2021-11-01 13:36:46 +00:00
|
|
|
ActorFollowTrack(actor, ACTORMOVETICS);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2021-10-29 18:49:57 +00:00
|
|
|
(*u->ActorActionFunc)(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-11-01 07:04:23 +00:00
|
|
|
DoHornetMatchPlayerZ(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2021-10-29 18:49:57 +00:00
|
|
|
DoActorSectorDamage(actor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "saveable.h"
|
|
|
|
|
|
|
|
static saveable_code saveable_hornet_code[] =
|
|
|
|
{
|
|
|
|
SAVE_CODE(NullHornet),
|
|
|
|
SAVE_CODE(DoHornetMatchPlayerZ),
|
|
|
|
SAVE_CODE(InitHornetCircle),
|
|
|
|
SAVE_CODE(DoHornetCircle),
|
|
|
|
SAVE_CODE(DoHornetDeath),
|
|
|
|
SAVE_CODE(DoCheckSwarm),
|
|
|
|
SAVE_CODE(DoHornetMove),
|
|
|
|
};
|
|
|
|
|
|
|
|
static saveable_data saveable_hornet_data[] =
|
|
|
|
{
|
|
|
|
SAVE_DATA(HornetBattle),
|
|
|
|
SAVE_DATA(HornetOffense),
|
|
|
|
SAVE_DATA(HornetBroadcast),
|
|
|
|
SAVE_DATA(HornetSurprised),
|
|
|
|
SAVE_DATA(HornetEvasive),
|
|
|
|
SAVE_DATA(HornetLostTarget),
|
|
|
|
SAVE_DATA(HornetCloseRange),
|
|
|
|
SAVE_DATA(HornetTouchTarget),
|
|
|
|
|
|
|
|
SAVE_DATA(HornetPersonality),
|
|
|
|
|
|
|
|
SAVE_DATA(HornetAttrib),
|
|
|
|
|
|
|
|
SAVE_DATA(s_HornetRun),
|
|
|
|
SAVE_DATA(sg_HornetRun),
|
|
|
|
SAVE_DATA(s_HornetStand),
|
|
|
|
SAVE_DATA(sg_HornetStand),
|
|
|
|
SAVE_DATA(s_HornetDie),
|
|
|
|
SAVE_DATA(sg_HornetDie),
|
|
|
|
SAVE_DATA(s_HornetDead),
|
|
|
|
SAVE_DATA(sg_HornetDead),
|
|
|
|
|
|
|
|
SAVE_DATA(HornetActionSet),
|
|
|
|
};
|
|
|
|
|
|
|
|
saveable_module saveable_hornet =
|
|
|
|
{
|
|
|
|
// code
|
|
|
|
saveable_hornet_code,
|
|
|
|
SIZ(saveable_hornet_code),
|
|
|
|
|
|
|
|
// data
|
|
|
|
saveable_hornet_data,
|
|
|
|
SIZ(saveable_hornet_data)
|
|
|
|
};
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|