// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Red Spring Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------
//-------Aliases-------//
private alias 15 : TYPE_REDSPRING
// Function declarations
reserve function RedSpring_DebugDraw
reserve function RedSpring_DebugSpawn
// Static Values
public value RedSpring_value26 = 0;
// Tables
function RedSpring_DebugDraw
temp0 = object[0].value17
temp0 -= RedSpring_value26
DrawSprite(temp0)
temp0 += 4
DrawSprite(temp0)
end function
function RedSpring_DebugSpawn
temp0 = object[0].value17
temp0 -= RedSpring_value26
CreateTempObject(TypeName[Red Spring], temp0, object.xpos, object.ypos)
end function
event ObjectMain
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
switch object.propertyValue
case 0
temp0 = object.value1
if object[currentPlayer].gravity == GRAVITY_AIR
temp0 = 1
end if
if object[currentPlayer].collisionMode > CMODE_FLOOR
if object[currentPlayer].yvel < 0
temp0 = 1
end if
end if
if temp0 == 0
BoxCollisionTest(C_BOX, object.entityPos, -14, -8, 14, 8,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -10, 14, -
6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object[currentPlayer].value10 = ANI_WALKING
if object[currentPlayer].animation == ANI_RUNNING
object[currentPlayer].value10 = ANI_RUNNING
end if
if object[currentPlayer].animation == ANI_PEELOUT
object[currentPlayer].value10 = ANI_PEELOUT
end if
object.value0 = 1
object[currentPlayer].state = PlayerObject_HandleAir
object[currentPlayer].tileCollisions = 1
object[currentPlayer].gravity = GRAVITY_AIR
object[currentPlayer].speed =
object[currentPlayer].xvel
object[currentPlayer].yvel = -0x100000
object[currentPlayer].animation = ANI_BOUNCING
object[currentPlayer].value1 = 0
PlaySfx(SfxName[Spring], 0)
end if
else
if object[currentPlayer].yvel >= 0
BoxCollisionTest(C_PLATFORM, object.entityPos, -14, -
8, 14, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -10,
14, -6, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object[currentPlayer].value10 = ANI_WALKING
if object[currentPlayer].animation ==
ANI_RUNNING
object[currentPlayer].value10 =
ANI_RUNNING
end if
if object[currentPlayer].animation ==
ANI_PEELOUT
object[currentPlayer].value10 =
ANI_PEELOUT
end if
object.value0 = 1
object[currentPlayer].state =
PlayerObject_HandleAir
object[currentPlayer].tileCollisions = 1
object[currentPlayer].gravity = GRAVITY_AIR
object[currentPlayer].speed =
object[currentPlayer].xvel
object[currentPlayer].yvel = -0x100000
object[currentPlayer].animation = ANI_BOUNCING
object[currentPlayer].value1 = 0
PlaySfx(SfxName[Spring], 0)
end if
end if
end if
break
case 1
BoxCollisionTest(C_BOX, object.entityPos, -8, -14, 8, 14,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if object[currentPlayer].gravity == GRAVITY_GROUND
BoxCollisionTest(C_TOUCH, object.entityPos, 6, -14, 11, 14,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object.value0 = 1
object[currentPlayer].tileCollisions = 1
object[currentPlayer].angle = 0
object[currentPlayer].speed = 0x100000
object[currentPlayer].collisionMode = CMODE_FLOOR
object[currentPlayer].pushing = 0
object[currentPlayer].direction = FLIP_NONE
object[currentPlayer].controlLock = 12
PlaySfx(SfxName[Spring], 0)
if object[currentPlayer].state !=
PlayerObject_HandleRoll
object[currentPlayer].state =
PlayerObject_HandleGround
object[currentPlayer].animation = ANI_RUNNING
end if
end if
else
if object.value7 == 1
BoxCollisionTest(C_TOUCH, object.entityPos, 6, -4,
11, 4, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object.value0 = 1
object[currentPlayer].tileCollisions = 1
object[currentPlayer].angle = 0
object[currentPlayer].speed = 0x100000
object[currentPlayer].yvel = 0
object[currentPlayer].collisionMode =
CMODE_FLOOR
object[currentPlayer].pushing = 0
object[currentPlayer].direction = FLIP_NONE
object[currentPlayer].controlLock = 12
PlaySfx(SfxName[Spring], 0)
if object[currentPlayer].state !=
PlayerObject_RollingJump
object[currentPlayer].animation =
ANI_BOUNCING
if object[currentPlayer].animation !=
ANI_JUMPING
object[currentPlayer].animation =
ANI_RUNNING
end if
object.animationSpeed = object.speed
object[currentPlayer].animationSpeed *=
80
object[currentPlayer].animationSpeed /=
0x60000
end if
end if
end if
end if
break
case 2
BoxCollisionTest(C_BOX, object.entityPos, -8, -14, 8, 14,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if object[currentPlayer].gravity == GRAVITY_GROUND
BoxCollisionTest(C_TOUCH, object.entityPos, -10, -14, -6,
14, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object.value0 = 1
object[currentPlayer].tileCollisions = 1
object[currentPlayer].speed = -0x100000
object[currentPlayer].collisionMode = CMODE_FLOOR
object[currentPlayer].pushing = 0
object[currentPlayer].direction = FLIP_X
object[currentPlayer].controlLock = 15
PlaySfx(SfxName[Spring], 0)
if object[currentPlayer].state !=
PlayerObject_HandleRoll
object[currentPlayer].state =
PlayerObject_HandleGround
object[currentPlayer].animation = ANI_RUNNING
end if
end if
else
if object.value7 == 1
BoxCollisionTest(C_TOUCH, object.entityPos, -10, -14,
-6, 14, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
object.value0 = 1
object[currentPlayer].tileCollisions = 1
object[currentPlayer].speed = -0x100000
object[currentPlayer].yvel = 0
object[currentPlayer].collisionMode =
CMODE_FLOOR
object[currentPlayer].pushing = 0
object[currentPlayer].direction = FLIP_X
object[currentPlayer].controlLock = 15
PlaySfx(SfxName[Spring], 0)
if object[currentPlayer].state !=
PlayerObject_RollingJump
object[currentPlayer].animation =
ANI_BOUNCING
if object[currentPlayer].animation !=
ANI_JUMPING
object[currentPlayer].animation =
ANI_RUNNING
end if
object.animationSpeed = object.speed
FlipSign(object[currentPlayer].animationSpeed)
object[currentPlayer].animationSpeed *=
80
object[currentPlayer].animationSpeed /=
0x60000
end if
end if
end if
end if
break
case 3
BoxCollisionTest(C_BOX, object.entityPos, -14, -8, 14, 8,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if object[currentPlayer].yvel <= 0
BoxCollisionTest(C_TOUCH, object.entityPos, -14, 6, 14, 10,
currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
if checkResult == 1
if object[currentPlayer].collisionMode == CMODE_ROOF
FlipSign(object[currentPlayer].speed)
FlipSign(object[currentPlayer].xvel)
end if
object.value0 = 1
object[currentPlayer].state = PlayerObject_HandleAir
object[currentPlayer].tileCollisions = 1
object[currentPlayer].gravity = GRAVITY_AIR
object[currentPlayer].speed =
object[currentPlayer].xvel
object[currentPlayer].yvel = 0x100000
object[currentPlayer].value1 = 0
PlaySfx(SfxName[Spring], 0)
end if
end if
break
end switch
next
end event
event ObjectDraw
if object.value0 == 0
temp1 = object.propertyValue
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
temp1 += 4
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
else
switch object.value0
case 2
case 3
temp1 = object.propertyValue
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
temp1 += 4
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
break
case 1
temp1 = object.propertyValue
temp1 += 8
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
break
case 4
case 5
case 6
case 7
case 8
case 9
temp1 = object.propertyValue
temp1 += 12
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
temp1 += 4
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
break
end switch
object.value0++
if object.value0 >= 10
object.value0 = 0
end if
end if
end event
event ObjectStartup
LoadSpriteSheet("Global/Items.gif")
arrayPos0 = 32
while arrayPos0 < 0x420
if object[arrayPos0].type == TypeName[Red Spring]
if object[arrayPos0].propertyValue > 3
object[arrayPos0].propertyValue -= 4
object[arrayPos0].value7 = 1
end if
if object[arrayPos0].propertyValue > 5
object[arrayPos0].direction = FLIP_Y
end if
end if
arrayPos0++
loop
SpriteFrame(-16, 0, 32, 8, 84, 9)
SpriteFrame(-8, -16, 8, 32, 141, 26)
SpriteFrame(0, -16, 8, 32, 141, 59)
SpriteFrame(-16, -8, 32, 8, 150, 101)
SpriteFrame(-16, -8, 32, 8, 84, 1)
SpriteFrame(0, -16, 8, 32, 149, 26)
SpriteFrame(-8, -16, 8, 32, 133, 59)
SpriteFrame(-16, 0, 32, 8, 150, 109)
SpriteFrame(-16, 0, 32, 8, 84, 1)
SpriteFrame(-8, -16, 8, 32, 149, 26)
SpriteFrame(0, -16, 8, 32, 133, 59)
SpriteFrame(-16, -8, 32, 8, 150, 109)
SpriteFrame(-16, -16, 32, 24, 117, 1)
SpriteFrame(-8, -16, 24, 32, 158, 26)
SpriteFrame(-16, -16, 24, 32, 158, 59)
SpriteFrame(-16, -8, 32, 24, 150, 1)
SpriteFrame(-16, -24, 32, 8, 84, 1)
SpriteFrame(16, -16, 8, 32, 149, 26)
SpriteFrame(-24, -16, 8, 32, 133, 59)
SpriteFrame(-16, 16, 32, 8, 150, 109)
temp0 = 0
RedSpring_value26 = DebugMode_ObjCount
while temp0 < 4
SetTableValue(TypeName[Red Spring], DebugMode_ObjCount,
DebugMode_TypesTable)
SetTableValue(RedSpring_DebugDraw, DebugMode_ObjCount,
DebugMode_DrawTable)
SetTableValue(RedSpring_DebugSpawn, DebugMode_ObjCount,
DebugMode_SpawnTable)
DebugMode_ObjCount++
temp0++
loop
end event
event RSDKDraw
temp1 = object.propertyValue
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
temp1 += 4
DrawSpriteFX(temp1, FX_FLIP, object.xpos, object.ypos)
end event
event RSDKLoad
LoadSpriteSheet("Global/Items.gif")
SpriteFrame(-16, 0, 32, 8, 84, 9)
SpriteFrame(-8, -16, 8, 32, 141, 26)
SpriteFrame(0, -16, 8, 32, 141, 59)
SpriteFrame(-16, -8, 32, 8, 150, 101)
SpriteFrame(-16, -8, 32, 8, 84, 1)
SpriteFrame(0, -16, 8, 32, 149, 26)
SpriteFrame(-8, -16, 8, 32, 133, 59)
SpriteFrame(-16, 0, 32, 8, 150, 109)
SpriteFrame(-16, 0, 32, 8, 84, 1)
SpriteFrame(-8, -16, 8, 32, 149, 26)
SpriteFrame(0, -16, 8, 32, 133, 59)
SpriteFrame(-16, -8, 32, 8, 150, 109)
SpriteFrame(-16, -16, 32, 24, 117, 1)
SpriteFrame(-8, -16, 24, 32, 158, 26)
SpriteFrame(-16, -16, 24, 32, 158, 59)
SpriteFrame(-16, -8, 32, 24, 150, 1)
SpriteFrame(-16, -24, 32, 8, 84, 1)
SpriteFrame(16, -16, 8, 32, 149, 26)
SpriteFrame(-24, -16, 8, 32, 133, 59)
SpriteFrame(-16, 16, 32, 8, 150, 109)
end event