0% found this document useful (0 votes)
12 views8 pages

Sonic Player Object Script Guide

The document outlines the player object script for the Sonic 1/Sonic 2 RSDK project, detailing various functions and variables related to player control, movement, and interactions. It includes function declarations for processing player actions, handling animations, and managing player states. The script also specifies event handling for object initialization, drawing, and loading of sprites.

Uploaded by

mundoverajo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Sonic Player Object Script Guide

The document outlines the player object script for the Sonic 1/Sonic 2 RSDK project, detailing various functions and variables related to player control, movement, and interactions. It includes function declarations for processing player actions, handling animations, and managing player states. The script also specifies event handling for object initialization, drawing, and loading of sprites.

Uploaded by

mundoverajo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// ----------------------------------

// RSDK Project: Sonic 1/Sonic 2


// Script Description: Player Object Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 1 : TYPE_PLAYEROBJECT
public alias 256 : GROUP_PLAYERS
public alias 257 : GROUP_BLOCKS
public alias 65536 : HITBOX_AUTO
public alias arrayPos6 : currentPlayer
public alias arrayPos7 : playerCount

public alias saveRAM[257] : [Link]


public alias saveRAM[258] : [Link]
public alias saveRAM[259] : [Link]
public alias saveRAM[260] : [Link]
public alias saveRAM[261] : [Link]
public alias saveRAM[262] : [Link]
public alias saveRAM[263] : [Link]
public alias saveRAM[264] : [Link]
public alias saveRAM[265] : [Link]
public alias saveRAM[266] : [Link]
public alias saveRAM[267] : [Link]
public alias saveRAM[268] : [Link]
public alias saveRAM[269] : [Link]
public alias saveRAM[270] : [Link]
public alias saveRAM[271] : [Link]
public alias saveRAM[272] : [Link]
public alias saveRAM[273] : [Link]
public alias saveRAM[274] : [Link]
public alias saveRAM[275] : [Link]
public alias saveRAM[276] : [Link]
public alias saveRAM[277] : [Link]
public alias saveRAM[280] : [Link]
public alias saveRAM[281] : [Link]
public alias saveRAM[282] : [Link]
public alias saveRAM[283] : [Link]
public alias saveRAM[299] : [Link]

// Function declarations
reserve function PlayerObject_ProcessPlayer
reserve function PlayerObject_Blank
reserve function PlayerObject_HandleAniSpeed
reserve function PlayerObject_HandleMovement
reserve function PlayerObject_InitReplay
reserve function PlayerObject_HandleGroundCol
reserve function PlayerObject_HandleAirCol

// Static Values
public value specialStageAngle = 0;
public value PlayerObject_value1 = 0;
public value PlayerObject_value2 = 0;
public value PlayerObject_value3 = 0;
public value PlayerObject_value4 = 0;
public value PlayerObject_ReplayData = 0;
public value PlayerObject_ReplayPos = 0;
public value PlayerObject_ReplaySize = 0;
public value PlayerObject_ReplayFrameCnt = 0;
public value PlayerObject_ReplayLength = 0;
public value PlayerObject_value0 = 0;

private value PlayerObject_value9 = 0;


private value PlayerObject_value10 = 0;
private value PlayerObject_value11 = 0;
private value PlayerObject_value12 = 0;
private value PlayerObject_value13 = 0;
private value PlayerObject_value14 = 0;
private value PlayerObject_value15 = 0;

function PlayerObject_InitReplay
PlayerObject_ReplayPos = 2
PlayerObject_ReplayFrameCnt = 1
currentPlayer = 0
while currentPlayer < playerCount
GetTableValue(object[currentPlayer].xpos, 0, PlayerObject_ReplayData)
GetTableValue(object[currentPlayer].ypos, 1, PlayerObject_ReplayData)
object[currentPlayer].controlMode = -1
object[currentPlayer].up = 0
object[currentPlayer].down = 0
object[currentPlayer].left = 0
object[currentPlayer].right = 0
object[currentPlayer].jumpPress = 0
object[currentPlayer].jumpHold = 0
object[currentPlayer].value1 = 0
currentPlayer++
loop
[Link] = object[0].ixpos
[Link] = object[0].iypos
end function

function PlayerObject_ProcessPlayer
if [Link] == 0
//if [Link] == 1
if [Link] == 0
if [Link] == 1
if [Link] == 1
CreateTempObject(TypeName[Fade In], 10,
[Link], [Link])
end if
end if
end if
//end if
ProcessObjectControl()

if [Link] == 1
if [Link] == 2
if [Link] == 1
object[currentPlayer].state = PlayerObject_Blank
object[currentPlayer].xvel = 0
object[currentPlayer].yvel = 0
object[currentPlayer].speed = 0
object.value0 = 0
object[currentPlayer].interaction = 0
ResetObjectEntity(20, TypeName[Special Finish], 0, 0,
0)
object[20].priority = PRIORITY_ACTIVE
PlaySfx(SfxName[Exit SS], 0)
[Link] = 0
[Link] = 0
[Link] = 0
end if
end if
end if
else
if [Link] == 1
if PlayerObject_ReplayFrameCnt > 1
PlayerObject_ReplayLength = 1
end if
end if
PlayerObject_ReplayFrameCnt--
if PlayerObject_ReplayFrameCnt < 1
if PlayerObject_ReplayPos < PlayerObject_ReplaySize
GetTableValue(temp0, PlayerObject_ReplayPos,
PlayerObject_ReplayData)
GetBit([Link], temp0, 0)
GetBit([Link], temp0, 1)
GetBit([Link], temp0, 2)
GetBit([Link], temp0, 3)
GetBit([Link], temp0, 4)
GetBit([Link], temp0, 5)
PlayerObject_ReplayPos++
GetTableValue(PlayerObject_ReplayFrameCnt,
PlayerObject_ReplayPos, PlayerObject_ReplayData)
PlayerObject_ReplayPos++
end if
else
if [Link] == 1
[Link] = 0
end if
end if
if PlayerObject_ReplayLength > 0
PlayerObject_ReplayLength--
if PlayerObject_ReplayLength < 1
arrayPos0 = PlayerObject_value0
object[arrayPos0].type = TypeName[Title Card]
object[arrayPos0].state = 8
object[arrayPos0].priority = PRIORITY_ACTIVE
object[arrayPos0].drawOrder = 6
end if
end if
end if
end function

function PlayerObject_Blank
checkResult = 0
end function

function PlayerObject_HandleAniSpeed
if [Link] == 1
[Link] = 120
else
[Link] = object.value2
Abs([Link])
[Link] *= 240
[Link] /= 0x60000
[Link] += 48
end if
end function

function PlayerObject_HandleGroundCol
if object.value12 > 0
GetBit(temp0, object.value11, 2)
else
GetBit(temp0, object.value11, 3)
end if
if temp0 != 0
object.value12 = 0
[Link] = GRAVITY_GROUND
end if
if object.value13 > 0
GetBit(temp0, object.value11, 1)
else
GetBit(temp0, object.value11, 4)
end if
if temp0 != 0
object.value13 = 0
[Link] = GRAVITY_GROUND
end if
end function

function PlayerObject_HandleAirCol
temp0 = PlayerObject_value1
temp0 >>= 1
temp0 -= 224
temp0 &= 192
switch temp0
case 0
if object.value2 > 0
GetBit(temp0, object.value11, 2)
else
GetBit(temp0, object.value11, 3)
end if
break
case 64
if object.value2 > 0
GetBit(temp0, object.value11, 1)
else
GetBit(temp0, object.value11, 4)
end if
break
case 128
if object.value2 > 0
GetBit(temp0, object.value11, 3)
else
GetBit(temp0, object.value11, 2)
end if
break
case 192
if object.value2 > 0
GetBit(temp0, object.value11, 4)
else
GetBit(temp0, object.value11, 1)
end if
break
end switch
if temp0 == 1
object.value2 = 0
end if
object.value11 = 0
end function

function PlayerObject_HandleMovement
CallFunction(PlayerObject_HandleGroundCol)
if [Link] == GRAVITY_AIR
if object.value14 != 0
object.value14--
end if
if object.value15 != 0
object.value15--
end if
end if
temp2 = PlayerObject_value1
temp2 &= 504
if [Link] == GRAVITY_GROUND
if [Link] == 1
checkResult = 1
else
checkResult = 0
end if
else
checkResult = 0
end if
if checkResult == 1
Sin(temp0, temp2)
temp0 *= object.value7
temp0 >>= 9
Cos(temp1, temp2)
temp1 *= object.value7
temp1 >>= 9
object.value12 = 0
object.value12 += temp0
object.value13 = 0
object.value13 -= temp1
PlaySfx(SfxName[Jump], 0)
else
Sin(temp0, temp2)
temp0 *= object.value5
temp0 >>= 9
Cos(temp1, temp2)
temp1 *= object.value5
temp1 >>= 9
object.value12 -= temp0
object.value13 += temp1
end if
CallFunction(PlayerObject_HandleAirCol)
temp0 = 0
if [Link] == 1
object.value2 -= object.value3
if object.value2 < -0x80000
object.value2 = -0x80000
end if
[Link] = FLIP_X
temp0 = 1
end if
if [Link] == 1
object.value2 += object.value3
if object.value2 > 0x80000
object.value2 = 0x80000
end if
[Link] = FLIP_NONE
temp0 = 1
end if
if temp0 == 0
if object.value2 != 0
if object.value2 > 0
object.value2 -= object.value3
if object.value2 < 0
object.value2 = 0
end if
else
object.value2 += object.value3
if object.value2 > 0
object.value2 = 0
end if
end if
end if
end if
temp0 = PlayerObject_value1
temp0 += 64
temp0 &= 384
Cos(object.value8, temp0)
object.value8 *= object.value2
object.value8 >>= 9
Sin(object.value9, temp0)
object.value9 *= object.value2
object.value9 >>= 9
[Link] = object.value12
[Link] += object.value8
[Link] = object.value13
[Link] += object.value9
CallFunction(PlayerObject_HandleAniSpeed)
end function

event ObjectMain

if [Link] == 1
CallFunction(PlayerObject_ProcessPlayer)
if [Link] == 1
[Link] = TypeName[Debug Mode]
if [Link] == 1
object[+1].type = TypeName[Blank Object]
end if
object.value2 = 0
[Link] = 0
[Link] = 0
PlayerObject_value1 = 0
PlayerObject_value2 = 2
[Link] = object.value10
specialStageAngle = 0
[Link] = 0
else
CallFunction([Link])
ProcessAnimation()
if [Link] != 1
ProcessObjectMovement()
end if
[Link] = GRAVITY_AIR
end if
else
CallFunction(PlayerObject_ProcessPlayer)
CallFunction([Link])
ProcessAnimation()
if [Link] != 1
ProcessObjectMovement()
end if
[Link] = GRAVITY_AIR
end if
end event

event ObjectDraw
DrawObjectAnimation()
end event

event ObjectStartup
ReadSaveRAM()
LoadSpriteSheet("Global/[Link]")
foreach (TypeName[Player Object], arrayPos0, ALL_ENTITIES)
if [Link] == 3
[Link] = 0
stage.player2Enabled = 1
end if
if [Link] == 4
[Link] = 2
stage.player2Enabled = 1
end if
ResetObjectEntity(0, TypeName[Player Object], 0,
object[arrayPos0].xpos, object[arrayPos0].ypos)
[Link] = object[0].ixpos
[Link] = object[0].iypos
object[0].groupID = GROUP_PLAYERS
object[0].xvel = 0
object[0].yvel = 0
object[0].speed = 0
PlayerObject_value0 = [Link]
switch [Link]
case 0
LoadAnimation("[Link]")
object[0].animationSpeed = 48
break
case 1
LoadAnimation("[Link]")
object[0].animationSpeed = 120
break
case 2
switch [Link]
case 0
LoadAnimation("[Link]")
break
case 1
LoadAnimation("[Link]")
break
case 2
LoadAnimation("[Link]")
break
end switch
object[0].animationSpeed = 48
break
case 5
LoadAnimation("[Link]")
object[0].animationSpeed = 48
break
case 6
LoadAnimation("[Link]")
object[0].animationSpeed = 48
break
end switch
object[0].state = PlayerObject_HandleMovement
object[0].priority = PRIORITY_ACTIVE
object[0].drawOrder = 4
object[0].value3 = 0xC00
object[0].value7 = 0x68000
object[0].value5 = 0x2A00
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
object[0].tileCollisions = 0
object[0].gravity = GRAVITY_AIR
PlayerObject_value1 = 0
PlayerObject_value2 = 0
PlayerObject_value3 = 0
PlayerObject_value4 = 0
specialStageAngle = 0
next
[Link] = 1
end event

event RSDKDraw
DrawSprite(0)
end event

event RSDKLoad
LoadSpriteSheet("Players/[Link]")
SpriteFrame(-16, -16, 32, 32, 42, 118)
end event

DrawSprite(0)
end event

event RSDKLoad
LoadSpriteSheet("Players/[Link]")
SpriteFrame(-16, -16, 32, 32, 42, 118)
end event

You might also like