- ActorMoveHitReact + DebugMoveHit

This commit is contained in:
Christoph Oelckers 2021-10-30 00:04:34 +02:00
parent c7f6b7a8c2
commit 077c4f19a7
3 changed files with 12 additions and 15 deletions

View file

@ -75,17 +75,14 @@ Distance(int x1, int y1, int x2, int y2)
} }
void DebugMoveHit(short SpriteNum) void DebugMoveHit(DSWActor* actor)
{ {
SPRITEp sp;
USERp u = User[SpriteNum].Data();
return;
//if (u->ret == -1) //if (u->ret == -1)
// printf("Hit a ledge\n"); // printf("Hit a ledge\n");
//else //else
/* /*
SPRITEp sp;
USERp u = actor->u();
switch (TEST(u->ret, HIT_MASK)) switch (TEST(u->ret, HIT_MASK))
{ {
case HIT_SPRITE: case HIT_SPRITE:
@ -113,10 +110,10 @@ void DebugMoveHit(short SpriteNum)
} }
bool ActorMoveHitReact(short SpriteNum) bool ActorMoveHitReact(DSWActor* actor)
{ {
auto actor = &swActors[SpriteNum]; USERp u = actor->u();
USERp u = User[SpriteNum].Data(); int SpriteNum = actor->GetSpriteIndex();
// Should only return true if there is a reaction to what was hit that // Should only return true if there is a reaction to what was hit that
// would cause the calling function to abort // would cause the calling function to abort
@ -1147,9 +1144,9 @@ DoActorMoveCloser(DSWActor* actor)
// if cannot move the sprite // if cannot move the sprite
if (!move_actor(SpriteNum, nx, ny, 0L)) if (!move_actor(SpriteNum, nx, ny, 0L))
{ {
DebugMoveHit(SpriteNum); DebugMoveHit(actor);
if (ActorMoveHitReact(SpriteNum)) if (ActorMoveHitReact(actor))
return 0; return 0;
DoActorCantMoveCloser(actor); DoActorCantMoveCloser(actor);
@ -2071,7 +2068,7 @@ DoActorReposition(DSWActor* actor)
// still might hit something and have to handle it. // still might hit something and have to handle it.
if (!move_actor(SpriteNum, nx, ny, 0L)) if (!move_actor(SpriteNum, nx, ny, 0L))
{ {
if (ActorMoveHitReact(SpriteNum)) if (ActorMoveHitReact(actor))
return 0; return 0;
u->Vis = 6; u->Vis = 6;

View file

@ -70,8 +70,8 @@ struct ATTRIBUTEstruct
extern ATTRIBUTE DefaultAttrib; extern ATTRIBUTE DefaultAttrib;
// AI.C functions // AI.C functions
void DebugMoveHit(short SpriteNum); void DebugMoveHit(DSWActor* actor);
bool ActorMoveHitReact(short SpriteNum); bool ActorMoveHitReact(DSWActor* actor);
bool ActorFlaming(short SpriteNum); bool ActorFlaming(short SpriteNum);
void DoActorSetSpeed(short SpriteNum,uint8_t speed); void DoActorSetSpeed(short SpriteNum,uint8_t speed);
short ChooseActionNumber(short decision[]); short ChooseActionNumber(short decision[]);

View file

@ -469,7 +469,7 @@ int DoHornetCircle(DSWActor* actor)
if (!move_actor(SpriteNum, nx, ny, 0L)) if (!move_actor(SpriteNum, nx, ny, 0L))
{ {
//ActorMoveHitReact(SpriteNum); //ActorMoveHitReact(actor);
// try moving in the opposite direction // try moving in the opposite direction
u->Counter2 = -u->Counter2; u->Counter2 = -u->Counter2;