Path: blob/master/Sonic 2/Scripts/WFZ/HPlatform.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: H Platform Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value0 : object.centerPos.x12private alias object.value1 : object.hitbox.left13private alias object.value2 : object.hitbox.right14private alias object.value3 : object.stoodPlayers1516// Player Aliases17private alias object.xpos : player.xpos1819private alias object.value17 : debugMode.currentSelection202122// ========================23// Function Declarations24// ========================2526reserve function HPlatform_DebugDraw27reserve function HPlatform_DebugSpawn2829// ========================30// Static Values31// ========================3233private value HPlatform_startDebugID = 0343536// ========================37// Function Definitions38// ========================3940private function HPlatform_DebugDraw41temp0 = debugMode[0].currentSelection42temp0 -= HPlatform_startDebugID43DrawSprite(temp0)44end function454647private function HPlatform_DebugSpawn48temp0 = debugMode[0].currentSelection49temp0 -= HPlatform_startDebugID50CreateTempObject(TypeName[H Platform], temp0, object.xpos, object.ypos)5152object[tempObjectPos].centerPos.x = object.xpos53object[tempObjectPos].direction = object.direction54if object[tempObjectPos].propertyValue == 055object[tempObjectPos].hitbox.left = -3256object[tempObjectPos].hitbox.right = 3257else58object[tempObjectPos].hitbox.left = -2459object[tempObjectPos].hitbox.right = 2460end if61end function626364// ========================65// Events66// ========================6768event ObjectUpdate69temp6 = object.xpos70GetTableValue(temp0, 6, StageSetup_oscillationTable)71if object.direction == FLIP_X72FlipSign(temp0)73temp0 += 0x600074end if75temp0 <<= 87677object.xpos = object.centerPos.x78object.xpos -= temp079temp6 &= 0xFFFF000080temp7 = object.xpos81temp7 &= 0xFFFF000082temp7 -= temp68384temp2 = 085foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)86GetBit(temp0, object.stoodPlayers, temp2)87if temp0 == true88player[currentPlayer].xpos += temp789end if9091SetBit(object.stoodPlayers, temp2, false)92BoxCollisionTest(C_PLATFORM, object.entityPos, object.hitbox.left, -16, object.hitbox.right, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)93if checkResult == true94SetBit(object.stoodPlayers, temp2, true)95end if96temp2++97next98end event99100101event ObjectDraw102DrawSprite(object.propertyValue)103end event104105106event ObjectStartup107LoadSpriteSheet("SCZ/Objects.gif")108SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0109SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1110111foreach (TypeName[H Platform], arrayPos0, ALL_ENTITIES)112object[arrayPos0].centerPos.x = object[arrayPos0].xpos113if object[arrayPos0].propertyValue == 0114object[arrayPos0].hitbox.left = -32115object[arrayPos0].hitbox.right = 32116else117object[arrayPos0].hitbox.left = -24118object[arrayPos0].hitbox.right = 24119end if120next121122temp0 = 0123HPlatform_startDebugID = DebugMode_ObjCount124while temp0 < 2125SetTableValue(TypeName[H Platform], DebugMode_ObjCount, DebugMode_TypesTable)126SetTableValue(HPlatform_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)127SetTableValue(HPlatform_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)128DebugMode_ObjCount++129temp0++130loop131end event132133134// ========================135// Editor Events136// ========================137138event RSDKEdit139if editor.returnVariable == true140switch editor.variableID141case EDIT_VAR_PROPVAL // property value142checkResult = object.propertyValue143break144145case 0 // type146checkResult = object.propertyValue147break148149end switch150else151switch editor.variableID152case EDIT_VAR_PROPVAL // property value153object.propertyValue = editor.variableValue154break155156case 0 // type157object.propertyValue = editor.variableValue158break159160end switch161end if162end event163164165event RSDKDraw166DrawSprite(object.propertyValue)167end event168169170event RSDKLoad171LoadSpriteSheet("SCZ/Objects.gif")172SpriteFrame(-24, -16, 48, 24, 381, 178) // Small Platform - #0173SpriteFrame(-32, -16, 64, 24, 1, 146) // Wide Platform - #1174175AddEditorVariable("type")176SetActiveVariable("type")177AddEnumVariable("Small Platform", 0)178AddEnumVariable("Wide Platform", 1)179end event180181182