Path: blob/master/Sonic 2/Scripts/Special/Ring.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Ring Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.localPos.x12private alias object.value2 : object.localPos.y13private alias object.value3 : object.localPos.z14private alias object.value4 : object.worldPos.x15private alias object.value5 : object.worldPos.y16private alias object.value6 : object.worldPos.z1718private alias object.value7 : object.shadowsEnabled19private alias object.value8 : object.localShadowPos.x20private alias object.value9 : object.localShadowPos.y21private alias object.value11 : object.worldShadowPos.x22private alias object.value12 : object.worldShadowPos.y23private alias object.value13 : object.worldShadowPos.z24private alias object.value14 : object.worldShadowPos.u2526// Halfpipe Aliases27private alias object.value13 : halfpipe.playerPos.z2829// Player Aliases30private alias object.value0 : player.rings31private alias object.value14 : player.localPos.z32private alias object.value15 : player.localPos.x33private alias object.value16 : player.localPos.y3435// Face Buffer Flag Aliases36private alias 5 : FACE_TEXTURED_C37private alias 6 : FACE_TEXTURED_C_BLEND383940// ========================41// Tables42// ========================4344private table Ring_vertexUTable4550, 83, 116, 149, 182, 215, 17, 5046end table4748private table Ring_vertexVTable4917, 17, 17, 17, 17, 17, 50, 5050end table515253// ========================54// Events55// ========================5657event ObjectUpdate58arrayPos0 = scene3D.vertexCount59arrayPos1 = scene3D.faceCount6061if object.shadowsEnabled == true62faceBuffer[arrayPos1].flag = FACE_TEXTURED_C_BLEND63faceBuffer[arrayPos1].a = arrayPos064vertexBuffer[arrayPos0].x = object.worldShadowPos.x65vertexBuffer[arrayPos0].y = object.worldShadowPos.y66vertexBuffer[arrayPos0].z = object.worldShadowPos.z67vertexBuffer[arrayPos0].u = object.worldShadowPos.u68vertexBuffer[arrayPos0].v = 5069arrayPos0++7071faceBuffer[arrayPos1].b = arrayPos072vertexBuffer[arrayPos0].x = object.worldShadowPos.x73vertexBuffer[arrayPos0].y = object.worldShadowPos.y74vertexBuffer[arrayPos0].z = object.worldShadowPos.z75temp0 = object[0].ypos76temp0 -= 0xE0000077object.scale = object.ypos78object.scale -= temp079if object.scale > 080object.scale >>= 1481object.scale += 0x40082else83object.scale = 0x40084end if85vertexBuffer[arrayPos0].u = object.scale86vertexBuffer[arrayPos0].v = object.scale87arrayPos0++8889faceBuffer[arrayPos1].c = arrayPos090vertexBuffer[arrayPos0].x = object.worldShadowPos.x91vertexBuffer[arrayPos0].y = object.worldShadowPos.y92vertexBuffer[arrayPos0].z = object.worldShadowPos.z93vertexBuffer[arrayPos0].u = 1794vertexBuffer[arrayPos0].v = 1695arrayPos0++9697faceBuffer[arrayPos1].d = arrayPos098vertexBuffer[arrayPos0].x = object.worldShadowPos.x99vertexBuffer[arrayPos0].y = object.worldShadowPos.y100vertexBuffer[arrayPos0].z = object.worldShadowPos.z101arrayPos0++102103arrayPos1++104scene3D.vertexCount += 4105scene3D.faceCount++106end if107108faceBuffer[arrayPos1].flag = FACE_TEXTURED_C109faceBuffer[arrayPos1].a = arrayPos0110vertexBuffer[arrayPos0].x = object.worldPos.x111vertexBuffer[arrayPos0].y = object.worldPos.y112vertexBuffer[arrayPos0].z = object.worldPos.z113GetTableValue(vertexBuffer[arrayPos0].u, ringFrame, Ring_vertexUTable)114GetTableValue(vertexBuffer[arrayPos0].v, ringFrame, Ring_vertexVTable)115arrayPos0++116117faceBuffer[arrayPos1].b = arrayPos0118vertexBuffer[arrayPos0].x = object.worldPos.x119vertexBuffer[arrayPos0].y = object.worldPos.y120vertexBuffer[arrayPos0].z = object.worldPos.z121122temp0 = object[0].ypos123temp0 -= 0xE00000124object.scale = object.ypos125object.scale -= temp0126if object.scale > 0127object.scale >>= 14128object.scale += 0x400129else130object.scale = 0x400131end if132vertexBuffer[arrayPos0].u = object.scale133vertexBuffer[arrayPos0].v = object.scale134arrayPos0++135136faceBuffer[arrayPos1].c = arrayPos0137vertexBuffer[arrayPos0].x = object.worldPos.x138vertexBuffer[arrayPos0].y = object.worldPos.y139vertexBuffer[arrayPos0].z = object.worldPos.z140vertexBuffer[arrayPos0].u = 16141vertexBuffer[arrayPos0].v = 16142arrayPos0++143144faceBuffer[arrayPos1].d = arrayPos0145vertexBuffer[arrayPos0].x = object.worldPos.x146vertexBuffer[arrayPos0].y = object.worldPos.y147vertexBuffer[arrayPos0].z = object.worldPos.z148scene3D.vertexCount += 4149scene3D.faceCount++150151if object.localPos.z < halfpipe[0].playerPos.z152object.type = TypeName[Blank Object]153else154foreach (TypeName[Player Object], currentPlayer, ACTIVE_ENTITIES)155temp1 = object.localPos.z156temp1 -= 0x20000157temp2 = object.localPos.z158temp2 += 0x20000159160if player[currentPlayer].localPos.z > temp1161if player[currentPlayer].localPos.z < temp2162temp0 = player[currentPlayer].localPos.x163temp0 -= object.localPos.x164temp1 = temp0165temp1 *= temp0166temp0 = player[currentPlayer].localPos.y167temp0 -= object.localPos.y168temp2 = temp0169temp2 *= temp0170temp1 += temp2171172if temp1 < 0xC40000173if options.vsMode == false174player[currentPlayer].rings++175else176if ReceiveValue > -1177if currentPlayer == 2178player[currentPlayer].rings++179end if180else181player[currentPlayer].rings++182end if183end if184185object.type = TypeName[Ring Sparkle]186object.animationTimer = 0187object.frame = 0188if ringPan == 0189PlaySfx(SfxName[Ring L], false)190SetSfxAttributes(SfxName[Ring L], -1, -100)191ringPan = 1192else193PlaySfx(SfxName[Ring R], false)194SetSfxAttributes(SfxName[Ring R], -1, 100)195ringPan = 0196end if197end if198end if199end if200next201end if202end event203204205event ObjectStartup206LoadSpriteSheet("Special/Objects.gif")207208foreach (TypeName[Ring], arrayPos0, ALL_ENTITIES)209object[arrayPos0].angle = object[arrayPos0].ixpos210object[arrayPos0].angle -= 448211object[arrayPos0].angle &= 0x1FF212213Sin(object[arrayPos0].localPos.x, object[arrayPos0].angle)214object[arrayPos0].localPos.x *= -48215object[arrayPos0].localPos.x >>= 1216217Cos(object[arrayPos0].localPos.y, object[arrayPos0].angle)218object[arrayPos0].localPos.y *= -48219object[arrayPos0].localPos.y >>= 1220221if object[arrayPos0].localPos.y < -0x400222object[arrayPos0].shadowsEnabled = true223224Sin(object[arrayPos0].localShadowPos.x, object[arrayPos0].angle)225object[arrayPos0].localShadowPos.x *= -60226object[arrayPos0].localShadowPos.x >>= 1227228Cos(object[arrayPos0].localShadowPos.y, object[arrayPos0].angle)229object[arrayPos0].localShadowPos.y *= -60230object[arrayPos0].localShadowPos.y >>= 1231232object[arrayPos0].worldShadowPos.u = 116233if object[arrayPos0].angle > 32234if object[arrayPos0].angle < 480235if object[arrayPos0].angle < 256236object[arrayPos0].worldShadowPos.u = 149237else238object[arrayPos0].worldShadowPos.u = 182239end if240end if241end if242end if243next244end event245246247// ========================248// Editor Events249// ========================250251event RSDKDraw252DrawSprite(0)253end event254255256event RSDKLoad257LoadSpriteSheet("Special/Objects.gif")258SpriteFrame(-8, -8, 16, 16, 233, 0)259260SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")261end event262263264