Path: blob/master/Sonic 1/Scripts/Enemies/NewtronFly.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 12// Script Description: Newtron Fly Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011private alias object.propertyValue : object.appearFrame1213private alias object.value1 : object.startPos.x14private alias object.value2 : object.startPos.y1516private alias 0 : NEWTRONFLY_WAITFORPLAYER17private alias 1 : NEWTRONFLY_APPEARING18private alias 2 : NEWTRONFLY_APPEARED19private alias 3 : NEWTRONFLY_MOVING2021private alias 0 : NEWTRONFLY_ANI_IDLE22private alias 1 : NEWTRONFLY_ANI_APPEAR23private alias 2 : NEWTRONFLY_ANI_MOVING2425// Player Aliases26private alias object.xpos : player.xpos27private alias object.value40 : player.hitboxLeft28private alias object.value38 : player.hitboxTop29private alias object.value41 : player.hitboxRight30private alias object.value39 : player.hitboxBottom3132// Path ID Aliases33private alias 0 : PATH_A343536// ========================37// Function Declarations38// ========================3940reserve function NewtronFly_DebugDraw41reserve function NewtronFly_DebugSpawn424344// ========================45// Function Definitions46// ========================4748private function NewtronFly_DebugDraw49DrawSprite(object.direction)50end function515253private function NewtronFly_DebugSpawn54CreateTempObject(TypeName[Newtron Fly], object.direction, object.xpos, object.ypos)55object[tempObjectPos].inkEffect = INK_ALPHA56object[tempObjectPos].alpha = 057object[tempObjectPos].startPos.x = object.xpos58object[tempObjectPos].startPos.y = object.ypos59end function606162// ========================63// Events64// ========================6566event ObjectUpdate67switch object.state68case NEWTRONFLY_WAITFORPLAYER69foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)70BoxCollisionTest(C_TOUCH, object.entityPos, -128, -64, 128, 64, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)71if checkResult == true72object.state = NEWTRONFLY_APPEARING73end if74next75break7677case NEWTRONFLY_APPEARING78object.priority = PRIORITY_ACTIVE79if object.alpha < 0xF880object.alpha += 481if player[0].xpos > object.xpos82object.appearFrame = FLIP_NONE83else84object.appearFrame = FLIP_X85end if86else87object.alpha = 0xFF88object.animation = NEWTRONFLY_ANI_APPEAR89if object.appearFrame == FLIP_NONE90object.xvel = 0x2000091else92object.xvel = -0x2000093end if94object.direction = object.appearFrame95object.state++96end if97break9899case NEWTRONFLY_APPEARED100object.ypos += object.yvel101object.yvel += 0x3800102ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)103if checkResult == true104object.yvel = 0105object.animationTimer = 0106object.animation = NEWTRONFLY_ANI_MOVING107object.state++108end if109break110111case NEWTRONFLY_MOVING112object.xpos += object.xvel113ObjectTileGrip(CSIDE_FLOOR, 0, 8, PATH_A)114break115116end switch117118if object.outOfBounds == true119temp0 = object.xpos120temp1 = object.ypos121object.xpos = object.startPos.x122object.ypos = object.startPos.y123if object.outOfBounds == true124object.yvel = 0125object.xpos = object.startPos.x126object.ypos = object.startPos.y127object.animation = NEWTRONFLY_ANI_IDLE128object.animationTimer = 0129object.priority = PRIORITY_BOUNDS130object.alpha = 0131object.state = NEWTRONFLY_WAITFORPLAYER132else133object.xpos = temp0134object.ypos = temp1135end if136end if137138foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)139switch object.state140default141case NEWTRONFLY_WAITFORPLAYER142case NEWTRONFLY_APPEARING143break144145case NEWTRONFLY_APPEARED146case NEWTRONFLY_MOVING147BoxCollisionTest(C_TOUCH, object.entityPos, -16, -8, 16, 8, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)148if checkResult == true149CallFunction(Player_BadnikBreak)150end if151break152153end switch154next155156switch object.animation157case NEWTRONFLY_ANI_IDLE158break159160case NEWTRONFLY_ANI_APPEAR161if object.animationTimer < 41162object.frame = object.animationTimer163object.frame /= 20164object.animationTimer++165end if166object.frame += 2167break168169case NEWTRONFLY_ANI_MOVING170object.frame = object.animationTimer171object.frame /= 3172object.frame += 5173object.animationTimer++174object.animationTimer %= 6175break176177end switch178end event179180181event ObjectDraw182switch object.animation183case NEWTRONFLY_ANI_IDLE184DrawSpriteFX(object.appearFrame, FX_INK, object.xpos, object.ypos)185break186187case NEWTRONFLY_ANI_APPEAR188DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)189break190191case NEWTRONFLY_ANI_MOVING192DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)193DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)194break195196end switch197end event198199200event ObjectStartup201CheckCurrentStageFolder("Zone01")202if checkResult == true203LoadSpriteSheet("GHZ/Objects2.gif")204SpriteFrame(-20, -20, 39, 39, 161, 1)205SpriteFrame(-19, -20, 39, 39, 201, 1)206SpriteFrame(-18, -20, 37, 35, 218, 41)207SpriteFrame(-15, -18, 36, 22, 1, 41)208SpriteFrame(-20, -16, 40, 16, 38, 41)209SpriteFrame(-28, -9, 8, 8, 79, 41)210SpriteFrame(-34, -10, 14, 8, 88, 41)211end if212213CheckCurrentStageFolder("Zone07")214if checkResult == true215LoadSpriteSheet("MBZ/Objects.gif")216SpriteFrame(-20, -20, 39, 39, 1, 124)217SpriteFrame(-19, -20, 39, 39, 41, 124)218SpriteFrame(-18, -20, 37, 35, 81, 128)219SpriteFrame(-15, -18, 36, 22, 1, 204)220SpriteFrame(-20, -16, 40, 16, 38, 204)221SpriteFrame(-28, -9, 8, 8, 79, 204)222SpriteFrame(-34, -10, 14, 8, 88, 204)223end if224225foreach (TypeName[Newtron Fly], arrayPos0, ALL_ENTITIES)226object[arrayPos0].startPos.x = object[arrayPos0].xpos227object[arrayPos0].startPos.y = object[arrayPos0].ypos228object[arrayPos0].inkEffect = INK_ALPHA229object[arrayPos0].alpha = 0230next231232SetTableValue(TypeName[Newtron Fly], DebugMode_ObjCount, DebugMode_TypesTable)233SetTableValue(NewtronFly_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)234SetTableValue(NewtronFly_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)235DebugMode_ObjCount++236end event237238239// ========================240// Editor Events241// ========================242243event RSDKDraw244DrawSprite(0)245end event246247248event RSDKLoad249CheckCurrentStageFolder("Zone07")250if checkResult == true251LoadSpriteSheet("MBZ/Objects.gif")252SpriteFrame(-20, -20, 39, 39, 1, 124)253else254LoadSpriteSheet("GHZ/Objects2.gif")255SpriteFrame(-20, -20, 39, 39, 161, 1)256end if257258// Not to be set from the editor259// It's set to 0 because that's how it was in the original game (the two Newtrons were the same obj type, behaviour was subtype)260SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")261262// TODO: double check that val1 isn't used by this object;263// it's set in the editor in m006264// also prop val goes up to two there (y-flip), is that normal?265end event266267268