Path: blob/master/Sonic 2/Scripts/HPZ/VBlock.txt
1479 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: V Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.drawPos.y12private alias object.value2 : object.collisionOffset.y1314// Player Aliases15private alias object.ypos : player.ypos16private alias object.gravity : player.gravity171819// ========================20// Function Declarations21// ========================2223reserve function VBlock_DebugDraw24reserve function VBlock_DebugSpawn252627// ========================28// Function Definitions29// ========================3031private function VBlock_DebugDraw32DrawSprite(0)33end function343536private function VBlock_DebugSpawn37CreateTempObject(TypeName[V Block], 0, object.xpos, object.ypos)38object[tempObjectPos].drawPos.y = object.ypos39object[tempObjectPos].propertyValue = object.direction40end function414243// ========================44// Events45// ========================4647event ObjectUpdate48temp7 = object.ypos4950GetTableValue(temp0, 12, StageSetup_oscillationTable)51if object.propertyValue == 152FlipSign(temp0)53temp0 += 0x400054else55temp0 -= 0x400056end if57temp0 <<= 85859object.ypos = object.drawPos.y60object.ypos -= temp061temp1 = object.ypos6263temp7 &= 0xFFFF000064object.collisionOffset.y = object.ypos65object.collisionOffset.y &= 0xFFFF000066object.collisionOffset.y -= temp76768object.ypos = temp76970foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)71BoxCollisionTest(C_SOLID2, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)72switch checkResult73case COL_TOP74player[currentPlayer].ypos += object.collisionOffset.y75break7677case COL_BOTTOM78if player[currentPlayer].gravity == GRAVITY_GROUND79if object.collisionOffset.y > 080CallFunction(Player_Kill)81end if82end if83break8485end switch86next8788object.ypos = temp189end event909192event ObjectDraw93DrawSprite(0)94end event959697event ObjectStartup98LoadSpriteSheet("HPZ/Objects.gif")99SpriteFrame(-32, -32, 64, 64, 353, 1)100101foreach (TypeName[V Block], arrayPos0, ALL_ENTITIES)102object[arrayPos0].drawPos.y = object[arrayPos0].ypos103next104105SetTableValue(TypeName[V Block], DebugMode_ObjCount, DebugMode_TypesTable)106SetTableValue(VBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)107SetTableValue(VBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)108DebugMode_ObjCount++109end event110111112// ========================113// Editor Events114// ========================115116event RSDKEdit117if editor.returnVariable == true118switch editor.variableID119case EDIT_VAR_PROPVAL // property value120checkResult = object.propertyValue121checkResult &= 1122break123124case 0 // startDir125checkResult = object.propertyValue126checkResult &= 1127break128129end switch130else131switch editor.variableID132case EDIT_VAR_PROPVAL // property value133object.propertyValue = editor.variableValue134object.propertyValue &= 1135break136137case 0 // startDir138object.propertyValue = editor.variableValue139object.propertyValue &= 1140break141142end switch143end if144end event145146147event RSDKDraw148DrawSprite(0)149end event150151152event RSDKLoad153LoadSpriteSheet("HPZ/Objects.gif")154SpriteFrame(-32, -32, 64, 64, 353, 1)155156AddEditorVariable("startDir")157SetActiveVariable("startDir")158AddEnumVariable("Up", 0)159AddEnumVariable("Down", 1)160end event161162163