Path: blob/master/Sonic 1/Scripts/SLZ/Fan.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: 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.isOn1314// Player Aliases15private alias object.state : player.state16private alias object.xpos : player.xpos17private alias object.ypos : player.ypos1819private alias object.value17 : debugMode.currentSelection2021// ========================22// Function Declarations23// ========================2425reserve function Fan_DebugDraw26reserve function Fan_DebugSpawn272829// ========================30// Static Values31// ========================3233private value Fan_startDebugID = 0343536// ========================37// Function Definitions38// ========================3940private function Fan_DebugDraw41DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)42end function434445private function Fan_DebugSpawn46temp0 = debugMode[0].currentSelection47temp0 -= Fan_startDebugID48CreateTempObject(TypeName[Fan], temp0, object.xpos, object.ypos)49object[tempObjectPos].direction = object.direction50end function515253// ========================54// Events55// ========================5657event ObjectUpdate58GetBit(temp0, object.propertyValue, 1) // Bit 1 is true if the object should always be on59if temp0 == false60object.timer--61if object.timer <= 062if object.isOn == false63object.timer = 12064else65object.timer = 18066end if6768object.isOn ^= true69end if70end if7172if object.isOn == false73// Check if the object should be activated7475foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)7677// Some special Knux exceptions, don't blow him away if he's supposed to be static for right now78CheckEqual(player[currentPlayer].state, Player_State_Climb)79temp0 = checkResult80CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)81temp0 |= checkResult8283if temp0 == false84temp0 = player[currentPlayer].xpos85temp0 &= 0xFFFF000086temp0 -= object.xpos87GetBit(temp2, object.direction, 0)88if temp2 == FLIP_NONE89FlipSign(temp0)90end if9192temp0 += 0x50000093if temp0 >= 094if temp0 < 0xF0000095temp1 = player[currentPlayer].ypos96temp1 &= 0xFFFF000097temp1 -= object.ypos9899// See if Y flip bit is set100GetBit(temp2, object.direction, 1)101if temp2 == true102FlipSign(temp1)103end if104temp1 += 0x600000105106// See if this object should have a taller hitbox height107GetBit(temp2, object.propertyValue, 2)108if temp2 == true109temp3 = 0x900000110else111temp3 = 0x700000112end if113114if temp1 >= 0115if temp1 < temp3116temp0 -= 0x500000117if temp0 < 0118temp0 ^= 0xFFFF0000119temp0 <<= 1120end if121temp0 += 0x600000122if object.direction == FLIP_NONE123FlipSign(temp0)124end if125temp0 ^= 0xFF0000126temp0 += 0x10000127temp0 >>= 4128GetBit(temp1, object.propertyValue, 0)129if temp1 != false130FlipSign(temp0)131end if132133player[currentPlayer].xpos += temp0134end if135end if136end if137end if138end if139next140141object.animationTimer++142if object.animationTimer >= 3143object.animationTimer = 0144end if145object.frame = object.animationTimer146147GetBit(temp0, object.propertyValue, 0)148if temp0 != false149object.frame += 2150end if151end if152end event153154155event ObjectDraw156DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)157end event158159160event ObjectStartup161LoadSpriteSheet("SLZ/Objects.gif")162163// Fan frames164SpriteFrame(-11, -16, 27, 32, 6, 223)165SpriteFrame(-12, -15, 28, 31, 38, 224)166SpriteFrame(-11, -14, 27, 30, 72, 225)167SpriteFrame(-12, -15, 28, 31, 38, 224)168SpriteFrame(-11, -16, 27, 32, 6, 223)169170temp0 = 0171Fan_startDebugID = DebugMode_ObjCount172Fan_startDebugID--173while temp0 < 4174SetTableValue(TypeName[Fan], DebugMode_ObjCount, DebugMode_TypesTable)175SetTableValue(Fan_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)176SetTableValue(Fan_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)177DebugMode_ObjCount++178temp0++179loop180end event181182183// ========================184// Editor Events185// ========================186187event RSDKEdit188if editor.returnVariable == true189switch editor.variableID190case EDIT_VAR_PROPVAL // property value191checkResult = object.propertyValue192checkResult &= 7193break194195case 0 // forceDir196GetBit(checkResult, object.propertyValue, 0)197break198199case 1 // alwaysOn200GetBit(checkResult, object.propertyValue, 1)201break202203case 2 // force204GetBit(checkResult, object.propertyValue, 2)205break206207end switch208else209switch editor.variableID210case EDIT_VAR_PROPVAL // property value211object.propertyValue = editor.variableValue212object.propertyValue &= 7213break214215case 0 // forceDir216CheckNotEqual(editor.variableValue, 0)217SetBit(object.propertyValue, 0, checkResult)218break219220case 1 // alwaysOn221CheckNotEqual(editor.variableValue, false)222SetBit(object.propertyValue, 1, checkResult)223break224225case 2 // force226CheckNotEqual(editor.variableValue, 0)227SetBit(object.propertyValue, 2, checkResult)228break229230end switch231end if232end event233234235event RSDKDraw236GetBit(object.frame, object.propertyValue, 0)237DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)238239if editor.showGizmos == true240editor.drawingOverlay = true241242// TODO: we're just drawing a dir arrow, but showing the complete hitbox would be cool243244temp1 = object.xpos245if object.frame == 1246temp1 -= 0x200000247else248temp1 += 0x200000249end if250DrawArrow(object.xpos, object.ypos, temp1, object.ypos, 0x00, 0xFF, 0x00)251252editor.drawingOverlay = false253end if254end event255256257event RSDKLoad258LoadSpriteSheet("SLZ/Objects.gif")259SpriteFrame(-11, -16, 27, 32, 6, 223)260SpriteFrame(-11, -14, 27, 30, 72, 225)261262// Not the same as direction, idk why but it is what it is263AddEditorVariable("forceDir")264SetActiveVariable("forceDir")265AddEnumVariable("Right", 0)266AddEnumVariable("Left", 1)267268AddEditorVariable("alwaysOn")269SetActiveVariable("alwaysOn")270AddEnumVariable("false", false)271AddEnumVariable("true", true)272273AddEditorVariable("force") // TODO: idk what to call it but this should be hitbox height274SetActiveVariable("force")275AddEnumVariable("Weak", 0)276AddEnumVariable("Strong", 1)277end event278279280