Path: blob/master/Sonic 2/Scripts/CNZ/HBlock.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: H Block Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.value1 : object.drawPos.x12private alias object.value2 : object.collisionOffset.x1314// Player Aliases15private alias object.state : player.state16private alias object.xpos : player.xpos17private alias object.animation : player.animation1819private alias object.value1 : player.timer202122// ========================23// Function Declarations24// ========================2526reserve function HBlock_DebugDraw27reserve function HBlock_DebugSpawn282930// ========================31// Function Definitions32// ========================3334private function HBlock_DebugDraw35DrawSprite(0)36end function373839private function HBlock_DebugSpawn40CreateTempObject(TypeName[H Block], 0, object.xpos, object.ypos)41object[tempObjectPos].drawPos.x = object.xpos42object[tempObjectPos].propertyValue = object.direction43if object[tempObjectPos].propertyValue == FACING_RIGHT44object[tempObjectPos].xpos -= 0x60000045else46object[tempObjectPos].xpos += 0x60000047end if48end function495051// ========================52// Events53// ========================5455event ObjectUpdate56temp6 = object.xpos57if object.xpos >= object.drawPos.x58object.xvel -= 0x40059else60object.xvel += 0x40061end if62object.xpos += object.xvel6364temp0 = object.xpos65temp6 &= 0xFFFF000066object.collisionOffset.x = object.xpos67object.collisionOffset.x &= 0xFFFF000068object.collisionOffset.x -= temp66970object.xpos = temp67172foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)73BoxCollisionTest(C_SOLID, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)74switch checkResult75case COL_TOP76player[currentPlayer].xpos += object.collisionOffset.x77break7879case COL_LEFT80case COL_RIGHT81if player[currentPlayer].state == Player_State_Climb82player[currentPlayer].timer = 083player[currentPlayer].animation = ANI_GLIDING_DROP84player[currentPlayer].state = Player_State_GlideDrop85end if86break8788end switch89next9091object.xpos = temp092end event939495event ObjectDraw96DrawSprite(0)97end event9899100event ObjectStartup101LoadSpriteSheet("CNZ/Objects.gif")102SpriteFrame(-32, -32, 64, 64, 82, 34)103foreach (TypeName[H Block], arrayPos0, ALL_ENTITIES)104object[arrayPos0].drawPos.x = object[arrayPos0].xpos105if object[arrayPos0].propertyValue == 0106object[arrayPos0].xpos -= 0x600000107else108object[arrayPos0].xpos += 0x600000109end if110next111SetTableValue(TypeName[H Block], DebugMode_ObjCount, DebugMode_TypesTable)112SetTableValue(HBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)113SetTableValue(HBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)114DebugMode_ObjCount++115end event116117118// ========================119// Editor Events120// ========================121122event RSDKEdit123if editor.returnVariable == true124switch editor.variableID125case EDIT_VAR_PROPVAL // property value126checkResult = object.propertyValue127break128129case 0 // startDir130checkResult = object.propertyValue131break132133end switch134else135switch editor.variableID136case EDIT_VAR_PROPVAL // property value137object.propertyValue = editor.variableValue138break139140case 0 // startDir141object.propertyValue = editor.variableValue142break143144end switch145end if146end event147148149event RSDKDraw150DrawSprite(0)151end event152153154event RSDKLoad155LoadSpriteSheet("CNZ/Objects.gif")156SpriteFrame(-32, -32, 64, 64, 82, 34)157158// Some HBlocks have their dir FLIP_X attr set in the scene, that's irrelevant though159AddEditorVariable("startDir")160SetActiveVariable("startDir")161AddEnumVariable("Right", 0)162AddEnumVariable("Left", 1)163end event164165166