Path: blob/master/Sonic 1/Scripts/Animals/Picky.txt
1480 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Picky Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.delay1213private alias object.value0 : object.timer // its this in ANIMAL_WAIT14private alias object.value0 : object.bounceDir // its this in every other state15private alias object.value1 : object.randomizeDir1617private alias 0 : ANIMAL_WAIT18private alias 1 : ANIMAL_FALL19private alias 2 : ANIMAL_BOUNCING_PLACED20private alias 3 : ANIMAL_BOUNCING_FIXED21private alias 4 : ANIMAL_BOUNCING_FOLLOW22private alias 5 : ANIMAL_BOUNCING_FREE2324private alias 0x1C000 : ANIMAL_XVEL25private alias -0x30000 : ANIMAL_YVEL2627// Player Aliases28private alias object.xpos : player.xpos2930// Path ID Aliases31private alias 0 : PATH_A323334// ========================35// Function Declarations36// ========================3738reserve function Picky_DebugDraw39reserve function Picky_DebugSpawn404142// ========================43// Function Definitions44// ========================4546private function Picky_DebugDraw47DrawSprite(2)48end function495051private function Picky_DebugSpawn52CreateTempObject(TypeName[Picky], 0, object.xpos, object.ypos)5354GetBit(temp0, object.direction, 0)55if temp0 == FACING_RIGHT56object[tempObjectPos].state = ANIMAL_BOUNCING_FIXED57object[tempObjectPos].xvel = ANIMAL_XVEL58object[tempObjectPos].yvel = ANIMAL_YVEL5960Rand(checkResult, 32)61if checkResult < 1662object[tempObjectPos].direction = FACING_LEFT63FlipSign(object[tempObjectPos].xvel)64end if65else66object[tempObjectPos].state = ANIMAL_BOUNCING_FOLLOW67end if68end function697071// ========================72// Events73// ========================7475event ObjectUpdate76switch object.state77case ANIMAL_WAIT78if object.timer < object.delay79object.timer++80else81object.xvel = ANIMAL_XVEL8283if object.randomizeDir == true84object.drawOrder = 48586Rand(checkResult, 32)87if checkResult < 1688object.direction = FACING_LEFT89FlipSign(object.xvel)90end if91else92object.direction = FACING_LEFT93FlipSign(object.xvel)94end if9596object.yvel = -0x4000097object.state++98end if99break100101case ANIMAL_FALL102object.ypos += object.yvel103object.yvel += 0x3800104105if object.yvel > 0106ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)107if checkResult == true108object.yvel = ANIMAL_YVEL109object.state++110end if111end if112break113114case ANIMAL_BOUNCING_FOLLOW115if player[0].xpos < object.xpos116object.direction = FACING_LEFT117else118object.direction = FACING_RIGHT119end if120// [Fallthrough]121case ANIMAL_BOUNCING_PLACED122case ANIMAL_BOUNCING_FIXED123case ANIMAL_BOUNCING_FREE124object.xpos += object.xvel125object.ypos += object.yvel126object.yvel += 0x3800127128if object.yvel > 0129ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)130if checkResult == true131if object.state == ANIMAL_BOUNCING_FIXED132if object.bounceDir == FACING_LEFT133FlipSign(object.xvel)134object.direction ^= FACING_LEFT135end if136137object.bounceDir ^= FACING_LEFT138end if139140object.yvel = ANIMAL_YVEL141end if142end if143break144145end switch146147if object.state < ANIMAL_BOUNCING_FIXED148if object.outOfBounds == true149object.type = TypeName[Blank Object]150end if151end if152end event153154155event ObjectDraw156switch object.state157case ANIMAL_WAIT158case ANIMAL_FALL159DrawSprite(2)160break161162case ANIMAL_BOUNCING_PLACED163case ANIMAL_BOUNCING_FIXED164case ANIMAL_BOUNCING_FOLLOW165case ANIMAL_BOUNCING_FREE166if object.yvel < 0167DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)168else169DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)170end if171break172173end switch174end event175176177event ObjectStartup178LoadSpriteSheet("Global/Items2.gif")179SpriteFrame(-12, -8, 24, 15, 1, 232)180SpriteFrame(-12, -8, 24, 15, 1, 216)181SpriteFrame(-7, -12, 16, 24, 66, 231)182183foreach (TypeName[Picky], arrayPos0, ALL_ENTITIES)184if object[arrayPos0].propertyValue == 1185object[arrayPos0].state = ANIMAL_BOUNCING_FIXED186object[arrayPos0].xvel = ANIMAL_XVEL187object[arrayPos0].yvel = ANIMAL_YVEL188189Rand(checkResult, 32)190if checkResult < 16191object[arrayPos0].direction = FACING_LEFT192FlipSign(object[arrayPos0].xvel)193end if194else195if object[arrayPos0].propertyValue == 2196object[arrayPos0].state = ANIMAL_BOUNCING_FOLLOW197end if198199if object[arrayPos0].propertyValue == 3200object[arrayPos0].state = ANIMAL_BOUNCING_FREE201object[arrayPos0].xvel = ANIMAL_XVEL202FlipSign(object[arrayPos0].xvel)203object[arrayPos0].direction = FACING_LEFT204end if205end if206207object[arrayPos0].propertyValue = 0208next209210SetTableValue(TypeName[Picky], DebugMode_ObjCount, DebugMode_TypesTable)211SetTableValue(Picky_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)212SetTableValue(Picky_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)213DebugMode_ObjCount++214end event215216217// ========================218// Editor Events219// ========================220221event RSDKEdit222if editor.returnVariable == true223switch editor.variableID224case EDIT_VAR_PROPVAL // property value225checkResult = object.propertyValue226break227228case 0 // behaviour229checkResult = object.propertyValue230break231232end switch233else234switch editor.variableID235case EDIT_VAR_PROPVAL // property value236object.propertyValue = editor.variableValue237break238239case 0 // behaviour240object.propertyValue = editor.variableValue241break242243end switch244end if245end event246247248event RSDKDraw249DrawSprite(0)250end event251252253event RSDKLoad254LoadSpriteSheet("Global/Items2.gif")255SpriteFrame(-7, -12, 16, 24, 66, 231)256257AddEditorVariable("behavior")258SetActiveVariable("behavior")259AddEnumVariable("Placed", 0)260AddEnumVariable("Fixed", 1)261AddEnumVariable("Follow", 2)262AddEnumVariable("Free", 3)263end event264265266