Path: blob/master/Sonic 1/Scripts/MZ/UFO.txt
1481 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: UFO Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// Reserved Object Slot Aliases12// (The UFO object occupies the slot the Title Card is initially in)13private alias 11 : SLOT_TITLECARD141516// ========================17// Function Declarations18// ========================1920reserve function UFO_DebugDraw21reserve function UFO_DebugSpawn222324// ========================25// Function Definitions26// ========================2728private function UFO_DebugDraw29DrawSprite(0)30end function313233private function UFO_DebugSpawn34// Place one... and then clear it?35// The actual UFO placing is done below, a fake one is placed because Debug Mode does an operation with tempObjectPos after running the DebugSpawn function36CreateTempObject(TypeName[UFO], 0, object.xpos, object.ypos)37object[tempObjectPos].type = TypeName[Blank Object]3839// There can only be 1 UFO object at a time since they occupy the Title Card object slot, so let's see if they exist and either add them or remove them40if object[SLOT_TITLECARD].type == TypeName[UFO]41// If the UFOs already exist, clear them42ResetObjectEntity(SLOT_TITLECARD, TypeName[Blank Object], 0, 0, 0)43else44// If they don't exist, then spawn them45ResetObjectEntity(SLOT_TITLECARD, TypeName[UFO], 0, 0, 0)46object[SLOT_TITLECARD].priority = PRIORITY_ACTIVE47object[SLOT_TITLECARD].drawOrder = 1 // Place it among the lowest draw order, it's supposed to be drawn as part of the BG48object[SLOT_TITLECARD].inkEffect = INK_ALPHA49end if50end function515253// ========================54// Events55// ========================5657event ObjectUpdate58// Animate the UFOs59object.frame = object.animationTimer60object.frame >>= 36162object.animationTimer++63object.animationTimer &= 6364end event656667event ObjectDraw68if screen.yoffset < 64069temp0 = screen.xoffset70temp0 >>= 371temp0 &= 0x7F72FlipSign(temp0)7374// temp1 is the base pos for the UFOs to draw at75temp1 = tileLayer[1].scrollPos76temp1 /= -0x1000077temp1 += 327879// First draw the "closer" set of UFOs80temp2 = screen.xsize81temp2 += 3282temp5 = oscillation83temp5 <<= 184while temp0 < temp285temp3 = temp086temp3 += temp58788Sin(temp4, temp3)89temp4 >>= 590temp4 += temp19192Cos(object.alpha, temp3)93object.alpha >>= 294object.alpha += 1289596DrawSpriteScreenFX(object.frame, FX_INK, temp0, temp4)9798temp0 += 6499loop100101// And then draw the "further" set of UFOs102temp0 = screen.xoffset103temp0 >>= 4104temp0 &= 0x7F105temp0 += 32106FlipSign(temp0)107while temp0 < temp2108temp3 = temp0109temp3 += temp5110111Sin(temp4, temp3)112temp4 >>= 5113FlipSign(temp4)114temp4 += temp1115116Cos(object.alpha, temp3)117object.alpha >>= 2118FlipSign(object.alpha)119object.alpha += 128120121DrawSpriteScreenFX(object.frame, FX_INK, temp0, temp4)122123temp0 += 64124loop125end if126end event127128129event ObjectStartup130LoadSpriteSheet("MZ/Objects.gif")131132// UFO frames133SpriteFrame(-16, -8, 32, 16, 123, 303)134SpriteFrame(-16, -8, 32, 16, 156, 230)135SpriteFrame(-16, -12, 32, 24, 123, 247)136SpriteFrame(-16, -15, 32, 30, 123, 272)137SpriteFrame(-16, -16, 32, 32, 130, 355)138SpriteFrame(-16, -15, 32, 30, 156, 273)139SpriteFrame(-16, -12, 32, 25, 156, 247)140SpriteFrame(-16, -8, 32, 16, 123, 230)141142// Add UFOs to the stage's debug object list143SetTableValue(TypeName[UFO], DebugMode_ObjCount, DebugMode_TypesTable)144SetTableValue(UFO_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)145SetTableValue(UFO_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)146DebugMode_ObjCount++147end event148149150// ========================151// Editor Events152// ========================153154event RSDKDraw155DrawSprite(0)156end event157158159event RSDKLoad160LoadSpriteSheet("MZ/Objects.gif")161SpriteFrame(-16, -8, 32, 16, 123, 303)162163SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")164end event165166167