Path: blob/master/Sonic 1/Scripts/Global/LampPost.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Lamp Post Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.ballAngle12private alias object.value1 : object.ballPos.x13private alias object.value2 : object.ballPos.y1415private alias 0 : LAMPPOST_INACTIVE16private alias 1 : LAMPPOST_SPINNING17private alias 2 : LAMPPOST_ACTIVE1819// Player Aliases20private alias object.xpos : player.xpos21private alias object.ypos : player.ypos22private alias object.ixpos : player.ixpos23private alias object.iypos : player.iypos24private alias object.value0 : player.rings2526private alias 0 : SLOT_PLAYER1272829// ========================30// Function Declarations31// ========================3233reserve function LampPost_DebugDraw34reserve function LampPost_DebugSpawn353637// ========================38// Editor Events39// ========================4041private function LampPost_DebugDraw42DrawSprite(0)43end function444546private function LampPost_DebugSpawn47CreateTempObject(TypeName[Lamp Post], 0, object.xpos, object.ypos)48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)57if object.state == LAMPPOST_INACTIVE58BoxCollisionTest(C_TOUCH, object.entityPos, -8, -44, 8, 20, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)59if checkResult == true60lampPostID = object.entityPos61#platform: USE_ORIGINS62recScore = player.score63recRing = player[0].rings64#endplatform65recMilliSeconds = stage.milliSeconds66recSeconds = stage.seconds67recMinutes = stage.minutes68recWaterState = stage.waterState69recWaterLevel = stage.waterLevel70#platform: USE_ORIGINS71StatsUsabilityParam1 = StageStatsUsabilityParam172StatsUsabilityParam2 = StageStatsUsabilityParam273StatsUsabilityParam3 = StageStatsUsabilityParam374StatsUsabilityParam4 = StageStatsUsabilityParam475StatsUsabilityParam5 = StageStatsUsabilityParam576#endplatform77object.state = LAMPPOST_SPINNING78object.ballAngle = 0x18079if object.priority != PRIORITY_XBOUNDS_DESTROY80object.priority = PRIORITY_ACTIVE81end if82PlaySfx(SfxName[Lamp Post], false)83#platform: USE_ORIGINS84if options.attractMode == false85// That little autosave icon, I sure hope you like it...86CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_CHECKPOINT, 0)87end if88#endplatform89end if90end if91next9293if object.state == LAMPPOST_SPINNING94Cos(object.ballPos.x, object.ballAngle)95object.ballPos.x *= -0x5009697Sin(object.ballPos.y, object.ballAngle)98object.ballPos.y *= 0x50099100object.ballPos.x += object.xpos101object.ballPos.y += object.ypos102object.ballPos.y -= 0x1A0000103104object.ballAngle += 0x20105if object.ballAngle > 0x580106object.ballAngle = 0107object.state = LAMPPOST_ACTIVE108if object.priority != PRIORITY_XBOUNDS_DESTROY109object.priority = PRIORITY_BOUNDS110end if111end if112end if113end event114115116event ObjectDraw117switch object.state118case LAMPPOST_INACTIVE119DrawSprite(0)120break121122case LAMPPOST_SPINNING123DrawSprite(1)124DrawSpriteXY(3, object.ballPos.x, object.ballPos.y)125break126127case LAMPPOST_ACTIVE128DrawSprite(1)129object.ballAngle++130if object.ballAngle == 8131object.ballAngle = 0132end if133134temp0 = object.ypos135temp0 -= 0x240000136DrawSpriteXY(3, object.xpos, temp0)137break138139end switch140end event141142143event ObjectStartup144LoadSpriteSheet("Global/Items.gif")145146SpriteFrame(-8, -44, 16, 64, 1, 137) // 0 - Full checkpoint sprite147SpriteFrame(-8, -28, 16, 48, 1, 153) // 1 - Checkpoint body sprite148SpriteFrame(-8, -8, 16, 16, 1, 137) // 2 - Blue ball sprite149SpriteFrame(-8, -8, 16, 16, 1, 236) // 3 - Red ball sprite150// (Weird green ball next to these on the sheet is unused)151152SetTableValue(TypeName[Lamp Post], DebugMode_ObjCount, DebugMode_TypesTable)153SetTableValue(LampPost_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)154SetTableValue(LampPost_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)155DebugMode_ObjCount++156157if lampPostID > 31158arrayPos0 = lampPostID159160// Move all Players to the Lamp Post161currentPlayer = SLOT_PLAYER1162while currentPlayer < playerCount163player[currentPlayer].xpos = object[arrayPos0].xpos164player[currentPlayer].ypos = object[arrayPos0].ypos165currentPlayer++166loop167168#platform: USE_ORIGINS169player.score = recScore170171if player.deadResetRings == true172player[0].rings = 0173player.deadResetRings = false174else175player[0].rings = recRing176end if177178ringExtraLife = 100179ringExtraLife += player[0].rings180temp0 = player[0].rings181temp0 %= 100182ringExtraLife -= temp0183if ringExtraLife > 300184ringExtraLife = 1000185end if186#endplatform187188camera[0].xpos = player[0].ixpos189camera[0].ypos = player[0].iypos190191object[arrayPos0].state = LAMPPOST_ACTIVE192193stage.milliSeconds = recMilliSeconds194stage.seconds = recSeconds195stage.minutes = recMinutes196197#platform: USE_ORIGINS198StageStatsUsabilityParam1 = StatsUsabilityParam1199StageStatsUsabilityParam2 = StatsUsabilityParam2200StageStatsUsabilityParam3 = StatsUsabilityParam3201StageStatsUsabilityParam4 = StatsUsabilityParam4202StageStatsUsabilityParam5 = StatsUsabilityParam5203else204game.timeOver = false205#endplatform206end if207end event208209210// ========================211// Editor Events212// ========================213214event RSDKDraw215DrawSprite(0)216end event217218219event RSDKLoad220LoadSpriteSheet("Global/Items.gif")221SpriteFrame(-8, -44, 16, 64, 1, 137)222223// unused, BUT there are values in the editor which suggest it's supposed to be "lampPostID"224SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")225end event226227228