Path: blob/master/Sonic 1/Scripts/Animals/Cucky.txt
1482 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Cucky 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 0x20000 : 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 Cucky_DebugDraw39reserve function Cucky_DebugSpawn404142// ========================43// Function Definitions44// ========================4546private function Cucky_DebugDraw47DrawSprite(2)48end function495051private function Cucky_DebugSpawn52CreateTempObject(TypeName[Cucky], 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 = 485Rand(checkResult, 32)86if checkResult < 1687object.direction = FACING_LEFT88FlipSign(object.xvel)89end if90else91object.direction = FACING_LEFT92FlipSign(object.xvel)93end if9495// Jump & then apply gravity96object.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 if143144object.frame = object.animationTimer145object.frame >>= 1146object.animationTimer++147object.animationTimer &= 3148break149150end switch151152if object.state < ANIMAL_BOUNCING_FIXED153if object.outOfBounds == true154object.type = TypeName[Blank Object]155end if156end if157end event158159160event ObjectDraw161switch object.state162case ANIMAL_WAIT163case ANIMAL_FALL164DrawSprite(2)165break166167case ANIMAL_BOUNCING_PLACED168case ANIMAL_BOUNCING_FIXED169case ANIMAL_BOUNCING_FOLLOW170case ANIMAL_BOUNCING_FREE171DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)172break173174end switch175end event176177178event ObjectStartup179LoadSpriteSheet("Global/Items.gif")180SpriteFrame(-8, -8, 16, 16, 174, 215)181SpriteFrame(-8, -8, 16, 16, 97, 227)182SpriteFrame(-7, -12, 15, 24, 207, 197)183184foreach (TypeName[Cucky], arrayPos0, ALL_ENTITIES)185if object[arrayPos0].propertyValue == 1186object[arrayPos0].state = ANIMAL_BOUNCING_FIXED187object[arrayPos0].xvel = ANIMAL_XVEL188object[arrayPos0].yvel = ANIMAL_YVEL189190Rand(checkResult, 32)191if checkResult < 16192object[arrayPos0].direction = FACING_LEFT193FlipSign(object[arrayPos0].xvel)194end if195else196if object[arrayPos0].propertyValue == 2197object[arrayPos0].state = ANIMAL_BOUNCING_FOLLOW198end if199200if object[arrayPos0].propertyValue == 3201object[arrayPos0].state = ANIMAL_BOUNCING_FREE202object[arrayPos0].xvel = ANIMAL_XVEL203FlipSign(object[arrayPos0].xvel)204object[arrayPos0].direction = FACING_LEFT205end if206end if207208object[arrayPos0].propertyValue = 0209next210211SetTableValue(TypeName[Cucky], DebugMode_ObjCount, DebugMode_TypesTable)212SetTableValue(Cucky_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)213SetTableValue(Cucky_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)214DebugMode_ObjCount++215end event216217218// ========================219// Editor Events220// ========================221222event RSDKEdit223if editor.returnVariable == true224switch editor.variableID225case EDIT_VAR_PROPVAL // property value226checkResult = object.propertyValue227break228229case 0 // behavior230checkResult = object.propertyValue231break232233end switch234else235switch editor.variableID236case EDIT_VAR_PROPVAL // property value237object.propertyValue = editor.variableValue238break239240case 0 // behavior241object.propertyValue = editor.variableValue242break243244end switch245end if246end event247248249event RSDKDraw250DrawSprite(0)251end event252253254event RSDKLoad255LoadSpriteSheet("Global/Items.gif")256SpriteFrame(-7, -12, 15, 24, 207, 197)257258AddEditorVariable("behavior")259SetActiveVariable("behavior")260AddEnumVariable("Placed", 0)261AddEnumVariable("Fixed", 1)262AddEnumVariable("Follow", 2)263AddEnumVariable("Free", 3)264end event265266267