Path: blob/master/Sonic 2/Scripts/OOZ/VFan.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: V Fan Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.timer12private alias object.value1 : object.fanOffset.y13private alias object.value2 : object.hitboxT14private alias object.value3 : object.hitboxB1516// States17private alias 0 : VFAN_DEACTIVATE18private alias 1 : VFAN_IDLE19private alias 2 : VFAN_ACTIVE2021// Player Aliases22private alias object.state : player.state23private alias object.ypos : player.ypos24private alias object.xvel : player.xvel25private alias object.yvel : player.yvel26private alias object.speed : player.speed27private alias object.gravity : player.gravity28private alias object.animationSpeed : player.animationSpeed29private alias object.animation : player.animation30private alias object.scrollTracking : player.scrollTracking31private alias object.tileCollisions : player.tileCollisions3233private alias object.value1 : player.timer343536// ========================37// Function Declarations38// ========================3940reserve function VFan_DebugDraw41reserve function VFan_DebugSpawn424344// ========================45// Function Definitions46// ========================4748private function VFan_DebugDraw49DrawSprite(0)50end function515253private function VFan_DebugSpawn54CreateTempObject(TypeName[V Fan], 0, object.xpos, object.ypos)55object[tempObjectPos].speed = 4856end function575859// ========================60// Events61// ========================6263event ObjectUpdate64switch object.state65case VFAN_DEACTIVATE66if object.speed > 067object.speed--68else69object.state++70end if71object.frame = object.animationTimer72object.frame /= 4873object.animationTimer += object.speed74object.animationTimer %= 28875break7677case VFAN_IDLE78object.timer++79if object.timer == 3080object.timer = 081object.speed = 4882object.state++83end if84break8586case VFAN_ACTIVE87object.frame = object.animationTimer88object.frame /= 4889object.animationTimer += object.speed90object.animationTimer %= 2889192object.timer++93if object.timer == 18094object.timer = 095object.state = VFAN_DEACTIVATE96end if9798// (This little thing done with temp0, the result isn't actually used anywhere else in this script)99// Perhaps this object used to use this variable for oscillation rather than the oscillation table itself?100temp0 = oscillation101temp0 <<= 2102103GetTableValue(object.hitboxT, 10, StageSetup_oscillationTable)104object.hitboxT >>= 8105object.hitboxB = object.hitboxT106object.hitboxT -= 112107object.hitboxB += 32108object.fanOffset.y = object.hitboxT109object.fanOffset.y <<= 16110object.fanOffset.y += object.ypos111foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)112BoxCollisionTest(C_TOUCH, object.entityPos, -64, object.hitboxT, 64, object.hitboxB, currentPlayer, 0, 0, 0, 0)113if checkResult == true114player[currentPlayer].animation = ANI_TWIRL115player[currentPlayer].animationSpeed = 0x50116player[currentPlayer].scrollTracking = true117player[currentPlayer].gravity = GRAVITY_AIR118#platform: USE_STANDALONE119player[currentPlayer].state = Player_State_Air120#endplatform121#platform: USE_ORIGINS122player[currentPlayer].state = Player_State_Air_NoDropDash123#endplatform124player[currentPlayer].tileCollisions = true125player[currentPlayer].speed = player[currentPlayer].xvel126player[currentPlayer].timer = 0127player[currentPlayer].yvel = 0128temp1 = object.fanOffset.y129temp1 -= player[currentPlayer].ypos130temp1 >>= 4131player[currentPlayer].ypos += temp1132end if133next134break135136end switch137end event138139140event ObjectDraw141DrawSprite(object.frame)142end event143144145event ObjectStartup146CheckCurrentStageFolder("Zone07")147if checkResult == true148LoadSpriteSheet("OOZ/Objects.gif")149SpriteFrame(-16, -12, 32, 24, 206, 181)150SpriteFrame(-16, -12, 32, 24, 239, 181)151SpriteFrame(-16, -12, 32, 24, 206, 206)152SpriteFrame(-16, -12, 32, 24, 239, 206)153SpriteFrame(-16, -12, 32, 24, 206, 231)154SpriteFrame(-16, -12, 32, 24, 239, 231)155else156LoadSpriteSheet("MBZ/Objects.gif")157SpriteFrame(-16, -12, 32, 24, 376, 820)158SpriteFrame(-16, -12, 32, 24, 409, 820)159SpriteFrame(-16, -12, 32, 24, 376, 845)160SpriteFrame(-16, -12, 32, 24, 409, 845)161SpriteFrame(-16, -12, 32, 24, 376, 870)162SpriteFrame(-16, -12, 32, 24, 409, 870)163end if164165foreach (TypeName[V Fan], arrayPos0, ALL_ENTITIES)166object[arrayPos0].speed = 36167next168169SetTableValue(TypeName[V Fan], DebugMode_ObjCount, DebugMode_TypesTable)170SetTableValue(VFan_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)171SetTableValue(VFan_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)172DebugMode_ObjCount++173end event174175176// ========================177// Editor Events178// ========================179180event RSDKDraw181DrawSprite(0)182183if editor.showGizmos == true184editor.drawingOverlay = true185186// The hitbox oscillates a bit, but it's only by a few pixels, so this is okay187temp0 = 64; temp1 = 112; temp2 = 64; temp3 = 32;188CallFunction(EditorHelpers_DrawHitbox)189190editor.drawingOverlay = false191end if192end event193194195event RSDKLoad196CheckCurrentStageFolder("Zone07")197if checkResult == true198LoadSpriteSheet("OOZ/Objects.gif")199SpriteFrame(-16, -12, 32, 24, 206, 181)200else201LoadSpriteSheet("MBZ/Objects.gif")202SpriteFrame(-16, -12, 32, 24, 376, 820)203end if204205SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")206end event207208209