Gave each BehaviorScript an ID

Created functions to trivially translate an ID to a Behavior and vice
versa. Sent ID over packets instead of Behavior pointer. This should
allow Linux and Windows to play together.
This commit is contained in:
MysterD 2020-08-09 16:21:12 -07:00
parent a896713510
commit 9036336f42
11 changed files with 7808 additions and 34 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
behaviors = []
with open('behavior_data.c', 'r') as f:
lines = f.readlines()
with open('../../data/behavior_data.c', 'w+') as f:
line_number = -1
current_behavior = None
for line in lines:
f.write(line)
if current_behavior is not None:
f.write(' ID(id_' + current_behavior + '),\n')
current_behavior = None
line_number += 1
if not line.startswith('const BehaviorScript'):
continue
if 'BEGIN(' not in lines[line_number + 1]:
continue
behavior_name = line.split('const BehaviorScript ')[1].split('[]')[0]
current_behavior = behavior_name
behaviors.append(behavior_name)
with open('../../include/behavior_table.h', 'w+') as f:
f.write('#ifndef BEHAVIOR_TABLE_H\n')
f.write('#define BEHAVIOR_TABLE_H\n\n')
f.write('extern BehaviorScript* gBehaviorTable;\n\n')
f.write('enum BehaviorId {\n')
for behavior in behaviors:
f.write(' id_' + behavior + ',\n')
f.write(' id_bhv_max_count // must be the last in the list\n')
f.write('};\n')
f.write('#endif\n')
with open('../../data/behavior_table.c', 'w+') as f:
f.write('#include "behavior_table.h"\n\n')
f.write('BehaviorScript* gBehaviorTable[id_bhv_max_count] = {\n')
for behavior in behaviors:
f.write(' [id_' + behavior + '] = &' + behavior + ',\n')
f.write('};\n')
print(str(behaviors))

File diff suppressed because it is too large Load diff

527
data/behavior_table.c Normal file
View file

@ -0,0 +1,527 @@
#include <assert.h>
#include "behavior_table.h"
const BehaviorScript* gBehaviorTable[id_bhv_max_count] = {
[id_bhvStarDoor] = bhvStarDoor,
[id_bhvMrI] = bhvMrI,
[id_bhvMrIBody] = bhvMrIBody,
[id_bhvMrIParticle] = bhvMrIParticle,
[id_bhvPurpleParticle] = bhvPurpleParticle,
[id_bhvGiantPole] = bhvGiantPole,
[id_bhvPoleGrabbing] = bhvPoleGrabbing,
[id_bhvThiHugeIslandTop] = bhvThiHugeIslandTop,
[id_bhvThiTinyIslandTop] = bhvThiTinyIslandTop,
[id_bhvCapSwitchBase] = bhvCapSwitchBase,
[id_bhvCapSwitch] = bhvCapSwitch,
[id_bhvKingBobomb] = bhvKingBobomb,
[id_bhvBobombAnchorMario] = bhvBobombAnchorMario,
[id_bhvBetaChestBottom] = bhvBetaChestBottom,
[id_bhvBetaChestLid] = bhvBetaChestLid,
[id_bhvBubbleParticleSpawner] = bhvBubbleParticleSpawner,
[id_bhvBubbleMaybe] = bhvBubbleMaybe,
[id_bhvSmallWaterWave] = bhvSmallWaterWave,
[id_bhvWaterAirBubble] = bhvWaterAirBubble,
[id_bhvSmallParticle] = bhvSmallParticle,
[id_bhvPlungeBubble] = bhvPlungeBubble,
[id_bhvSmallParticleSnow] = bhvSmallParticleSnow,
[id_bhvSmallParticleBubbles] = bhvSmallParticleBubbles,
[id_bhvFishGroup] = bhvFishGroup,
[id_bhvCannon] = bhvCannon,
[id_bhvCannonBarrel] = bhvCannonBarrel,
[id_bhvCannonBaseUnused] = bhvCannonBaseUnused,
[id_bhvChuckya] = bhvChuckya,
[id_bhvChuckyaAnchorMario] = bhvChuckyaAnchorMario,
[id_bhvUnused05A8] = bhvUnused05A8,
[id_bhvRotatingPlatform] = bhvRotatingPlatform,
[id_bhvTower] = bhvTower,
[id_bhvBulletBillCannon] = bhvBulletBillCannon,
[id_bhvWfBreakableWallRight] = bhvWfBreakableWallRight,
[id_bhvWfBreakableWallLeft] = bhvWfBreakableWallLeft,
[id_bhvKickableBoard] = bhvKickableBoard,
[id_bhvTowerDoor] = bhvTowerDoor,
[id_bhvRotatingCounterClockwise] = bhvRotatingCounterClockwise,
[id_bhvWfRotatingWoodenPlatform] = bhvWfRotatingWoodenPlatform,
[id_bhvKoopaShellUnderwater] = bhvKoopaShellUnderwater,
[id_bhvExitPodiumWarp] = bhvExitPodiumWarp,
[id_bhvFadingWarp] = bhvFadingWarp,
[id_bhvWarp] = bhvWarp,
[id_bhvWarpPipe] = bhvWarpPipe,
[id_bhvWhitePuffExplosion] = bhvWhitePuffExplosion,
[id_bhvSpawnedStar] = bhvSpawnedStar,
[id_bhvSpawnedStarNoLevelExit] = bhvSpawnedStarNoLevelExit,
[id_bhvMrIBlueCoin] = bhvMrIBlueCoin,
[id_bhvCoinInsideBoo] = bhvCoinInsideBoo,
[id_bhvCoinFormationSpawn] = bhvCoinFormationSpawn,
[id_bhvCoinFormation] = bhvCoinFormation,
[id_bhvOneCoin] = bhvOneCoin,
[id_bhvYellowCoin] = bhvYellowCoin,
[id_bhvTemporaryYellowCoin] = bhvTemporaryYellowCoin,
[id_bhvThreeCoinsSpawn] = bhvThreeCoinsSpawn,
[id_bhvTenCoinsSpawn] = bhvTenCoinsSpawn,
[id_bhvSingleCoinGetsSpawned] = bhvSingleCoinGetsSpawned,
[id_bhvCoinSparkles] = bhvCoinSparkles,
[id_bhvGoldenCoinSparkles] = bhvGoldenCoinSparkles,
[id_bhvWallTinyStarParticle] = bhvWallTinyStarParticle,
[id_bhvVertStarParticleSpawner] = bhvVertStarParticleSpawner,
[id_bhvPoundTinyStarParticle] = bhvPoundTinyStarParticle,
[id_bhvHorStarParticleSpawner] = bhvHorStarParticleSpawner,
[id_bhvPunchTinyTriangle] = bhvPunchTinyTriangle,
[id_bhvTriangleParticleSpawner] = bhvTriangleParticleSpawner,
[id_bhvDoorWarp] = bhvDoorWarp,
[id_bhvDoor] = bhvDoor,
[id_bhvGrindel] = bhvGrindel,
[id_bhvThwomp2] = bhvThwomp2,
[id_bhvThwomp] = bhvThwomp,
[id_bhvTumblingBridgePlatform] = bhvTumblingBridgePlatform,
[id_bhvWfTumblingBridge] = bhvWfTumblingBridge,
[id_bhvBbhTumblingBridge] = bhvBbhTumblingBridge,
[id_bhvLllTumblingBridge] = bhvLllTumblingBridge,
[id_bhvFlame] = bhvFlame,
[id_bhvAnotherElavator] = bhvAnotherElavator,
[id_bhvRrElevatorPlatform] = bhvRrElevatorPlatform,
[id_bhvHmcElevatorPlatform] = bhvHmcElevatorPlatform,
[id_bhvWaterMist] = bhvWaterMist,
[id_bhvBreathParticleSpawner] = bhvBreathParticleSpawner,
[id_bhvBreakBoxTriangle] = bhvBreakBoxTriangle,
[id_bhvWaterMist2] = bhvWaterMist2,
[id_bhvUnused0DFC] = bhvUnused0DFC,
[id_bhvMistCircParticleSpawner] = bhvMistCircParticleSpawner,
[id_bhvDirtParticleSpawner] = bhvDirtParticleSpawner,
[id_bhvSnowParticleSpawner] = bhvSnowParticleSpawner,
[id_bhvWind] = bhvWind,
[id_bhvEndToad] = bhvEndToad,
[id_bhvEndPeach] = bhvEndPeach,
[id_bhvUnusedParticleSpawn] = bhvUnusedParticleSpawn,
[id_bhvUkiki] = bhvUkiki,
[id_bhvUkikiCageChild] = bhvUkikiCageChild,
[id_bhvUkikiCageStar] = bhvUkikiCageStar,
[id_bhvUkikiCage] = bhvUkikiCage,
[id_bhvBitfsSinkingPlatforms] = bhvBitfsSinkingPlatforms,
[id_bhvBitfsSinkingCagePlatform] = bhvBitfsSinkingCagePlatform,
[id_bhvDddMovingPole] = bhvDddMovingPole,
[id_bhvBitfsTiltingInvertedPyramid] = bhvBitfsTiltingInvertedPyramid,
[id_bhvSquishablePlatform] = bhvSquishablePlatform,
[id_bhvCutOutObject] = bhvCutOutObject,
[id_bhvBetaMovingFlames] = bhvBetaMovingFlames,
[id_bhvRrRotatingBridgePlatform] = bhvRrRotatingBridgePlatform,
[id_bhvFlamethrower] = bhvFlamethrower,
[id_bhvFlamethrowerFlame] = bhvFlamethrowerFlame,
[id_bhvBouncingFireball] = bhvBouncingFireball,
[id_bhvBouncingFireballFlame] = bhvBouncingFireballFlame,
[id_bhvBowserShockWave] = bhvBowserShockWave,
[id_bhvFireParticleSpawner] = bhvFireParticleSpawner,
[id_bhvBlackSmokeMario] = bhvBlackSmokeMario,
[id_bhvBlackSmokeBowser] = bhvBlackSmokeBowser,
[id_bhvBlackSmokeUpward] = bhvBlackSmokeUpward,
[id_bhvBetaFishSplashSpawner] = bhvBetaFishSplashSpawner,
[id_bhvSpindrift] = bhvSpindrift,
[id_bhvTowerPlatformGroup] = bhvTowerPlatformGroup,
[id_bhvWfSlidingTowerPlatform] = bhvWfSlidingTowerPlatform,
[id_bhvWfElevatorTowerPlatform] = bhvWfElevatorTowerPlatform,
[id_bhvWfSolidTowerPlatform] = bhvWfSolidTowerPlatform,
[id_bhvLeafParticleSpawner] = bhvLeafParticleSpawner,
[id_bhvTreeSnow] = bhvTreeSnow,
[id_bhvTreeLeaf] = bhvTreeLeaf,
[id_bhvAnotherTiltingPlatform] = bhvAnotherTiltingPlatform,
[id_bhvSquarishPathMoving] = bhvSquarishPathMoving,
[id_bhvPiranhaPlantBubble] = bhvPiranhaPlantBubble,
[id_bhvPiranhaPlantWakingBubbles] = bhvPiranhaPlantWakingBubbles,
[id_bhvFloorSwitchAnimatesObject] = bhvFloorSwitchAnimatesObject,
[id_bhvFloorSwitchGrills] = bhvFloorSwitchGrills,
[id_bhvFloorSwitchHardcodedModel] = bhvFloorSwitchHardcodedModel,
[id_bhvFloorSwitchHiddenObjects] = bhvFloorSwitchHiddenObjects,
[id_bhvHiddenObject] = bhvHiddenObject,
[id_bhvBreakableBox] = bhvBreakableBox,
[id_bhvPushableMetalBox] = bhvPushableMetalBox,
[id_bhvHeaveHo] = bhvHeaveHo,
[id_bhvHeaveHoThrowMario] = bhvHeaveHoThrowMario,
[id_bhvCcmTouchedStarSpawn] = bhvCcmTouchedStarSpawn,
[id_bhvUnusedPoundablePlatform] = bhvUnusedPoundablePlatform,
[id_bhvBetaTrampolineTop] = bhvBetaTrampolineTop,
[id_bhvBetaTrampolineSpring] = bhvBetaTrampolineSpring,
[id_bhvJumpingBox] = bhvJumpingBox,
[id_bhvBooCage] = bhvBooCage,
[id_bhvStub] = bhvStub,
[id_bhvIgloo] = bhvIgloo,
[id_bhvBowserKey] = bhvBowserKey,
[id_bhvGrandStar] = bhvGrandStar,
[id_bhvBetaBooKey] = bhvBetaBooKey,
[id_bhvAlphaBooKey] = bhvAlphaBooKey,
[id_bhvBulletBill] = bhvBulletBill,
[id_bhvWhitePuffSmoke] = bhvWhitePuffSmoke,
[id_bhvUnused1820] = bhvUnused1820,
[id_bhvBowserTailAnchor] = bhvBowserTailAnchor,
[id_bhvBowser] = bhvBowser,
[id_bhvBowserBodyAnchor] = bhvBowserBodyAnchor,
[id_bhvBowserFlameSpawn] = bhvBowserFlameSpawn,
[id_bhvTiltingBowserLavaPlatform] = bhvTiltingBowserLavaPlatform,
[id_bhvFallingBowserPlatform] = bhvFallingBowserPlatform,
[id_bhvBlueBowserFlame] = bhvBlueBowserFlame,
[id_bhvFlameFloatingLanding] = bhvFlameFloatingLanding,
[id_bhvBlueFlamesGroup] = bhvBlueFlamesGroup,
[id_bhvFlameBouncing] = bhvFlameBouncing,
[id_bhvFlameMovingForwardGrowing] = bhvFlameMovingForwardGrowing,
[id_bhvFlameBowser] = bhvFlameBowser,
[id_bhvFlameLargeBurningOut] = bhvFlameLargeBurningOut,
[id_bhvBlueFish] = bhvBlueFish,
[id_bhvTankFishGroup] = bhvTankFishGroup,
[id_bhvCheckerboardElevatorGroup] = bhvCheckerboardElevatorGroup,
[id_bhvCheckerboardPlatformSub] = bhvCheckerboardPlatformSub,
[id_bhvBowserKeyUnlockDoor] = bhvBowserKeyUnlockDoor,
[id_bhvBowserKeyCourseExit] = bhvBowserKeyCourseExit,
[id_bhvInvisibleObjectsUnderBridge] = bhvInvisibleObjectsUnderBridge,
[id_bhvWaterLevelPillar] = bhvWaterLevelPillar,
[id_bhvDddWarp] = bhvDddWarp,
[id_bhvMoatGrills] = bhvMoatGrills,
[id_bhvClockMinuteHand] = bhvClockMinuteHand,
[id_bhvClockHourHand] = bhvClockHourHand,
[id_bhvMacroUkiki] = bhvMacroUkiki,
[id_bhvStub1D0C] = bhvStub1D0C,
[id_bhvLllRotatingHexagonalPlatform] = bhvLllRotatingHexagonalPlatform,
[id_bhvLllSinkingRockBlock] = bhvLllSinkingRockBlock,
[id_bhvStub1D70] = bhvStub1D70,
[id_bhvLllMovingOctagonalMeshPlatform] = bhvLllMovingOctagonalMeshPlatform,
[id_bhvLllRotatingBlockWithFireBars] = bhvLllRotatingBlockWithFireBars,
[id_bhvLllRotatingHexFlame] = bhvLllRotatingHexFlame,
[id_bhvLllWoodPiece] = bhvLllWoodPiece,
[id_bhvLllFloatingWoodBridge] = bhvLllFloatingWoodBridge,
[id_bhvVolcanoFlames] = bhvVolcanoFlames,
[id_bhvLllRotatingHexagonalRing] = bhvLllRotatingHexagonalRing,
[id_bhvLllSinkingRectangularPlatform] = bhvLllSinkingRectangularPlatform,
[id_bhvLllSinkingSquarePlatforms] = bhvLllSinkingSquarePlatforms,
[id_bhvLllTiltingInvertedPyramid] = bhvLllTiltingInvertedPyramid,
[id_bhvUnused1F30] = bhvUnused1F30,
[id_bhvKoopaShell] = bhvKoopaShell,
[id_bhvKoopaShellFlame] = bhvKoopaShellFlame,
[id_bhvToxBox] = bhvToxBox,
[id_bhvPiranhaPlant] = bhvPiranhaPlant,
[id_bhvLllHexagonalMesh] = bhvLllHexagonalMesh,
[id_bhvLllBowserPuzzlePiece] = bhvLllBowserPuzzlePiece,
[id_bhvLllBowserPuzzle] = bhvLllBowserPuzzle,
[id_bhvTuxiesMother] = bhvTuxiesMother,
[id_bhvPenguinBaby] = bhvPenguinBaby,
[id_bhvUnused20E0] = bhvUnused20E0,
[id_bhvSmallPenguin] = bhvSmallPenguin,
[id_bhvFish2] = bhvFish2,
[id_bhvFish3] = bhvFish3,
[id_bhvLargeFishGroup] = bhvLargeFishGroup,
[id_bhvFish] = bhvFish,
[id_bhvWdwExpressElevator] = bhvWdwExpressElevator,
[id_bhvWdwExpressElevatorPlatform] = bhvWdwExpressElevatorPlatform,
[id_bhvChirpChirp] = bhvChirpChirp,
[id_bhvBub] = bhvBub,
[id_bhvExclamationBox] = bhvExclamationBox,
[id_bhvRotatingExclamationMark] = bhvRotatingExclamationMark,
[id_bhvSoundSpawner] = bhvSoundSpawner,
[id_bhvRockSolid] = bhvRockSolid,
[id_bhvBowserSubDoor] = bhvBowserSubDoor,
[id_bhvBowsersSub] = bhvBowsersSub,
[id_bhvSushiShark] = bhvSushiShark,
[id_bhvSushiSharkCollisionChild] = bhvSushiSharkCollisionChild,
[id_bhvJrbSlidingBox] = bhvJrbSlidingBox,
[id_bhvShipPart3] = bhvShipPart3,
[id_bhvInSunkenShip3] = bhvInSunkenShip3,
[id_bhvSunkenShipPart] = bhvSunkenShipPart,
[id_bhvSunkenShipPart2] = bhvSunkenShipPart2,
[id_bhvInSunkenShip] = bhvInSunkenShip,
[id_bhvInSunkenShip2] = bhvInSunkenShip2,
[id_bhvMistParticleSpawner] = bhvMistParticleSpawner,
[id_bhvWhitePuff1] = bhvWhitePuff1,
[id_bhvWhitePuff2] = bhvWhitePuff2,
[id_bhvWhitePuffSmoke2] = bhvWhitePuffSmoke2,
[id_bhvPurpleSwitchHiddenBoxes] = bhvPurpleSwitchHiddenBoxes,
[id_bhvBlueCoinSwitch] = bhvBlueCoinSwitch,
[id_bhvHiddenBlueCoin] = bhvHiddenBlueCoin,
[id_bhvOpenableCageDoor] = bhvOpenableCageDoor,
[id_bhvOpenableGrill] = bhvOpenableGrill,
[id_bhvWaterLevelDiamond] = bhvWaterLevelDiamond,
[id_bhvInitializeChangingWaterLevel] = bhvInitializeChangingWaterLevel,
[id_bhvTweesterSandParticle] = bhvTweesterSandParticle,
[id_bhvTweester] = bhvTweester,
[id_bhvMerryGoRoundBooManager] = bhvMerryGoRoundBooManager,
[id_bhvAnimatedTexture] = bhvAnimatedTexture,
[id_bhvBooInCastle] = bhvBooInCastle,
[id_bhvBooWithCage] = bhvBooWithCage,
[id_bhvBalconyBigBoo] = bhvBalconyBigBoo,
[id_bhvMerryGoRoundBigBoo] = bhvMerryGoRoundBigBoo,
[id_bhvGhostHuntBigBoo] = bhvGhostHuntBigBoo,
[id_bhvCourtyardBooTriplet] = bhvCourtyardBooTriplet,
[id_bhvBoo] = bhvBoo,
[id_bhvMerryGoRoundBoo] = bhvMerryGoRoundBoo,
[id_bhvGhostHuntBoo] = bhvGhostHuntBoo,
[id_bhvHiddenStaircaseStep] = bhvHiddenStaircaseStep,
[id_bhvBooBossSpawnedBridge] = bhvBooBossSpawnedBridge,
[id_bhvBbhTiltingTrapPlatform] = bhvBbhTiltingTrapPlatform,
[id_bhvHauntedBookshelf] = bhvHauntedBookshelf,
[id_bhvMeshElevator] = bhvMeshElevator,
[id_bhvMerryGoRound] = bhvMerryGoRound,
[id_bhvPlaysMusicTrackWhenTouched] = bhvPlaysMusicTrackWhenTouched,
[id_bhvBetaBowserAnchor] = bhvBetaBowserAnchor,
[id_bhvStaticCheckeredPlatform] = bhvStaticCheckeredPlatform,
[id_bhvUnused2A10] = bhvUnused2A10,
[id_bhvUnusedFakeStar] = bhvUnusedFakeStar,
[id_bhvStaticObject] = bhvStaticObject,
[id_bhvUnused2A54] = bhvUnused2A54,
[id_bhvCastleFloorTrap] = bhvCastleFloorTrap,
[id_bhvFloorTrapInCastle] = bhvFloorTrapInCastle,
[id_bhvTree] = bhvTree,
[id_bhvSparkle] = bhvSparkle,
[id_bhvSparkleSpawn] = bhvSparkleSpawn,
[id_bhvSparkleParticleSpawner] = bhvSparkleParticleSpawner,
[id_bhvScuttlebug] = bhvScuttlebug,
[id_bhvScuttlebugSpawn] = bhvScuttlebugSpawn,
[id_bhvWhompKingBoss] = bhvWhompKingBoss,
[id_bhvSmallWhomp] = bhvSmallWhomp,
[id_bhvWaterSplash] = bhvWaterSplash,
[id_bhvWaterDroplet] = bhvWaterDroplet,
[id_bhvWaterDropletSplash] = bhvWaterDropletSplash,
[id_bhvBubbleSplash] = bhvBubbleSplash,
[id_bhvIdleWaterWave] = bhvIdleWaterWave,
[id_bhvObjectWaterSplash] = bhvObjectWaterSplash,
[id_bhvShallowWaterWave] = bhvShallowWaterWave,
[id_bhvShallowWaterSplash] = bhvShallowWaterSplash,
[id_bhvObjectWaveTrail] = bhvObjectWaveTrail,
[id_bhvWaveTrail] = bhvWaveTrail,
[id_bhvTinyStrongWindParticle] = bhvTinyStrongWindParticle,
[id_bhvStrongWindParticle] = bhvStrongWindParticle,
[id_bhvSLSnowmanWind] = bhvSLSnowmanWind,
[id_bhvSLWalkingPenguin] = bhvSLWalkingPenguin,
[id_bhvYellowBall] = bhvYellowBall,
[id_bhvMario] = bhvMario,
[id_bhvMario2] = bhvMario2,
[id_bhvToadMessage] = bhvToadMessage,
[id_bhvUnlockDoorStar] = bhvUnlockDoorStar,
[id_bhvRandomAnimatedTexture] = bhvRandomAnimatedTexture,
[id_bhvYellowBackgroundInMenu] = bhvYellowBackgroundInMenu,
[id_bhvMenuButton] = bhvMenuButton,
[id_bhvMenuButtonManager] = bhvMenuButtonManager,
[id_bhvActSelectorStarType] = bhvActSelectorStarType,
[id_bhvActSelector] = bhvActSelector,
[id_bhvMovingYellowCoin] = bhvMovingYellowCoin,
[id_bhvMovingBlueCoin] = bhvMovingBlueCoin,
[id_bhvBlueCoinSliding] = bhvBlueCoinSliding,
[id_bhvBlueCoinJumping] = bhvBlueCoinJumping,
[id_bhvSeaweed] = bhvSeaweed,
[id_bhvSeaweedBundle] = bhvSeaweedBundle,
[id_bhvBobomb] = bhvBobomb,
[id_bhvBobombFuseSmoke] = bhvBobombFuseSmoke,
[id_bhvBobombBuddy] = bhvBobombBuddy,
[id_bhvBobombBuddyOpensCannon] = bhvBobombBuddyOpensCannon,
[id_bhvCannonClosed] = bhvCannonClosed,
[id_bhvWhirlpool] = bhvWhirlpool,
[id_bhvJetStream] = bhvJetStream,
[id_bhvMessagePanel] = bhvMessagePanel,
[id_bhvSignOnWall] = bhvSignOnWall,
[id_bhvHomingAmp] = bhvHomingAmp,
[id_bhvCirclingAmp] = bhvCirclingAmp,
[id_bhvButterfly] = bhvButterfly,
[id_bhvHoot] = bhvHoot,
[id_bhvBetaHoldableObject] = bhvBetaHoldableObject,
[id_bhvCarrySomething1] = bhvCarrySomething1,
[id_bhvCarrySomething2] = bhvCarrySomething2,
[id_bhvCarrySomething3] = bhvCarrySomething3,
[id_bhvCarrySomething4] = bhvCarrySomething4,
[id_bhvCarrySomething5] = bhvCarrySomething5,
[id_bhvCarrySomething6] = bhvCarrySomething6,
[id_bhvObjectBubble] = bhvObjectBubble,
[id_bhvObjectWaterWave] = bhvObjectWaterWave,
[id_bhvExplosion] = bhvExplosion,
[id_bhvBobombBullyDeathSmoke] = bhvBobombBullyDeathSmoke,
[id_bhvSmoke] = bhvSmoke,
[id_bhvBobombExplosionBubble] = bhvBobombExplosionBubble,
[id_bhvRespawner] = bhvRespawner,
[id_bhvSmallBully] = bhvSmallBully,
[id_bhvBigBully] = bhvBigBully,
[id_bhvBigBullyWithMinions] = bhvBigBullyWithMinions,
[id_bhvSmallChillBully] = bhvSmallChillBully,
[id_bhvBigChillBully] = bhvBigChillBully,
[id_bhvJetStreamRingSpawner] = bhvJetStreamRingSpawner,
[id_bhvJetStreamWaterRing] = bhvJetStreamWaterRing,
[id_bhvMantaRayWaterRing] = bhvMantaRayWaterRing,
[id_bhvMantaRayRingManager] = bhvMantaRayRingManager,
[id_bhvBowserBomb] = bhvBowserBomb,
[id_bhvBowserBombExplosion] = bhvBowserBombExplosion,
[id_bhvBowserBombSmoke] = bhvBowserBombSmoke,
[id_bhvCelebrationStar] = bhvCelebrationStar,
[id_bhvCelebrationStarSparkle] = bhvCelebrationStarSparkle,
[id_bhvStarKeyCollectionPuffSpawner] = bhvStarKeyCollectionPuffSpawner,
[id_bhvLllDrawbridgeSpawner] = bhvLllDrawbridgeSpawner,
[id_bhvLllDrawbridge] = bhvLllDrawbridge,
[id_bhvSmallBomp] = bhvSmallBomp,
[id_bhvLargeBomp] = bhvLargeBomp,
[id_bhvWfSlidingPlatform] = bhvWfSlidingPlatform,
[id_bhvMoneybag] = bhvMoneybag,
[id_bhvMoneybagHidden] = bhvMoneybagHidden,
[id_bhvPitBowlingBall] = bhvPitBowlingBall,
[id_bhvFreeBowlingBall] = bhvFreeBowlingBall,
[id_bhvBowlingBall] = bhvBowlingBall,
[id_bhvTtmBowlingBallSpawner] = bhvTtmBowlingBallSpawner,
[id_bhvBobBowlingBallSpawner] = bhvBobBowlingBallSpawner,
[id_bhvThiBowlingBallSpawner] = bhvThiBowlingBallSpawner,
[id_bhvRrCruiserWing] = bhvRrCruiserWing,
[id_bhvSpindel] = bhvSpindel,
[id_bhvSslMovingPyramidWall] = bhvSslMovingPyramidWall,
[id_bhvPyramidElevator] = bhvPyramidElevator,
[id_bhvPyramidElevatorTrajectoryMarkerBall] = bhvPyramidElevatorTrajectoryMarkerBall,
[id_bhvPyramidTop] = bhvPyramidTop,
[id_bhvPyramidTopFragment] = bhvPyramidTopFragment,
[id_bhvPyramidPillarTouchDetector] = bhvPyramidPillarTouchDetector,
[id_bhvWaterfallSoundLoop] = bhvWaterfallSoundLoop,
[id_bhvVolcanoSoundLoop] = bhvVolcanoSoundLoop,
[id_bhvCastleFlagWaving] = bhvCastleFlagWaving,
[id_bhvBirdsSoundLoop] = bhvBirdsSoundLoop,
[id_bhvAmbientSounds] = bhvAmbientSounds,
[id_bhvSandSoundLoop] = bhvSandSoundLoop,
[id_bhvHiddenAt120Stars] = bhvHiddenAt120Stars,
[id_bhvSnowmansBottom] = bhvSnowmansBottom,
[id_bhvSnowmansHead] = bhvSnowmansHead,
[id_bhvSnowmansBodyCheckpoint] = bhvSnowmansBodyCheckpoint,
[id_bhvBigSnowmanWhole] = bhvBigSnowmanWhole,
[id_bhvBigBoulder] = bhvBigBoulder,
[id_bhvBigBoulderGenerator] = bhvBigBoulderGenerator,
[id_bhvWingCap] = bhvWingCap,
[id_bhvMetalCap] = bhvMetalCap,
[id_bhvNormalCap] = bhvNormalCap,
[id_bhvVanishCap] = bhvVanishCap,
[id_bhvStar] = bhvStar,
[id_bhvStarSpawnCoordinates] = bhvStarSpawnCoordinates,
[id_bhvHiddenRedCoinStar] = bhvHiddenRedCoinStar,
[id_bhvRedCoin] = bhvRedCoin,
[id_bhvBowserCourseRedCoinStar] = bhvBowserCourseRedCoinStar,
[id_bhvHiddenStar] = bhvHiddenStar,
[id_bhvHiddenStarTrigger] = bhvHiddenStarTrigger,
[id_bhvTtmRollingLog] = bhvTtmRollingLog,
[id_bhvLllVolcanoFallingTrap] = bhvLllVolcanoFallingTrap,
[id_bhvLllRollingLog] = bhvLllRollingLog,
[id_bhv1upWalking] = bhv1upWalking,
[id_bhv1upRunningAway] = bhv1upRunningAway,
[id_bhv1upSliding] = bhv1upSliding,
[id_bhv1Up] = bhv1Up,
[id_bhv1upJumpOnApproach] = bhv1upJumpOnApproach,
[id_bhvHidden1up] = bhvHidden1up,
[id_bhvHidden1upTrigger] = bhvHidden1upTrigger,
[id_bhvHidden1upInPole] = bhvHidden1upInPole,
[id_bhvHidden1upInPoleTrigger] = bhvHidden1upInPoleTrigger,
[id_bhvHidden1upInPoleSpawner] = bhvHidden1upInPoleSpawner,
[id_bhvControllablePlatform] = bhvControllablePlatform,
[id_bhvControllablePlatformSub] = bhvControllablePlatformSub,
[id_bhvBreakableBoxSmall] = bhvBreakableBoxSmall,
[id_bhvSlidingSnowMound] = bhvSlidingSnowMound,
[id_bhvSnowMoundSpawn] = bhvSnowMoundSpawn,
[id_bhvWdwSquareFloatingPlatform] = bhvWdwSquareFloatingPlatform,
[id_bhvWdwRectangularFloatingPlatform] = bhvWdwRectangularFloatingPlatform,
[id_bhvJrbFloatingPlatform] = bhvJrbFloatingPlatform,
[id_bhvArrowLift] = bhvArrowLift,
[id_bhvOrangeNumber] = bhvOrangeNumber,
[id_bhvMantaRay] = bhvMantaRay,
[id_bhvFallingPillar] = bhvFallingPillar,
[id_bhvFallingPillarHitbox] = bhvFallingPillarHitbox,
[id_bhvPillarBase] = bhvPillarBase,
[id_bhvJrbFloatingBox] = bhvJrbFloatingBox,
[id_bhvDecorativePendulum] = bhvDecorativePendulum,
[id_bhvTreasureChestsShip] = bhvTreasureChestsShip,
[id_bhvTreasureChestsJrb] = bhvTreasureChestsJrb,
[id_bhvTreasureChests] = bhvTreasureChests,
[id_bhvTreasureChestBottom] = bhvTreasureChestBottom,
[id_bhvTreasureChestTop] = bhvTreasureChestTop,
[id_bhvMips] = bhvMips,
[id_bhvYoshi] = bhvYoshi,
[id_bhvKoopa] = bhvKoopa,
[id_bhvKoopaRaceEndpoint] = bhvKoopaRaceEndpoint,
[id_bhvKoopaFlag] = bhvKoopaFlag,
[id_bhvPokey] = bhvPokey,
[id_bhvPokeyBodyPart] = bhvPokeyBodyPart,
[id_bhvSwoop] = bhvSwoop,
[id_bhvFlyGuy] = bhvFlyGuy,
[id_bhvGoomba] = bhvGoomba,
[id_bhvGoombaTripletSpawner] = bhvGoombaTripletSpawner,
[id_bhvChainChomp] = bhvChainChomp,
[id_bhvChainChompChainPart] = bhvChainChompChainPart,
[id_bhvWoodenPost] = bhvWoodenPost,
[id_bhvChainChompGate] = bhvChainChompGate,
[id_bhvWigglerHead] = bhvWigglerHead,
[id_bhvWigglerBody] = bhvWigglerBody,
[id_bhvEnemyLakitu] = bhvEnemyLakitu,
[id_bhvCameraLakitu] = bhvCameraLakitu,
[id_bhvCloud] = bhvCloud,
[id_bhvCloudPart] = bhvCloudPart,
[id_bhvSpiny] = bhvSpiny,
[id_bhvMontyMole] = bhvMontyMole,
[id_bhvMontyMoleHole] = bhvMontyMoleHole,
[id_bhvMontyMoleRock] = bhvMontyMoleRock,
[id_bhvPlatformOnTrack] = bhvPlatformOnTrack,
[id_bhvTrackBall] = bhvTrackBall,
[id_bhvSeesawPlatform] = bhvSeesawPlatform,
[id_bhvFerrisWheelAxle] = bhvFerrisWheelAxle,
[id_bhvFerrisWheelPlatform] = bhvFerrisWheelPlatform,
[id_bhvWaterBombSpawner] = bhvWaterBombSpawner,
[id_bhvWaterBomb] = bhvWaterBomb,
[id_bhvWaterBombShadow] = bhvWaterBombShadow,
[id_bhvTTCRotatingSolid] = bhvTTCRotatingSolid,
[id_bhvTTCPendulum] = bhvTTCPendulum,
[id_bhvTTCTreadmill] = bhvTTCTreadmill,
[id_bhvTTCMovingBar] = bhvTTCMovingBar,
[id_bhvTTCCog] = bhvTTCCog,
[id_bhvTTCPitBlock] = bhvTTCPitBlock,
[id_bhvTTCElevator] = bhvTTCElevator,
[id_bhvTTC2DRotator] = bhvTTC2DRotator,
[id_bhvTTCSpinner] = bhvTTCSpinner,
[id_bhvMrBlizzard] = bhvMrBlizzard,
[id_bhvMrBlizzardSnowball] = bhvMrBlizzardSnowball,
[id_bhvSlidingPlatform2] = bhvSlidingPlatform2,
[id_bhvOctagonalPlatformRotating] = bhvOctagonalPlatformRotating,
[id_bhvAnimatesOnFloorSwitchPress] = bhvAnimatesOnFloorSwitchPress,
[id_bhvActivatedBackAndForthPlatform] = bhvActivatedBackAndForthPlatform,
[id_bhvRecoveryHeart] = bhvRecoveryHeart,
[id_bhvWaterBombCannon] = bhvWaterBombCannon,
[id_bhvCannonBarrelBubbles] = bhvCannonBarrelBubbles,
[id_bhvUnagi] = bhvUnagi,
[id_bhvUnagiSubobject] = bhvUnagiSubobject,
[id_bhvDorrie] = bhvDorrie,
[id_bhvHauntedChair] = bhvHauntedChair,
[id_bhvMadPiano] = bhvMadPiano,
[id_bhvFlyingBookend] = bhvFlyingBookend,
[id_bhvBookendSpawn] = bhvBookendSpawn,
[id_bhvHauntedBookshelfManager] = bhvHauntedBookshelfManager,
[id_bhvBookSwitch] = bhvBookSwitch,
[id_bhvFirePiranhaPlant] = bhvFirePiranhaPlant,
[id_bhvSmallPiranhaFlame] = bhvSmallPiranhaFlame,
[id_bhvFireSpitter] = bhvFireSpitter,
[id_bhvFlyguyFlame] = bhvFlyguyFlame,
[id_bhvSnufit] = bhvSnufit,
[id_bhvSnufitBalls] = bhvSnufitBalls,
[id_bhvHorizontalGrindel] = bhvHorizontalGrindel,
[id_bhvEyerokBoss] = bhvEyerokBoss,
[id_bhvEyerokHand] = bhvEyerokHand,
[id_bhvKlepto] = bhvKlepto,
[id_bhvBird] = bhvBird,
[id_bhvRacingPenguin] = bhvRacingPenguin,
[id_bhvPenguinRaceFinishLine] = bhvPenguinRaceFinishLine,
[id_bhvPenguinRaceShortcutCheck] = bhvPenguinRaceShortcutCheck,
[id_bhvCoffinSpawner] = bhvCoffinSpawner,
[id_bhvCoffin] = bhvCoffin,
[id_bhvClamShell] = bhvClamShell,
[id_bhvSkeeter] = bhvSkeeter,
[id_bhvSkeeterWave] = bhvSkeeterWave,
[id_bhvSwingPlatform] = bhvSwingPlatform,
[id_bhvDonutPlatformSpawner] = bhvDonutPlatformSpawner,
[id_bhvDonutPlatform] = bhvDonutPlatform,
[id_bhvDDDPole] = bhvDDDPole,
[id_bhvRedCoinStarMarker] = bhvRedCoinStarMarker,
[id_bhvTripletButterfly] = bhvTripletButterfly,
[id_bhvBubba] = bhvBubba,
[id_bhvBeginningLakitu] = bhvBeginningLakitu,
[id_bhvBeginningPeach] = bhvBeginningPeach,
[id_bhvEndBirds1] = bhvEndBirds1,
[id_bhvEndBirds2] = bhvEndBirds2,
[id_bhvIntroScene] = bhvIntroScene,
};
enum BehaviorId get_id_from_behavior(const BehaviorScript* behavior) {
return (enum BehaviorId)(behavior[1] & 0xFFFF);
}
const BehaviorScript* get_behavior_from_id(enum BehaviorId id) {
return gBehaviorTable[id];
}

529
include/behavior_table.h Normal file
View file

@ -0,0 +1,529 @@
#ifndef BEHAVIOR_TABLE_H
#define BEHAVIOR_TABLE_H
#include "behavior_data.h"
extern const BehaviorScript* gBehaviorTable[];
enum BehaviorId {
id_bhvStarDoor,
id_bhvMrI,
id_bhvMrIBody,
id_bhvMrIParticle,
id_bhvPurpleParticle,
id_bhvGiantPole,
id_bhvPoleGrabbing,
id_bhvThiHugeIslandTop,
id_bhvThiTinyIslandTop,
id_bhvCapSwitchBase,
id_bhvCapSwitch,
id_bhvKingBobomb,
id_bhvBobombAnchorMario,
id_bhvBetaChestBottom,
id_bhvBetaChestLid,
id_bhvBubbleParticleSpawner,
id_bhvBubbleMaybe,
id_bhvSmallWaterWave,
id_bhvWaterAirBubble,
id_bhvSmallParticle,
id_bhvPlungeBubble,
id_bhvSmallParticleSnow,
id_bhvSmallParticleBubbles,
id_bhvFishGroup,
id_bhvCannon,
id_bhvCannonBarrel,
id_bhvCannonBaseUnused,
id_bhvChuckya,
id_bhvChuckyaAnchorMario,
id_bhvUnused05A8,
id_bhvRotatingPlatform,
id_bhvTower,
id_bhvBulletBillCannon,
id_bhvWfBreakableWallRight,
id_bhvWfBreakableWallLeft,
id_bhvKickableBoard,
id_bhvTowerDoor,
id_bhvRotatingCounterClockwise,
id_bhvWfRotatingWoodenPlatform,
id_bhvKoopaShellUnderwater,
id_bhvExitPodiumWarp,
id_bhvFadingWarp,
id_bhvWarp,
id_bhvWarpPipe,
id_bhvWhitePuffExplosion,
id_bhvSpawnedStar,
id_bhvSpawnedStarNoLevelExit,
id_bhvMrIBlueCoin,
id_bhvCoinInsideBoo,
id_bhvCoinFormationSpawn,
id_bhvCoinFormation,
id_bhvOneCoin,
id_bhvYellowCoin,
id_bhvTemporaryYellowCoin,
id_bhvThreeCoinsSpawn,
id_bhvTenCoinsSpawn,
id_bhvSingleCoinGetsSpawned,
id_bhvCoinSparkles,
id_bhvGoldenCoinSparkles,
id_bhvWallTinyStarParticle,
id_bhvVertStarParticleSpawner,
id_bhvPoundTinyStarParticle,
id_bhvHorStarParticleSpawner,
id_bhvPunchTinyTriangle,
id_bhvTriangleParticleSpawner,
id_bhvDoorWarp,
id_bhvDoor,
id_bhvGrindel,
id_bhvThwomp2,
id_bhvThwomp,
id_bhvTumblingBridgePlatform,
id_bhvWfTumblingBridge,
id_bhvBbhTumblingBridge,
id_bhvLllTumblingBridge,
id_bhvFlame,
id_bhvAnotherElavator,
id_bhvRrElevatorPlatform,
id_bhvHmcElevatorPlatform,
id_bhvWaterMist,
id_bhvBreathParticleSpawner,
id_bhvBreakBoxTriangle,
id_bhvWaterMist2,
id_bhvUnused0DFC,
id_bhvMistCircParticleSpawner,
id_bhvDirtParticleSpawner,
id_bhvSnowParticleSpawner,
id_bhvWind,
id_bhvEndToad,
id_bhvEndPeach,
id_bhvUnusedParticleSpawn,
id_bhvUkiki,
id_bhvUkikiCageChild,
id_bhvUkikiCageStar,
id_bhvUkikiCage,
id_bhvBitfsSinkingPlatforms,
id_bhvBitfsSinkingCagePlatform,
id_bhvDddMovingPole,
id_bhvBitfsTiltingInvertedPyramid,
id_bhvSquishablePlatform,
id_bhvCutOutObject,
id_bhvBetaMovingFlames,
id_bhvRrRotatingBridgePlatform,
id_bhvFlamethrower,
id_bhvFlamethrowerFlame,
id_bhvBouncingFireball,
id_bhvBouncingFireballFlame,
id_bhvBowserShockWave,
id_bhvFireParticleSpawner,
id_bhvBlackSmokeMario,
id_bhvBlackSmokeBowser,
id_bhvBlackSmokeUpward,
id_bhvBetaFishSplashSpawner,
id_bhvSpindrift,
id_bhvTowerPlatformGroup,
id_bhvWfSlidingTowerPlatform,
id_bhvWfElevatorTowerPlatform,
id_bhvWfSolidTowerPlatform,
id_bhvLeafParticleSpawner,
id_bhvTreeSnow,
id_bhvTreeLeaf,
id_bhvAnotherTiltingPlatform,
id_bhvSquarishPathMoving,
id_bhvPiranhaPlantBubble,
id_bhvPiranhaPlantWakingBubbles,
id_bhvFloorSwitchAnimatesObject,
id_bhvFloorSwitchGrills,
id_bhvFloorSwitchHardcodedModel,
id_bhvFloorSwitchHiddenObjects,
id_bhvHiddenObject,
id_bhvBreakableBox,
id_bhvPushableMetalBox,
id_bhvHeaveHo,
id_bhvHeaveHoThrowMario,
id_bhvCcmTouchedStarSpawn,
id_bhvUnusedPoundablePlatform,
id_bhvBetaTrampolineTop,
id_bhvBetaTrampolineSpring,
id_bhvJumpingBox,
id_bhvBooCage,
id_bhvStub,
id_bhvIgloo,
id_bhvBowserKey,
id_bhvGrandStar,
id_bhvBetaBooKey,
id_bhvAlphaBooKey,
id_bhvBulletBill,
id_bhvWhitePuffSmoke,
id_bhvUnused1820,
id_bhvBowserTailAnchor,
id_bhvBowser,
id_bhvBowserBodyAnchor,
id_bhvBowserFlameSpawn,
id_bhvTiltingBowserLavaPlatform,
id_bhvFallingBowserPlatform,
id_bhvBlueBowserFlame,
id_bhvFlameFloatingLanding,
id_bhvBlueFlamesGroup,
id_bhvFlameBouncing,
id_bhvFlameMovingForwardGrowing,
id_bhvFlameBowser,
id_bhvFlameLargeBurningOut,
id_bhvBlueFish,
id_bhvTankFishGroup,
id_bhvCheckerboardElevatorGroup,
id_bhvCheckerboardPlatformSub,
id_bhvBowserKeyUnlockDoor,
id_bhvBowserKeyCourseExit,
id_bhvInvisibleObjectsUnderBridge,
id_bhvWaterLevelPillar,
id_bhvDddWarp,
id_bhvMoatGrills,
id_bhvClockMinuteHand,
id_bhvClockHourHand,
id_bhvMacroUkiki,
id_bhvStub1D0C,
id_bhvLllRotatingHexagonalPlatform,
id_bhvLllSinkingRockBlock,
id_bhvStub1D70,
id_bhvLllMovingOctagonalMeshPlatform,
id_bhvLllRotatingBlockWithFireBars,
id_bhvLllRotatingHexFlame,
id_bhvLllWoodPiece,
id_bhvLllFloatingWoodBridge,
id_bhvVolcanoFlames,
id_bhvLllRotatingHexagonalRing,
id_bhvLllSinkingRectangularPlatform,
id_bhvLllSinkingSquarePlatforms,
id_bhvLllTiltingInvertedPyramid,
id_bhvUnused1F30,
id_bhvKoopaShell,
id_bhvKoopaShellFlame,
id_bhvToxBox,
id_bhvPiranhaPlant,
id_bhvLllHexagonalMesh,
id_bhvLllBowserPuzzlePiece,
id_bhvLllBowserPuzzle,
id_bhvTuxiesMother,
id_bhvPenguinBaby,
id_bhvUnused20E0,
id_bhvSmallPenguin,
id_bhvFish2,
id_bhvFish3,
id_bhvLargeFishGroup,
id_bhvFish,
id_bhvWdwExpressElevator,
id_bhvWdwExpressElevatorPlatform,
id_bhvChirpChirp,
id_bhvBub,
id_bhvExclamationBox,
id_bhvRotatingExclamationMark,
id_bhvSoundSpawner,
id_bhvRockSolid,
id_bhvBowserSubDoor,
id_bhvBowsersSub,
id_bhvSushiShark,
id_bhvSushiSharkCollisionChild,
id_bhvJrbSlidingBox,
id_bhvShipPart3,
id_bhvInSunkenShip3,
id_bhvSunkenShipPart,
id_bhvSunkenShipPart2,
id_bhvInSunkenShip,
id_bhvInSunkenShip2,
id_bhvMistParticleSpawner,
id_bhvWhitePuff1,
id_bhvWhitePuff2,
id_bhvWhitePuffSmoke2,
id_bhvPurpleSwitchHiddenBoxes,
id_bhvBlueCoinSwitch,
id_bhvHiddenBlueCoin,
id_bhvOpenableCageDoor,
id_bhvOpenableGrill,
id_bhvWaterLevelDiamond,
id_bhvInitializeChangingWaterLevel,
id_bhvTweesterSandParticle,
id_bhvTweester,
id_bhvMerryGoRoundBooManager,
id_bhvAnimatedTexture,
id_bhvBooInCastle,
id_bhvBooWithCage,
id_bhvBalconyBigBoo,
id_bhvMerryGoRoundBigBoo,
id_bhvGhostHuntBigBoo,
id_bhvCourtyardBooTriplet,
id_bhvBoo,
id_bhvMerryGoRoundBoo,
id_bhvGhostHuntBoo,
id_bhvHiddenStaircaseStep,
id_bhvBooBossSpawnedBridge,
id_bhvBbhTiltingTrapPlatform,
id_bhvHauntedBookshelf,
id_bhvMeshElevator,
id_bhvMerryGoRound,
id_bhvPlaysMusicTrackWhenTouched,
id_bhvBetaBowserAnchor,
id_bhvStaticCheckeredPlatform,
id_bhvUnused2A10,
id_bhvUnusedFakeStar,
id_bhvStaticObject,
id_bhvUnused2A54,
id_bhvCastleFloorTrap,
id_bhvFloorTrapInCastle,
id_bhvTree,
id_bhvSparkle,
id_bhvSparkleSpawn,
id_bhvSparkleParticleSpawner,
id_bhvScuttlebug,
id_bhvScuttlebugSpawn,
id_bhvWhompKingBoss,
id_bhvSmallWhomp,
id_bhvWaterSplash,
id_bhvWaterDroplet,
id_bhvWaterDropletSplash,
id_bhvBubbleSplash,
id_bhvIdleWaterWave,
id_bhvObjectWaterSplash,
id_bhvShallowWaterWave,
id_bhvShallowWaterSplash,
id_bhvObjectWaveTrail,
id_bhvWaveTrail,
id_bhvTinyStrongWindParticle,
id_bhvStrongWindParticle,
id_bhvSLSnowmanWind,
id_bhvSLWalkingPenguin,
id_bhvYellowBall,
id_bhvMario,
id_bhvMario2,
id_bhvToadMessage,
id_bhvUnlockDoorStar,
id_bhvRandomAnimatedTexture,
id_bhvYellowBackgroundInMenu,
id_bhvMenuButton,
id_bhvMenuButtonManager,
id_bhvActSelectorStarType,
id_bhvActSelector,
id_bhvMovingYellowCoin,
id_bhvMovingBlueCoin,
id_bhvBlueCoinSliding,
id_bhvBlueCoinJumping,
id_bhvSeaweed,
id_bhvSeaweedBundle,
id_bhvBobomb,
id_bhvBobombFuseSmoke,
id_bhvBobombBuddy,
id_bhvBobombBuddyOpensCannon,
id_bhvCannonClosed,
id_bhvWhirlpool,
id_bhvJetStream,
id_bhvMessagePanel,
id_bhvSignOnWall,
id_bhvHomingAmp,
id_bhvCirclingAmp,
id_bhvButterfly,
id_bhvHoot,
id_bhvBetaHoldableObject,
id_bhvCarrySomething1,
id_bhvCarrySomething2,
id_bhvCarrySomething3,
id_bhvCarrySomething4,
id_bhvCarrySomething5,
id_bhvCarrySomething6,
id_bhvObjectBubble,
id_bhvObjectWaterWave,
id_bhvExplosion,
id_bhvBobombBullyDeathSmoke,
id_bhvSmoke,
id_bhvBobombExplosionBubble,
id_bhvRespawner,
id_bhvSmallBully,
id_bhvBigBully,
id_bhvBigBullyWithMinions,
id_bhvSmallChillBully,
id_bhvBigChillBully,
id_bhvJetStreamRingSpawner,
id_bhvJetStreamWaterRing,
id_bhvMantaRayWaterRing,
id_bhvMantaRayRingManager,
id_bhvBowserBomb,
id_bhvBowserBombExplosion,
id_bhvBowserBombSmoke,
id_bhvCelebrationStar,
id_bhvCelebrationStarSparkle,
id_bhvStarKeyCollectionPuffSpawner,
id_bhvLllDrawbridgeSpawner,
id_bhvLllDrawbridge,
id_bhvSmallBomp,
id_bhvLargeBomp,
id_bhvWfSlidingPlatform,
id_bhvMoneybag,
id_bhvMoneybagHidden,
id_bhvPitBowlingBall,
id_bhvFreeBowlingBall,
id_bhvBowlingBall,
id_bhvTtmBowlingBallSpawner,
id_bhvBobBowlingBallSpawner,
id_bhvThiBowlingBallSpawner,
id_bhvRrCruiserWing,
id_bhvSpindel,
id_bhvSslMovingPyramidWall,
id_bhvPyramidElevator,
id_bhvPyramidElevatorTrajectoryMarkerBall,
id_bhvPyramidTop,
id_bhvPyramidTopFragment,
id_bhvPyramidPillarTouchDetector,
id_bhvWaterfallSoundLoop,
id_bhvVolcanoSoundLoop,
id_bhvCastleFlagWaving,
id_bhvBirdsSoundLoop,
id_bhvAmbientSounds,
id_bhvSandSoundLoop,
id_bhvHiddenAt120Stars,
id_bhvSnowmansBottom,
id_bhvSnowmansHead,
id_bhvSnowmansBodyCheckpoint,
id_bhvBigSnowmanWhole,
id_bhvBigBoulder,
id_bhvBigBoulderGenerator,
id_bhvWingCap,
id_bhvMetalCap,
id_bhvNormalCap,
id_bhvVanishCap,
id_bhvStar,
id_bhvStarSpawnCoordinates,
id_bhvHiddenRedCoinStar,
id_bhvRedCoin,
id_bhvBowserCourseRedCoinStar,
id_bhvHiddenStar,
id_bhvHiddenStarTrigger,
id_bhvTtmRollingLog,
id_bhvLllVolcanoFallingTrap,
id_bhvLllRollingLog,
id_bhv1upWalking,
id_bhv1upRunningAway,
id_bhv1upSliding,
id_bhv1Up,
id_bhv1upJumpOnApproach,
id_bhvHidden1up,
id_bhvHidden1upTrigger,
id_bhvHidden1upInPole,
id_bhvHidden1upInPoleTrigger,
id_bhvHidden1upInPoleSpawner,
id_bhvControllablePlatform,
id_bhvControllablePlatformSub,
id_bhvBreakableBoxSmall,
id_bhvSlidingSnowMound,
id_bhvSnowMoundSpawn,
id_bhvWdwSquareFloatingPlatform,
id_bhvWdwRectangularFloatingPlatform,
id_bhvJrbFloatingPlatform,
id_bhvArrowLift,
id_bhvOrangeNumber,
id_bhvMantaRay,
id_bhvFallingPillar,
id_bhvFallingPillarHitbox,
id_bhvPillarBase,
id_bhvJrbFloatingBox,
id_bhvDecorativePendulum,
id_bhvTreasureChestsShip,
id_bhvTreasureChestsJrb,
id_bhvTreasureChests,
id_bhvTreasureChestBottom,
id_bhvTreasureChestTop,
id_bhvMips,
id_bhvYoshi,
id_bhvKoopa,
id_bhvKoopaRaceEndpoint,
id_bhvKoopaFlag,
id_bhvPokey,
id_bhvPokeyBodyPart,
id_bhvSwoop,
id_bhvFlyGuy,
id_bhvGoomba,
id_bhvGoombaTripletSpawner,
id_bhvChainChomp,
id_bhvChainChompChainPart,
id_bhvWoodenPost,
id_bhvChainChompGate,
id_bhvWigglerHead,
id_bhvWigglerBody,
id_bhvEnemyLakitu,
id_bhvCameraLakitu,
id_bhvCloud,
id_bhvCloudPart,
id_bhvSpiny,
id_bhvMontyMole,
id_bhvMontyMoleHole,
id_bhvMontyMoleRock,
id_bhvPlatformOnTrack,
id_bhvTrackBall,
id_bhvSeesawPlatform,
id_bhvFerrisWheelAxle,
id_bhvFerrisWheelPlatform,
id_bhvWaterBombSpawner,
id_bhvWaterBomb,
id_bhvWaterBombShadow,
id_bhvTTCRotatingSolid,
id_bhvTTCPendulum,
id_bhvTTCTreadmill,
id_bhvTTCMovingBar,
id_bhvTTCCog,
id_bhvTTCPitBlock,
id_bhvTTCElevator,
id_bhvTTC2DRotator,
id_bhvTTCSpinner,
id_bhvMrBlizzard,
id_bhvMrBlizzardSnowball,
id_bhvSlidingPlatform2,
id_bhvOctagonalPlatformRotating,
id_bhvAnimatesOnFloorSwitchPress,
id_bhvActivatedBackAndForthPlatform,
id_bhvRecoveryHeart,
id_bhvWaterBombCannon,
id_bhvCannonBarrelBubbles,
id_bhvUnagi,
id_bhvUnagiSubobject,
id_bhvDorrie,
id_bhvHauntedChair,
id_bhvMadPiano,
id_bhvFlyingBookend,
id_bhvBookendSpawn,
id_bhvHauntedBookshelfManager,
id_bhvBookSwitch,
id_bhvFirePiranhaPlant,
id_bhvSmallPiranhaFlame,
id_bhvFireSpitter,
id_bhvFlyguyFlame,
id_bhvSnufit,
id_bhvSnufitBalls,
id_bhvHorizontalGrindel,
id_bhvEyerokBoss,
id_bhvEyerokHand,
id_bhvKlepto,
id_bhvBird,
id_bhvRacingPenguin,
id_bhvPenguinRaceFinishLine,
id_bhvPenguinRaceShortcutCheck,
id_bhvCoffinSpawner,
id_bhvCoffin,
id_bhvClamShell,
id_bhvSkeeter,
id_bhvSkeeterWave,
id_bhvSwingPlatform,
id_bhvDonutPlatformSpawner,
id_bhvDonutPlatform,
id_bhvDDDPole,
id_bhvRedCoinStarMarker,
id_bhvTripletButterfly,
id_bhvBubba,
id_bhvBeginningLakitu,
id_bhvBeginningPeach,
id_bhvEndBirds1,
id_bhvEndBirds2,
id_bhvIntroScene,
id_bhv_max_count // must be the last in the list
};
enum BehaviorId get_id_from_behavior(const BehaviorScript* behavior);
const BehaviorScript* get_behavior_from_id(enum BehaviorId id);
#endif

View file

@ -880,6 +880,13 @@ static s32 bhv_cmd_animate_texture(void) {
return BHV_PROC_CONTINUE; return BHV_PROC_CONTINUE;
} }
// Command 0x39: Defines the id of the behavior script, used for synchronization
// Usage: ID(index)
static s32 bhv_cmd_id(void) {
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
void stub_behavior_script_2(void) { void stub_behavior_script_2(void) {
} }
@ -941,7 +948,8 @@ static BhvCommandProc BehaviorCmdTable[] = {
bhv_cmd_disable_rendering, //35 bhv_cmd_disable_rendering, //35
bhv_cmd_set_int_unused, //36 bhv_cmd_set_int_unused, //36
bhv_cmd_spawn_water_droplet, //37 bhv_cmd_spawn_water_droplet, //37
bhv_cmd_cylboard //38 bhv_cmd_cylboard, //38
bhv_cmd_id //38
}; };
// Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects. // Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects.

View file

@ -5,8 +5,9 @@
#include "socket/socket.h" #include "socket/socket.h"
enum NetworkType networkType; enum NetworkType networkType;
SOCKET gSocket; static SOCKET gSocket;
unsigned short txPort; static char* txIp = "127.0.0.1";
static unsigned short txPort;
void network_init(enum NetworkType inNetworkType) { void network_init(enum NetworkType inNetworkType) {
networkType = inNetworkType; networkType = inNetworkType;
@ -38,7 +39,7 @@ void network_send(struct Packet* p) {
memcpy(&p->buffer[p->dataLength], &hash, sizeof(u32)); memcpy(&p->buffer[p->dataLength], &hash, sizeof(u32));
// send // send
int rc = socket_send(gSocket, "127.0.0.1", txPort, p->buffer, p->cursor + sizeof(u32)); int rc = socket_send(gSocket, txIp, txPort, p->buffer, p->cursor + sizeof(u32));
if (rc != NO_ERROR) { return; } if (rc != NO_ERROR) { return; }
p->sent = true; p->sent = true;
} }

View file

@ -2,6 +2,7 @@
#include "../network.h" #include "../network.h"
#include "object_fields.h" #include "object_fields.h"
#include "object_constants.h" #include "object_constants.h"
#include "behavior_table.h"
#include "course_table.h" #include "course_table.h"
#include "src/game/interaction.h" #include "src/game/interaction.h"
#include "src/engine/math_util.h" #include "src/engine/math_util.h"
@ -46,11 +47,12 @@ static struct Object* find_nearest_coin(const BehaviorScript *behavior, f32* pos
} }
void network_send_collect_coin(struct Object* o) { void network_send_collect_coin(struct Object* o) {
enum BehaviorId behaviorId = get_id_from_behavior(o->behavior);
struct Packet p; struct Packet p;
packet_init(&p, PACKET_COLLECT_COIN, true); packet_init(&p, PACKET_COLLECT_COIN, true);
packet_write(&p, &localCoinId, sizeof(u8)); packet_write(&p, &localCoinId, sizeof(u8));
packet_write(&p, &o->behavior, sizeof(void*)); packet_write(&p, &behaviorId, sizeof(enum BehaviorId));
packet_write(&p, &o->oPosX, sizeof(f32) * 3); packet_write(&p, &o->oPosX, sizeof(f32) * 3);
packet_write(&p, &gMarioStates[0].numCoins, sizeof(s16)); packet_write(&p, &gMarioStates[0].numCoins, sizeof(s16));
packet_write(&p, &o->oDamageOrCoinValue, sizeof(s32)); packet_write(&p, &o->oDamageOrCoinValue, sizeof(s32));
@ -61,17 +63,20 @@ void network_send_collect_coin(struct Object* o) {
void network_receive_collect_coin(struct Packet* p) { void network_receive_collect_coin(struct Packet* p) {
u8 remoteCoinId = 0; u8 remoteCoinId = 0;
enum BehaviorId behaviorId;
void* behavior = NULL; void* behavior = NULL;
f32 pos[3] = { 0 }; f32 pos[3] = { 0 };
s16 numCoins = 0; s16 numCoins = 0;
s32 coinValue = 0; s32 coinValue = 0;
packet_read(p, &remoteCoinId, sizeof(u8)); packet_read(p, &remoteCoinId, sizeof(u8));
packet_read(p, &behavior, sizeof(void*)); packet_read(p, &behaviorId, sizeof(enum BehaviorId));
packet_read(p, &pos, sizeof(f32) * 3); packet_read(p, &pos, sizeof(f32) * 3);
packet_read(p, &numCoins, sizeof(s16)); packet_read(p, &numCoins, sizeof(s16));
packet_read(p, &coinValue, sizeof(s32)); packet_read(p, &coinValue, sizeof(s32));
behavior = get_behavior_from_id(behaviorId);
// check if remote coin id has already been seen // check if remote coin id has already been seen
for (int i = 0; i < MAX_REMOTE_COIN_IDS; i++) { for (int i = 0; i < MAX_REMOTE_COIN_IDS; i++) {
if (remoteCoinIds[i] == remoteCoinId) { if (remoteCoinIds[i] == remoteCoinId) {

View file

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include "../network.h" #include "../network.h"
#include "behavior_table.h"
#include "course_table.h" #include "course_table.h"
#include "object_fields.h" #include "object_fields.h"
#include "object_constants.h" #include "object_constants.h"
@ -40,13 +41,15 @@ static struct Object* find_nearest_star(const BehaviorScript* behavior, f32* pos
} }
void network_send_collect_star(struct Object* o, s16 coinScore, s16 starIndex) { void network_send_collect_star(struct Object* o, s16 coinScore, s16 starIndex) {
enum BehaviorId behaviorId = get_id_from_behavior(o->behavior);
struct Packet p; struct Packet p;
packet_init(&p, PACKET_COLLECT_STAR, true); packet_init(&p, PACKET_COLLECT_STAR, true);
packet_write(&p, &gCurrSaveFileNum, sizeof(s16)); packet_write(&p, &gCurrSaveFileNum, sizeof(s16));
packet_write(&p, &gCurrCourseNum, sizeof(s16)); packet_write(&p, &gCurrCourseNum, sizeof(s16));
packet_write(&p, &o->oPosX, sizeof(u32) * 3); packet_write(&p, &o->oPosX, sizeof(u32) * 3);
packet_write(&p, &o->behavior, sizeof(void*)); packet_write(&p, &behaviorId, sizeof(enum BehaviorId));
packet_write(&p, &coinScore, sizeof(s16)); packet_write(&p, &coinScore, sizeof(s16));
packet_write(&p, &starIndex, sizeof(s16)); packet_write(&p, &starIndex, sizeof(s16));
@ -55,6 +58,7 @@ void network_send_collect_star(struct Object* o, s16 coinScore, s16 starIndex) {
void network_receive_collect_star(struct Packet* p) { void network_receive_collect_star(struct Packet* p) {
u32 pos[3] = { 0 }; u32 pos[3] = { 0 };
enum BehaviorId behaviorId;
void* behavior = NULL; void* behavior = NULL;
s16 coinScore, starIndex; s16 coinScore, starIndex;
s16 lastSaveFileNum = gCurrSaveFileNum; s16 lastSaveFileNum = gCurrSaveFileNum;
@ -63,10 +67,12 @@ void network_receive_collect_star(struct Packet* p) {
packet_read(p, &gCurrSaveFileNum, sizeof(s16)); packet_read(p, &gCurrSaveFileNum, sizeof(s16));
packet_read(p, &gCurrCourseNum, sizeof(s16)); packet_read(p, &gCurrCourseNum, sizeof(s16));
packet_read(p, &pos, sizeof(u32) * 3); packet_read(p, &pos, sizeof(u32) * 3);
packet_read(p, &behavior, sizeof(void*)); packet_read(p, &behaviorId, sizeof(enum BehaviorId));
packet_read(p, &coinScore, sizeof(s16)); packet_read(p, &coinScore, sizeof(s16));
packet_read(p, &starIndex, sizeof(s16)); packet_read(p, &starIndex, sizeof(s16));
behavior = get_behavior_from_id(behaviorId);
save_file_collect_star_or_key(coinScore, starIndex); save_file_collect_star_or_key(coinScore, starIndex);
s32 numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1); s32 numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1);

View file

@ -4,6 +4,7 @@
#include "object_fields.h" #include "object_fields.h"
#include "object_constants.h" #include "object_constants.h"
#include "behavior_data.h" #include "behavior_data.h"
#include "behavior_table.h"
u8 nextSyncID = 1; u8 nextSyncID = 1;
struct SyncObject syncObjects[MAX_SYNC_OBJECTS] = { 0 }; struct SyncObject syncObjects[MAX_SYNC_OBJECTS] = { 0 };
@ -62,12 +63,14 @@ void network_send_object(struct Object* o) {
so->onEventId++; so->onEventId++;
enum BehaviorId behaviorId = get_id_from_behavior(o->behavior);
bool reliable = (o->activeFlags == ACTIVE_FLAG_DEACTIVATED || so->maxSyncDistance == SYNC_DISTANCE_ONLY_EVENTS); bool reliable = (o->activeFlags == ACTIVE_FLAG_DEACTIVATED || so->maxSyncDistance == SYNC_DISTANCE_ONLY_EVENTS);
struct Packet p; struct Packet p;
packet_init(&p, PACKET_OBJECT, reliable); packet_init(&p, PACKET_OBJECT, reliable);
packet_write(&p, &o->oSyncID, 4); packet_write(&p, &o->oSyncID, 4);
packet_write(&p, &so->onEventId, sizeof(u16)); packet_write(&p, &so->onEventId, sizeof(u16));
packet_write(&p, &so->behavior, sizeof(void*)); packet_write(&p, &behaviorId, sizeof(enum BehaviorId));
if (so->maxSyncDistance != SYNC_DISTANCE_ONLY_EVENTS) { if (so->maxSyncDistance != SYNC_DISTANCE_ONLY_EVENTS) {
packet_write(&p, &o->activeFlags, sizeof(s16)); packet_write(&p, &o->activeFlags, sizeof(s16));
@ -135,7 +138,9 @@ void network_receive_object(struct Packet* p) {
so->onEventId = eventId; so->onEventId = eventId;
// make sure the behaviors match // make sure the behaviors match
packet_read(p, &so->behavior, sizeof(void*)); enum BehaviorId behaviorId;
packet_read(p, &behaviorId, sizeof(enum BehaviorId));
so->behavior = get_behavior_from_id(behaviorId);
if (o->behavior != so->behavior) { if (o->behavior != so->behavior) {
printf("network_receive_object() BEHAVIOR MISMATCH!\n"); printf("network_receive_object() BEHAVIOR MISMATCH!\n");
forget_sync_object(so); forget_sync_object(so);

View file

@ -3,6 +3,7 @@
#include "object_fields.h" #include "object_fields.h"
#include "object_constants.h" #include "object_constants.h"
#include "behavior_data.h" #include "behavior_data.h"
#include "behavior_table.h"
static u8 localSpawnId = 1; static u8 localSpawnId = 1;
@ -17,7 +18,7 @@ static u8 onRemoteSpawnId = 0;
struct SpawnObjectData { struct SpawnObjectData {
u8 parentId; u8 parentId;
u32 model; u32 model;
void* behavior; enum BehaviorId behaviorId;
s16 activeFlags; s16 activeFlags;
s32 rawData[80]; s32 rawData[80];
}; };
@ -49,9 +50,10 @@ void network_send_spawn_objects(struct Object* objects[], u32 models[], u8 objec
struct Object* o = objects[i]; struct Object* o = objects[i];
u32 model = models[i]; u32 model = models[i];
u8 parentId = generate_parent_id(objects, i); u8 parentId = generate_parent_id(objects, i);
enum BehaviorId behaviorId = get_id_from_behavior(o->behavior);
packet_write(&p, &parentId, sizeof(u8)); packet_write(&p, &parentId, sizeof(u8));
packet_write(&p, &model, sizeof(u32)); packet_write(&p, &model, sizeof(u32));
packet_write(&p, &o->behavior, sizeof(void*)); packet_write(&p, &behaviorId, sizeof(enum BehaviorId));
packet_write(&p, &o->activeFlags, sizeof(s16)); packet_write(&p, &o->activeFlags, sizeof(s16));
packet_write(&p, o->rawData.asU32, sizeof(s32) * 80); packet_write(&p, o->rawData.asU32, sizeof(s32) * 80);
assert(o->oSyncID == 0); assert(o->oSyncID == 0);
@ -86,7 +88,7 @@ void network_receive_spawn_objects(struct Packet* p) {
struct SpawnObjectData data = { 0 }; struct SpawnObjectData data = { 0 };
packet_read(p, &data.parentId, sizeof(u8)); packet_read(p, &data.parentId, sizeof(u8));
packet_read(p, &data.model, sizeof(u32)); packet_read(p, &data.model, sizeof(u32));
packet_read(p, &data.behavior, sizeof(void*)); packet_read(p, &data.behaviorId, sizeof(enum BehaviorId));
packet_read(p, &data.activeFlags, sizeof(s16)); packet_read(p, &data.activeFlags, sizeof(s16));
packet_read(p, &data.rawData, sizeof(s32) * 80); packet_read(p, &data.rawData, sizeof(s32) * 80);
@ -95,7 +97,8 @@ void network_receive_spawn_objects(struct Packet* p) {
: spawned[data.parentId]; : spawned[data.parentId];
if (parentObj == NULL) { continue; } if (parentObj == NULL) { continue; }
struct Object* o = spawn_object(parentObj, data.model, data.behavior); void* behavior = get_behavior_from_id(data.behaviorId);
struct Object* o = spawn_object(parentObj, data.model, behavior);
memcpy(o->rawData.asU32, data.rawData, sizeof(u32) * 80); memcpy(o->rawData.asU32, data.rawData, sizeof(u32) * 80);
spawned[i] = o; spawned[i] = o;