Path: blob/master/Sonic 1/Scripts/LZ/RotatingSpike.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Rotating Spike Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.spinAngle12private alias object.value1 : object.spinSpeed13private alias object.value2 : object.length14private alias object.value3 : object.amplitude15private alias object.value4 : object.drawPos.x16private alias object.value5 : object.drawPos.y1718// Player Aliases19private alias object.value17 : debugMode.currentSelection202122// ========================23// Function Declarations24// ========================2526reserve function RotatingSpike_DebugDraw27reserve function RotatingSpike_DebugSpawn282930// ========================31// Static Values32// ========================3334private value RotatingSpike_startDebugID = 0353637// ========================38// Function Definitions39// ========================4041private function RotatingSpike_DebugDraw42temp7 = debugMode[0].currentSelection43temp7 -= RotatingSpike_startDebugID44temp6 = object.direction45temp6 <<= 84647DrawSprite(0)48temp0 = 049temp1 = 1650while temp0 < temp751Cos(temp2, temp6)52temp2 *= temp153temp2 <<= 754temp2 += object.xpos5556Sin(temp3, temp6)57temp3 *= temp158temp3 <<= 759temp3 += object.ypos6061DrawSpriteXY(1, temp2, temp3)6263temp0++64temp1 += 1665loop6667Cos(temp2, temp6)68temp2 *= temp169temp2 <<= 770temp2 += object.xpos7172Sin(temp3, temp6)73temp3 *= temp174temp3 <<= 775temp3 += object.ypos7677DrawSpriteXY(2, temp2, temp3)78end function798081private function RotatingSpike_DebugSpawn82CreateTempObject(TypeName[Rotating Spike], 0, object.xpos, object.ypos)8384object[tempObjectPos].spinAngle = object.direction85object[tempObjectPos].spinAngle <<= 168687if object.direction == FLIP_NONE88object[tempObjectPos].spinSpeed = 25689else90object[tempObjectPos].spinSpeed = -25691end if9293object[tempObjectPos].length = debugMode[0].currentSelection94object[tempObjectPos].length -= RotatingSpike_startDebugID95object[tempObjectPos].length++9697object[tempObjectPos].amplitude = object[tempObjectPos].length98object[tempObjectPos].amplitude <<= 499end function100101102// ========================103// Events104// ========================105106event ObjectUpdate107object.spinAngle += object.spinSpeed108object.spinAngle &= 0x1FFFF109temp0 = object.spinAngle110temp0 >>= 8111112Cos(object.drawPos.x, temp0)113object.drawPos.x *= object.amplitude114object.drawPos.x <<= 7115object.drawPos.x += object.xpos116117Sin(object.drawPos.y, temp0)118object.drawPos.y *= object.amplitude119object.drawPos.y <<= 7120object.drawPos.y += object.ypos121122temp0 = object.xpos123temp1 = object.ypos124object.xpos = object.drawPos.x125object.ypos = object.drawPos.y126127foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)128BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)129if checkResult == true130CallFunction(Player_Hit)131end if132next133134object.xpos = temp0135object.ypos = temp1136end event137138139event ObjectDraw140DrawSprite(0)141142temp0 = 0143temp1 = 16144temp4 = object.spinAngle145temp4 >>= 8146while temp0 < object.length147Cos(temp2, temp4)148temp2 *= temp1149temp2 <<= 7150temp2 += object.xpos151Sin(temp3, temp4)152temp3 *= temp1153temp3 <<= 7154temp3 += object.ypos155DrawSpriteXY(1, temp2, temp3)156temp0++157temp1 += 16158loop159160temp1 -= 8161DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)162end event163164165event ObjectStartup166LoadSpriteSheet("LZ/Objects.gif")167SpriteFrame(-8, -8, 16, 16, 84, 173)168SpriteFrame(-8, -8, 16, 16, 101, 173)169SpriteFrame(-16, -16, 32, 32, 84, 190)170171foreach (TypeName[Rotating Spike], arrayPos0, ALL_ENTITIES)172object[arrayPos0].spinAngle = object[arrayPos0].direction173object[arrayPos0].spinAngle <<= 15174object[arrayPos0].direction = FLIP_NONE // this object doesn't really use dir for anything btw175176object[arrayPos0].spinSpeed = object[arrayPos0].propertyValue177object[arrayPos0].spinSpeed &= 0xF0178if object[arrayPos0].spinSpeed >= 0x80179object[arrayPos0].spinSpeed -= 0x100180end if181object[arrayPos0].spinSpeed <<= 4182183object[arrayPos0].length = object[arrayPos0].propertyValue184object[arrayPos0].length &= 15185object[arrayPos0].amplitude = object[arrayPos0].length186object[arrayPos0].amplitude <<= 4187next188189temp0 = 0190RotatingSpike_startDebugID = DebugMode_ObjCount191RotatingSpike_startDebugID--192while temp0 < 4193SetTableValue(TypeName[Rotating Spike], DebugMode_ObjCount, DebugMode_TypesTable)194SetTableValue(RotatingSpike_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)195SetTableValue(RotatingSpike_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)196DebugMode_ObjCount++197temp0++198loop199end event200201202// ========================203// Editor Events204// ========================205206event RSDKEdit207if editor.returnVariable == true208switch editor.variableID209case EDIT_VAR_PROPVAL // property value210checkResult = object.propertyValue211break212213// TODO: these following two, aren't they the same?214case 0 // spinSpeed215checkResult = object.propertyValue216checkResult >>= 4217checkResult &= 0x0F218break219220case 1 // length221checkResult = object.propertyValue222checkResult &= 0xF0223break224225end switch226else227switch editor.variableID228case EDIT_VAR_PROPVAL // property value229object.propertyValue = editor.variableValue230break231232case 0 // spinSpeed233editor.variableValue &= 0x0F234235object.propertyValue &= 0xF0236object.propertyValue |= editor.variableValue237break238239case 1 // length240editor.variableValue &= 0x0F241editor.variableValue <<= 4242243object.propertyValue &= 0x0F244object.propertyValue |= editor.variableValue245break246247end switch248end if249end event250251252event RSDKDraw253object.spinAngle = object.direction254object.spinAngle <<= 15255256object.length = object.propertyValue257object.length &= 15258object.amplitude = object.length259object.amplitude <<= 4260261temp0 = object.spinAngle262temp0 >>= 8263264Cos(object.drawPos.x, temp0)265object.drawPos.x *= object.amplitude266object.drawPos.x <<= 7267object.drawPos.x += object.xpos268269Sin(object.drawPos.y, temp0)270object.drawPos.y *= object.amplitude271object.drawPos.y <<= 7272object.drawPos.y += object.ypos273274DrawSprite(0)275276temp0 = 0277temp1 = 16278temp4 = object.spinAngle279temp4 >>= 8280while temp0 < object.length281Cos(temp2, temp4)282temp2 *= temp1283temp2 <<= 7284temp2 += object.xpos285286Sin(temp3, temp4)287temp3 *= temp1288temp3 <<= 7289temp3 += object.ypos290291DrawSpriteXY(1, temp2, temp3)292temp0++293temp1 += 16294loop295296temp1 -= 8297DrawSpriteXY(2, object.drawPos.x, object.drawPos.y)298end event299300301event RSDKLoad302LoadSpriteSheet("LZ/Objects.gif")303SpriteFrame(-8, -8, 16, 16, 84, 173)304SpriteFrame(-8, -8, 16, 16, 101, 173)305SpriteFrame(-16, -16, 32, 32, 84, 190)306307AddEditorVariable("spinSpeed")308SetActiveVariable("spinSpeed")309310AddEditorVariable("length")311SetActiveVariable("length")312313// TODO: looks like val0 (a pre-set angle) is a thing too? found one in m003314// that's just a 1 though, so maybe not..?315end event316317318