mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Move MT_SCRIPT_THING code into objects/talk-point.cpp
This commit is contained in:
parent
9491c54e9d
commit
1a916a7d16
4 changed files with 77 additions and 42 deletions
|
|
@ -392,6 +392,9 @@ void Obj_SSCabotronMobjSpawn(mobj_t* mo);
|
||||||
void Obj_SSCabotronMobjThink(mobj_t* mo);
|
void Obj_SSCabotronMobjThink(mobj_t* mo);
|
||||||
void Obj_SSCabotronStarMobjThink(mobj_t* mo);
|
void Obj_SSCabotronStarMobjThink(mobj_t* mo);
|
||||||
|
|
||||||
|
/* Talk Point */
|
||||||
|
void Obj_TalkPointThink(mobj_t* mo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ target_sources(SRB2SDL2 PRIVATE
|
||||||
cloud.c
|
cloud.c
|
||||||
waterfall-particle.c
|
waterfall-particle.c
|
||||||
sealed-star.c
|
sealed-star.c
|
||||||
|
talk-point.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(versus)
|
add_subdirectory(versus)
|
||||||
|
|
|
||||||
71
src/objects/talk-point.cpp
Normal file
71
src/objects/talk-point.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
// DR. ROBOTNIK'S RING RACERS
|
||||||
|
//-------------------------------
|
||||||
|
// Copyright (C) 2024 by Kart Krew
|
||||||
|
//
|
||||||
|
// This program is free software distributed under the
|
||||||
|
// terms of the GNU General Public License, version 2.
|
||||||
|
// See the 'LICENSE' file for more details.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "objects.hpp"
|
||||||
|
|
||||||
|
#include "../doomdef.h"
|
||||||
|
#include "../g_game.h"
|
||||||
|
#include "../p_spec.h"
|
||||||
|
|
||||||
|
using namespace srb2::objects;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
struct TalkPoint : Mobj
|
||||||
|
{
|
||||||
|
void thing_args() = delete;
|
||||||
|
Fixed radius() const { return mobj_t::thing_args[0] * FRACUNIT; }
|
||||||
|
bool oneshot() const { return !mobj_t::thing_args[1]; }
|
||||||
|
bool disabled() const { return mobj_t::thing_args[2]; }
|
||||||
|
|
||||||
|
void think()
|
||||||
|
{
|
||||||
|
if (disabled())
|
||||||
|
{
|
||||||
|
// turned off
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UINT8 i = 0; i < MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if (playeringame[i] == false || players[i].spectator == true)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mobj* player_mobj = static_cast<Mobj*>(players[i].mo);
|
||||||
|
if (!Mobj::valid(player_mobj))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Fixed dist = (pos2d() - player_mobj->pos2d()).magnitude();
|
||||||
|
if (dist < radius())
|
||||||
|
{
|
||||||
|
P_ActivateThingSpecial(this, player_mobj);
|
||||||
|
|
||||||
|
if (oneshot())
|
||||||
|
{
|
||||||
|
remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // namespace
|
||||||
|
|
||||||
|
void Obj_TalkPointThink(mobj_t* mo)
|
||||||
|
{
|
||||||
|
static_cast<TalkPoint*>(mo)->think();
|
||||||
|
}
|
||||||
44
src/p_mobj.c
44
src/p_mobj.c
|
|
@ -6458,48 +6458,8 @@ static void P_MobjSceneryThink(mobj_t *mobj)
|
||||||
Obj_CheckpointThink(mobj);
|
Obj_CheckpointThink(mobj);
|
||||||
break;
|
break;
|
||||||
case MT_SCRIPT_THING:
|
case MT_SCRIPT_THING:
|
||||||
{
|
Obj_TalkPointThink(mobj);
|
||||||
if (mobj->thing_args[2] != 0)
|
return;
|
||||||
{
|
|
||||||
// turned off
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT8 i;
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
|
||||||
{
|
|
||||||
if (playeringame[i] == false || players[i].spectator == true)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
player_t *player = &players[i];
|
|
||||||
if (P_MobjWasRemoved(player->mo) == true)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fixed_t dist = R_PointToDist2(
|
|
||||||
mobj->x, mobj->y,
|
|
||||||
player->mo->x, player->mo->y
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dist < mobj->thing_args[0] * FRACUNIT)
|
|
||||||
{
|
|
||||||
P_ActivateThingSpecial(mobj, player->mo);
|
|
||||||
|
|
||||||
if (mobj->thing_args[1] == 0)
|
|
||||||
{
|
|
||||||
P_RemoveMobj(mobj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MT_SPIKEDTARGET:
|
case MT_SPIKEDTARGET:
|
||||||
{
|
{
|
||||||
if (P_MobjWasRemoved(mobj->target) || (mobj->target->health <= 0) || (mobj->target->z == mobj->target->floorz))
|
if (P_MobjWasRemoved(mobj->target) || (mobj->target->health <= 0) || (mobj->target->z == mobj->target->floorz))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue