diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 9d0b05a2c..0e004e814 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2077,7 +2077,7 @@ extern bool NightVision; /////////////////////////////////////////////////////////////// int PickJumpMaxSpeed(DSWActor*, short max_speed); // ripper.c -int DoRipperRipHeart(short SpriteNum); // ripper.c +int DoRipperRipHeart(DSWActor*); // ripper.c int DoRipper2RipHeart(short SpriteNum); // ripper2.c DSWActor* BunnyHatch2(DSWActor*); // bunny.c diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 7d2a691eb..bdd0ff78e 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -814,22 +814,20 @@ ACTOR_ACTION_SET RipperBrownActionSet = nullptr }; -int -SetupRipper(short SpriteNum) +int SetupRipper(DSWActor* actor) { - auto actor = &swActors[SpriteNum]; - SPRITEp sp = &sprite[SpriteNum]; + SPRITEp sp = &actor->s(); USERp u; ANIMATOR DoActorDecide; if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE)) { - u = User[SpriteNum].Data(); + u = actor->u(); ASSERT(u); } else { - u = SpawnUser(SpriteNum, RIPPER_RUN_R0, s_RipperRun[0]); + u = SpawnUser(actor, RIPPER_RUN_R0, s_RipperRun[0]); u->Health = HEALTH_RIPPER/2; // Baby rippers are weaker } @@ -862,8 +860,7 @@ SetupRipper(short SpriteNum) return 0; } -int -GetJumpHeight(int jump_speed, int jump_grav) +int GetJumpHeight(int jump_speed, int jump_grav) { int jump_iterations; int height; @@ -879,10 +876,9 @@ GetJumpHeight(int jump_speed, int jump_grav) return DIV2(height); } -int -PickJumpSpeed(short SpriteNum, int pix_height) +int PickJumpSpeed(DSWActor* actor, int pix_height) { - USERp u = User[SpriteNum].Data(); + USERp u = actor->u(); //ASSERT(pix_height < 128); @@ -935,12 +931,10 @@ int PickJumpMaxSpeed(DSWActor* actor, short max_speed) // HANGING - Jumping/Falling/Stationary // -int -InitRipperHang(DSWActor* actor) +int InitRipperHang(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; - SPRITEp sp = &sprite[SpriteNum]; + SPRITEp sp = &actor->s(); int dist; hitdata_t hitinfo = { { 0, 0, 0 }, -2, 0, -2 }; @@ -998,11 +992,9 @@ InitRipperHang(DSWActor* actor) return 0; } -int -DoRipperHang(DSWActor* actor) +int DoRipperHang(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; if ((u->WaitTics -= ACTORMOVETICS) > 0) return 0; @@ -1013,12 +1005,10 @@ DoRipperHang(DSWActor* actor) return 0; } -int -DoRipperMoveHang(DSWActor* actor) +int DoRipperMoveHang(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; - SPRITEp sp = &sprite[SpriteNum]; + SPRITEp sp = &actor->s(); int nx, ny; // Move while jumping @@ -1054,11 +1044,9 @@ DoRipperMoveHang(DSWActor* actor) } -int -DoRipperHangJF(DSWActor* actor) +int DoRipperHangJF(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1086,19 +1074,19 @@ DoRipperHangJF(DSWActor* actor) // JUMP ATTACK // -int -DoRipperBeginJumpAttack(DSWActor* actor) +int DoRipperBeginJumpAttack(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; SPRITEp sp = &actor->s(); SPRITEp psp = &u->targetActor->s(); short tang; tang = getangle(psp->x - sp->x, psp->y - sp->y); - if (move_sprite(SpriteNum, bcos(tang, -7), bsin(tang, -7), - 0L, u->ceiling_dist, u->floor_dist, CLIPMASK_ACTOR, ACTORMOVETICS)) + Collision coll(move_sprite(actor->GetSpriteIndex(), bcos(tang, -7), bsin(tang, -7), + 0L, u->ceiling_dist, u->floor_dist, CLIPMASK_ACTOR, ACTORMOVETICS)); + + if (coll.type != kHitNone) sp->ang = NORM_ANGLE((sp->ang + 1024) + (RANDOM_NEG(256, 6) >> 6)); else sp->ang = NORM_ANGLE(tang + (RANDOM_NEG(256, 6) >> 6)); @@ -1115,18 +1103,16 @@ DoRipperBeginJumpAttack(DSWActor* actor) u->jump_grav = 17; // was 8 // if I didn't do this here they get stuck in the air sometimes - DoActorZrange(SpriteNum); + DoActorZrange(actor->GetSpriteIndex()); DoJump(actor); return 0; } -int -DoRipperMoveJump(DSWActor* actor) +int DoRipperMoveJump(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) { @@ -1152,11 +1138,9 @@ DoRipperMoveJump(DSWActor* actor) // STD MOVEMENT // -int -DoRipperQuickJump(DSWActor* actor) +int DoRipperQuickJump(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; // Tests to see if ripper is on top of a player/enemy and then immediatly // does another jump @@ -1177,11 +1161,9 @@ DoRipperQuickJump(DSWActor* actor) } -int -NullRipper(DSWActor* actor) +int NullRipper(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(actor); @@ -1195,7 +1177,6 @@ NullRipper(DSWActor* actor) int DoRipperPain(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; NullRipper(actor); @@ -1207,12 +1188,11 @@ int DoRipperPain(DSWActor* actor) // CTW MODIFICATION //int DoRipperRipHeart(SpriteNum) -int DoRipperRipHeart(short SpriteNum) +int DoRipperRipHeart(DSWActor* actor) // CTW MODIFICATION END { - auto actor = &swActors[SpriteNum]; - SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum].Data(); + SPRITEp sp = &actor->s(); + USERp u = actor->u(); SPRITEp tsp = &u->targetActor->s(); @@ -1229,7 +1209,6 @@ int DoRipperRipHeart(short SpriteNum) int DoRipperStandHeart(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; NullRipper(actor); @@ -1238,26 +1217,24 @@ int DoRipperStandHeart(DSWActor* actor) return 0; } -void RipperHatch(short Weapon) +void RipperHatch(DSWActor* actor) { - SPRITEp wp = &sprite[Weapon]; + SPRITEp wp = &actor->s(); - short New,i; SPRITEp np; USERp nu; -#define MAX_RIPPERS 1 + const int MAX_RIPPERS = 1; short rip_ang[MAX_RIPPERS]; rip_ang[0] = RANDOM_P2(2048); // rip_ang[1] = NORM_ANGLE(rip_ang[0] + 1024 + (RANDOM_P2(512) - 256)); - for (i = 0; i < MAX_RIPPERS; i++) + for (int i = 0; i < MAX_RIPPERS; i++) { - New = COVERinsertsprite(wp->sectnum, STAT_DEFAULT); - auto actorNew = &swActors[New]; - np = &sprite[New]; - memset(np,0,sizeof(SPRITE)); - np->sectnum = wp->sectnum; + auto actorNew = InsertActor(wp->sectnum, STAT_DEFAULT); + np = &actorNew->s(); + np->clear(); + np->sectnum = wp->sectnum; np->statnum = STAT_DEFAULT; np->x = wp->x; np->y = wp->y; @@ -1267,8 +1244,8 @@ void RipperHatch(short Weapon) np->xrepeat = np->yrepeat = 64; np->ang = rip_ang[i]; np->pal = 0; - SetupRipper(New); - nu = User[New].Data(); + SetupRipper(actorNew); + nu = actorNew->u(); // make immediately active SET(nu->Flags, SPR_ACTIVE); @@ -1284,17 +1261,15 @@ void RipperHatch(short Weapon) nu->jump_grav = 8; // if I didn't do this here they get stuck in the air sometimes - DoActorZrange(New); + DoActorZrange(actorNew->GetSpriteIndex()); DoJump(actorNew); } } -int -DoRipperMove(DSWActor* actor) +int DoRipperMove(DSWActor* actor) { USER* u = actor->u(); - int SpriteNum = u->SpriteNum; if (u->scale_speed) { diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index fd8372f6a..ebbc34a27 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -68,7 +68,7 @@ int SetupSailorGirl(DSWActor*); int SetupPruneGirl(DSWActor*); int SetupTrashCan(DSWActor*); int SetupBunny(DSWActor*); -int SetupRipper(short); +int SetupRipper(DSWActor*); int SetupRipper2(short); int SetupSerp(short); int SetupLava(DSWActor* actor); @@ -1427,7 +1427,7 @@ ActorSpawn(SPRITEp sp) } PicAnimOff(sp->picnum); - SetupRipper(SpriteNum); + SetupRipper(actor); break; } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index cd0edc702..642a37474 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -44,7 +44,7 @@ BEGIN_SW_NS void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny); void DoAutoTurretObject(SECTOR_OBJECTp sop); void DoTornadoObject(SECTOR_OBJECTp sop); -int PickJumpSpeed(short SpriteNum, int pix_height); +int PickJumpSpeed(DSWActor*, int pix_height); DSWActor* FindNearSprite(DSWActor, short); ANIMATOR NinjaJumpActionFunc; @@ -3242,7 +3242,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) zdiff = labs(sp->z - sector[wall[hitinfo.wall].nextsector].floorz) >> 8; - u->jump_speed = PickJumpSpeed(SpriteNum, zdiff); + u->jump_speed = PickJumpSpeed(actor, zdiff); } DoActorBeginJump(actor); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 4ffae70d8..c9738b9ed 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -6135,7 +6135,7 @@ DoDamage(short SpriteNum, short Weapon) { PlaySound(DIGI_RIPPERHEARTOUT,u->PlayerP,v3df_dontpan|v3df_doppler); - DoRipperRipHeart(Weapon); + DoRipperRipHeart(weapActor); } } }