Path: blob/master/Sonic 2/Scripts/CPZ/VPlatform.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: V Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.centerPos.y12private alias object.value1 : object.hitboxL13private alias object.value2 : object.hitboxR14private alias object.value3 : object.stoodPlayers1516// Player Aliases17private alias object.ypos : player.ypos1819private alias object.value17 : debugMode.currentSelection202122// ========================23// Function Declarations24// ========================2526reserve function VPlatform_DebugDraw27reserve function VPlatform_DebugSpawn282930// ========================31// Static Values32// ========================3334private value VPlatform_debugStartID = 0353637// ========================38// Function Definitions39// ========================4041private function VPlatform_DebugDraw42temp0 = debugMode[0].currentSelection43temp0 -= VPlatform_debugStartID44DrawSprite(temp0)45end function464748private function VPlatform_DebugSpawn49temp0 = debugMode[0].currentSelection50temp0 -= VPlatform_debugStartID51CreateTempObject(TypeName[V Platform], temp0, object.xpos, object.ypos)5253object[tempObjectPos].centerPos.y = object.ypos54object[tempObjectPos].direction = object.direction55if object[tempObjectPos].propertyValue == 056object[tempObjectPos].hitboxL = -3257object[tempObjectPos].hitboxR = 3258else59object[tempObjectPos].hitboxL = -2460object[tempObjectPos].hitboxR = 2461end if62end function636465// ========================66// Events67// ========================6869event ObjectUpdate70temp6 = object.ypos71GetTableValue(temp0, 14, StageSetup_oscillationTable)72if object.direction == FLIP_X73FlipSign(temp0)74temp0 += 0x800075end if76temp0 <<= 87778object.ypos = object.centerPos.y79object.ypos -= temp080temp6 &= 0xFFFF000081temp7 = object.ypos82temp7 &= 0xFFFF000083temp7 -= temp68485temp2 = 086foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)87GetBit(temp0, object.stoodPlayers, temp2)88if temp0 == true89player[currentPlayer].ypos += temp790end if9192SetBit(object.stoodPlayers, temp2, false)93BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitboxL, -16, object.hitboxR, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)94if checkResult == true95SetBit(object.stoodPlayers, temp2, true)96end if97temp2++98next99end event100101102event ObjectDraw103DrawSprite(object.propertyValue)104end event105106107event ObjectStartup108LoadSpriteSheet("CPZ/Objects.gif")109SpriteFrame(-32, -16, 64, 27, 136, 155) // Large Platform110SpriteFrame(-24, -16, 48, 26, 136, 183) // Small Platform111112foreach (TypeName[V Platform], arrayPos0, ALL_ENTITIES)113object[arrayPos0].centerPos.y = object[arrayPos0].ypos114if object[arrayPos0].propertyValue == 0115// Normal-sized platform116object[arrayPos0].hitboxL = -32117object[arrayPos0].hitboxR = 32118else119// Small-sized platform120object[arrayPos0].hitboxL = -24121object[arrayPos0].hitboxR = 24122end if123next124125temp0 = 0126VPlatform_debugStartID = DebugMode_ObjCount127while temp0 < 2128SetTableValue(TypeName[V Platform], DebugMode_ObjCount, DebugMode_TypesTable)129SetTableValue(VPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)130SetTableValue(VPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)131DebugMode_ObjCount++132temp0++133loop134end event135136137// ========================138// Editor Events139// ========================140141event RSDKEdit142if editor.returnVariable == true143switch editor.variableID144case EDIT_VAR_PROPVAL // property value145checkResult = object.propertyValue146break147148case 0 // type149checkResult = object.propertyValue150break151152end switch153else154switch editor.variableID155case EDIT_VAR_PROPVAL // property value156object.propertyValue = editor.variableValue157break158159case 0 // type160object.propertyValue = editor.variableValue161break162163end switch164end if165end event166167168event RSDKDraw169DrawSprite(object.propertyValue)170171if editor.showGizmos == true172// Draw arrows to indicate that this is a V platform173174editor.drawingOverlay = true175176temp0 = object.ypos177temp0 -= 0x320000178DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0, 224, 0)179temp0 = object.ypos180temp0 += 0x320000181DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0, 224, 0)182183editor.drawingOverlay = false184end if185end event186187188event RSDKLoad189LoadSpriteSheet("CPZ/Objects.gif")190SpriteFrame(-32, -16, 64, 27, 136, 155)191SpriteFrame(-24, -16, 48, 26, 136, 183)192193AddEditorVariable("type")194SetActiveVariable("type")195AddEnumVariable("Large", 0)196AddEnumVariable("Small", 1)197end event198199200