Path: blob/master/Sonic 1/Scripts/SYZ/HVSpikeBall.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: HV Spike Ball Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.amplitude.x12private alias object.value1 : object.amplitude.y1314// Player Aliases15private alias object.value17 : debugMode.currentSelection161718// ========================19// Function Declarations20// ========================2122reserve function HVSpikeBall_DebugDraw23reserve function HVSpikeBall_DebugSpawn242526// ========================27// Static Values28// ========================2930private value HVSpikeBall_startDebugID = 0313233// ========================34// Function Definitions35// ========================3637private function HVSpikeBall_DebugDraw38DrawSprite(0)39end function404142private function HVSpikeBall_DebugSpawn43CreateTempObject(TypeName[HV Spike Ball], object.direction, object.xpos, object.ypos)44temp0 = debugMode[0].currentSelection45temp0 -= HVSpikeBall_startDebugID4647if temp0 == 048if object.direction == FLIP_NONE49object[tempObjectPos].amplitude.x = 0x180050object[tempObjectPos].amplitude.y = 051object[tempObjectPos].xpos -= 0x30000052else53object[tempObjectPos].amplitude.x = -0x180054object[tempObjectPos].amplitude.y = 055object[tempObjectPos].xpos -= 0x30000056end if57else58if object.direction == FLIP_NONE59object[tempObjectPos].amplitude.x = 060object[tempObjectPos].amplitude.y = 0x180061object[tempObjectPos].ypos -= 0x30000062else63object[tempObjectPos].amplitude.x = 064object[tempObjectPos].amplitude.y = -0x180065object[tempObjectPos].ypos -= 0x50000066end if67end if68end function697071// ========================72// Events73// ========================7475event ObjectUpdate76object.angle = SYZSetup_oscillation77object.angle *= 0x20078object.angle /= 3567980temp0 = object.xpos81temp1 = object.ypos8283Cos(object.xpos, object.angle)84object.xpos *= object.amplitude.x85object.xpos += temp08687Sin(object.ypos, object.angle)88object.ypos *= object.amplitude.y89object.ypos += temp19091foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)92BoxCollisionTest(C_TOUCH, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)93if checkResult == true94CallFunction(Player_Hit)95end if96next9798object.xpos = temp099object.ypos = temp1100end event101102103event ObjectDraw104Cos(temp0, object.angle)105temp0 *= object.amplitude.x106temp0 += object.xpos107108Sin(temp1, object.angle)109temp1 *= object.amplitude.y110temp1 += object.ypos111112DrawSpriteXY(0, temp0, temp1)113end event114115116event ObjectStartup117LoadSpriteSheet("SYZ/Objects.gif")118SpriteFrame(-24, -24, 48, 48, 61, 178)119120foreach (TypeName[HV Spike Ball], arrayPos0, ALL_ENTITIES)121switch object[arrayPos0].propertyValue122case 0123object[arrayPos0].amplitude.x = 0x1800124object[arrayPos0].amplitude.y = 0125object[arrayPos0].xpos -= 0x300000126break127128case 1129object[arrayPos0].amplitude.x = -0x1800130object[arrayPos0].amplitude.y = 0131object[arrayPos0].xpos -= 0x300000132break133134case 2135object[arrayPos0].amplitude.x = 0136object[arrayPos0].amplitude.y = 0x1800137object[arrayPos0].ypos -= 0x300000138break139140case 3141object[arrayPos0].amplitude.x = 0142object[arrayPos0].amplitude.y = -0x1800143object[arrayPos0].ypos -= 0x500000144break145146end switch147next148149temp0 = 0150HVSpikeBall_startDebugID = DebugMode_ObjCount151while temp0 < 2152SetTableValue(TypeName[HV Spike Ball], DebugMode_ObjCount, DebugMode_TypesTable)153SetTableValue(HVSpikeBall_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)154SetTableValue(HVSpikeBall_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)155DebugMode_ObjCount++156temp0++157loop158end event159160161// ========================162// Editor Events163// ========================164165event RSDKEdit166if editor.returnVariable == true167switch editor.variableID168case EDIT_VAR_PROPVAL // property value169checkResult = object.propertyValue170break171172case 0 // type173checkResult = object.propertyValue174break175176end switch177else178switch editor.variableID179case EDIT_VAR_PROPVAL // property value180object.propertyValue = editor.variableValue181break182183case 0 // type184object.propertyValue = editor.variableValue185break186187end switch188end if189end event190191192event RSDKDraw193DrawSprite(0)194195if editor.showGizmos == true196editor.drawingOverlay = true197198temp6 = object.xpos199temp7 = object.ypos200201switch object.propertyValue202case 0203object.amplitude.x = 0x1800204object.amplitude.y = 0205object.xpos -= 0x300000206object.angle = 0x180207break208209case 1210object.amplitude.x = -0x1800211object.amplitude.y = 0212object.xpos -= 0x300000213object.angle = 0x80214break215216case 2217object.amplitude.x = 0218object.amplitude.y = 0x1800219object.ypos -= 0x300000220object.angle = 0x180221break222223case 3224object.amplitude.x = 0225object.amplitude.y = -0x1800226object.ypos -= 0x500000227object.angle = 0x80228break229230end switch231232arrayPos0 = 0233object.angle = 0x80234while arrayPos0 < 2235Cos(temp0, object.angle)236temp0 *= object.amplitude.x237temp0 += object.xpos238239Sin(temp1, object.angle)240temp1 *= object.amplitude.y241temp1 += object.ypos242243object.inkEffect = INK_BLEND244DrawSpriteFX(0, FX_INK, temp0, temp1)245246object.angle += 0x100247arrayPos0++248loop249250object.xpos = temp6251object.ypos = temp7252253editor.drawingOverlay = false254end if255end event256257258event RSDKLoad259LoadSpriteSheet("SYZ/Objects.gif")260SpriteFrame(-24, -24, 48, 48, 61, 178)261262AddEditorVariable("type")263SetActiveVariable("type")264AddEnumVariable("Right, Then Left", 0)265AddEnumVariable("Left, Then Right", 1)266AddEnumVariable("Down, Then Up", 2)267AddEnumVariable("Up, Then Down", 3)268end event269270271