Path: blob/master/Sonic 2/Scripts/CNZ/VBlock.txt
1482 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.direction40if object[tempObjectPos].propertyValue == 041object[tempObjectPos].ypos -= 0x60000042else43object[tempObjectPos].ypos += 0x60000044end if45end function464748// ========================49// Events50// ========================5152event ObjectUpdate53temp6 = object.ypos54if object.ypos >= object.drawPos.y55object.yvel -= 0x40056else57object.yvel += 0x40058end if59object.ypos += object.yvel6061temp0 = object.ypos62temp6 &= 0xFFFF000063object.collisionOffset.y = object.ypos64object.collisionOffset.y &= 0xFFFF000065object.collisionOffset.y -= temp66667object.ypos = temp668foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)69BoxCollisionTest(C_SOLID2, object.entityPos, -32, -32, 32, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)70switch checkResult71case COL_TOP72player[currentPlayer].ypos += object.collisionOffset.y73break7475case COL_BOTTOM76if player[currentPlayer].gravity == GRAVITY_GROUND77if object.yvel > 078CallFunction(Player_Kill)79end if80end if81break8283end switch84next8586object.ypos = temp087end event888990event ObjectDraw91DrawSprite(0)92end event939495event ObjectStartup96LoadSpriteSheet("CNZ/Objects.gif")97SpriteFrame(-32, -32, 64, 64, 82, 34)9899foreach (TypeName[V Block], arrayPos0, ALL_ENTITIES)100object[arrayPos0].drawPos.y = object[arrayPos0].ypos101if object[arrayPos0].propertyValue == 0102object[arrayPos0].ypos -= 0x600000103else104object[arrayPos0].ypos += 0x600000105end if106next107108SetTableValue(TypeName[V Block], DebugMode_ObjCount, DebugMode_TypesTable)109SetTableValue(VBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)110SetTableValue(VBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)111DebugMode_ObjCount++112end event113114115// ========================116// Editor Events117// ========================118119event RSDKEdit120if editor.returnVariable == true121switch editor.variableID122case EDIT_VAR_PROPVAL // property value123checkResult = object.propertyValue124break125126case 0 // startDir127checkResult = object.propertyValue128break129130end switch131else132switch editor.variableID133case EDIT_VAR_PROPVAL // property value134object.propertyValue = editor.variableValue135break136137case 0 // startDir138object.propertyValue = editor.variableValue139break140141end switch142end if143end event144145146event RSDKDraw147DrawSprite(0)148end event149150151event RSDKLoad152LoadSpriteSheet("CNZ/Objects.gif")153SpriteFrame(-32, -32, 64, 64, 82, 34)154155// Some VBlocks have their dir FLIP_Y attr set in the scene, that's irrelevant though156AddEditorVariable("startDir")157SetActiveVariable("startDir")158AddEnumVariable("Down", 0)159AddEnumVariable("Up", 1)160end event161162163