Path: blob/master/Sonic 2/Scripts/DEZ/Eggman.txt
1483 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Eggman Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// Using DEZEggman as a prefix here because there's like 12 "Eggman" objects in the game so its less confusing this way8// (and this object is called "DEZ Eggman" in MBZ)910// ========================11// Aliases12// ========================1314private alias object.value0 : object.sweat.x15private alias object.value1 : object.sweat.y16private alias object.value2 : object.sweat.yvel17private alias object.value3 : object.sweat.visible18private alias object.value4 : object.sweat.timer1920private alias 0 : DEZEGGMAN_AWAITPLAYER21private alias 1 : DEZEGGMAN_GRIMACING22private alias 2 : DEZEGGMAN_RUNNING23private alias 3 : DEZEGGMAN_DERJUMP2425// Reserved object slots26private alias 0 : SLOT_PLAYER12728// One Way Door aliases29private alias object.state : oneWayDoor.isOpen303132// ========================33// Events34// ========================3536event ObjectUpdate37switch object.state38case DEZEGGMAN_AWAITPLAYER39oneWayDoor[-1].isOpen = false4041// Check to see if Sonic (or whoever P1 is) is approaching42BoxCollisionTest(C_TOUCH, object.entityPos, -92, -92, 0, 92, 0, 1, 1, 1, 1)43if checkResult == true44object.frame = 145object.state = DEZEGGMAN_GRIMACING46end if47break4849case DEZEGGMAN_GRIMACING50oneWayDoor[-1].isOpen = false51object.animationTimer++52if object.animationTimer >= 2453object.state = DEZEGGMAN_RUNNING54end if55break5657case DEZEGGMAN_RUNNING58if object[SLOT_PLAYER1].xpos < object[+1].xpos59oneWayDoor[+1].isOpen = true60end if6162// Constant speed of at least 2 pixels a frame63object.xpos += 0x200006465// Make sure to always stay a few steps ahead of that pesky hedgehog66temp0 = object.xpos67temp0 -= 0x50000068if object[SLOT_PLAYER1].xpos > temp069object.xpos = object[SLOT_PLAYER1].xpos70object.xpos += 0x50000071end if7273// Animate the skidaddling74object.animationTimer++75if object.animationTimer >= 676object.animationTimer = 077object.frame++78if object.frame > 479object.frame = 280end if81end if8283object.sweat.timer++84switch object.sweat.timer85case 186object.sweat.x = object.xpos87object.sweat.x -= 0x7000088object.sweat.y = object.ypos89object.sweat.y -= 0x18000090object.sweat.yvel = 091object.sweat.visible = true92break9394case 295case 396case 497case 598case 699case 7100case 8101object.sweat.x -= 0x10000102object.sweat.yvel += 0x1C00103object.sweat.y += object.sweat.yvel104break105106case 9107object.sweat.visible = false108break109110case 32111object.sweat.timer = 0112break113114end switch115116// Check if arrived at the Death Egg Robot yet117// (Object [+9] is DER)118temp0 = object[+9].xpos119temp0 -= object.xpos120if temp0 <= 0x2C0000121// Hop in to the Death Egg Robot122object.xpos = object[+9].xpos123object.xpos -= 0x2C0000124object.yvel = -0x20000125object.frame = 2126object.sweat.visible = false127object.state = DEZEGGMAN_DERJUMP128end if129break130131case DEZEGGMAN_DERJUMP132object.xpos += 0xA000133object.ypos += object.yvel134object.yvel += 0x1000135if object.ypos >= object[+9].ypos136// Robotnik's no longer visible at all, so start up the Death Egg Robot and make this object dissappear137PlaySfx(SfxName[Machine Move], false)138object[+9].state = 2139object.type = TypeName[Blank Object]140end if141break142143end switch144end event145146147event ObjectDraw148if object.sweat.visible == true149DrawSpriteXY(5, object.sweat.x, object.sweat.y)150end if151152DrawSprite(object.frame)153end event154155156event ObjectStartup157CheckCurrentStageFolder("Zone12")158if checkResult == true159LoadSpriteSheet("DEZ/Objects.gif")160161// 0 - Idle Frame162SpriteFrame(-16, -25, 32, 51, 1, 58)163164// 1 - Panic Frame165SpriteFrame(-16, -26, 32, 52, 34, 58)166167// 2-4 - Running Frames168SpriteFrame(-30, -27, 58, 43, 67, 58)169SpriteFrame(-30, -27, 46, 55, 126, 58)170SpriteFrame(-30, -27, 51, 52, 173, 58)171172// 5 - Sweat Frame173SpriteFrame(-5, -2, 12, 5, 256, 52)174175// 6-7 - Laughing Frames176// (I don't think these are ever actually used?)177SpriteFrame(-16, -26, 32, 52, 225, 58)178SpriteFrame(-16, -25, 32, 51, 258, 58)179else180LoadSpriteSheet("MBZ/Objects.gif")181182// 0 - Idle Frame183SpriteFrame(-16, -25, 32, 51, 513, 58)184185// 1 - Panic Frame186SpriteFrame(-16, -26, 32, 52, 546, 58)187188// 2-4 - Running Frames189SpriteFrame(-30, -27, 58, 43, 579, 58)190SpriteFrame(-30, -27, 46, 55, 638, 58)191SpriteFrame(-30, -27, 51, 52, 685, 58)192193// 5 - Sweat Frame194SpriteFrame(-5, -2, 12, 5, 768, 52)195196// 6-7 - Laughing Frames197// (I don't think these are ever actually used?)198SpriteFrame(-16, -26, 32, 52, 737, 58)199SpriteFrame(-16, -25, 32, 51, 770, 58)200end if201end event202203204// ========================205// Editor Events206// ========================207208event RSDKDraw209DrawSprite(0)210end event211212213event RSDKLoad214CheckCurrentStageFolder("Zone12")215if checkResult == true216LoadSpriteSheet("DEZ/Objects.gif")217SpriteFrame(-16, -25, 32, 51, 1, 58)218else219LoadSpriteSheet("MBZ/Objects.gif")220SpriteFrame(-16, -25, 32, 51, 513, 58)221end if222223SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")224end event225226227