# TASVideos

Tool-assisted game movies
When human skills are just not enough

# Game Resources / DS / The World Ends With You

This page is only an old draft and will be updated and cleaned eventually.

## Random Number Generator (RNG)

### Mechanics

#### RNG Calculation

You can calculate the next RNG state with the following lua script.
```function getNextRNG(lowRNG, upRNG)
local temp = upRNG + ((2^0x2 * upRNG) % 2^0x10)
lowRNG = lowRNG * 2 + math.floor(temp / 2^0x10) + upRNG + math.floor((lowRNG * 2 + math.floor(temp / 2^0x10)) / 2^0x10)
return lowRNG % 0x10000, temp % 0x10000 -- return RNG L, RNG U
end```

0x2063760 16-bit RNG Lower 2 bytes
0x2063762 16-bit RNG Upper 2 bytes

#### Passed Value

A 16-bit value is passed to the function in register 0. The function then returns a value between 0 (inclusive) and the passed value (exclusive).
`r0 = (r0 * lowRNG) >> 0x10	// lowRNG is after the calculation for the next state`

### Battle Uses

#### Item Drop Test

Passed Value: 0x2710 (10,000)

The item's drop rate is multiplied by the drop rate multiplier and stored in register 8 during the RNG execution. If the returned value is less than the value in register 8, the test is passed and the item is dropped. Else, the drop test is considered failed and continues to the next item in the table.

## Overworld Movement

0x207415C 32-bit Current X Coordinate
0x2074160 32-bit Current Y Coordinate

## Battle Mechanics

### Light Puck (Puck)

#### Travel Time

The Puck begins moving to the next partner two frames after the character holding the Puck (either character if the Puck is not in play) damages an enemy with a combo finisher. The value is set, when the Puck begins moving, to the base value of 89 and is reduced by 1 every frame until 0. Upon turning 0 from traveling, the value becomes 1 the next frame and the pass is considered complete. The value becomes 0 afterwards. Attempting to change this value directly to 0 will cause the game to reset the value to the base value.

This value is signed. All negative values are treated like 1 and will turn to 0 on the next frame to complete the pass normally.

#### Hold Time

The Puck can only be held for a limited amount of time before disappearing from play. The value is reset, when passing the Puck, to the base value of 930 and reduced by 30 for every pass. This includes the pass the puck is created so maximum base value without clothes is 900. The value is reduced by 1 every frame until 0.

This value is signed. All negative values are treated like 1 and will turn to 0 on the next frame for the Puck to disappear from play normally.

This value is used the frame before a combo finisher by the character holding the Puck deals damage to determine the increase/decrease of the Puck's Damage Multiplier.

Value/Max Value Multiplier Change
98% +50 (+x0.5)
92% +20 (+x0.2)
70% +10 (+x0.1)
0% -100 (-x1.0)

#### Damage Multiplier

The Puck multiplies the damage dealt by a combo finisher if the character is currently holding it. The value is reset, when the Puck is created by the first pass, to the base value of 200. The value is then increased or decreased, when passing the Puck, based on the Puck Hold Time value. The value is a percentage so the value must be divided by 100 to get the true multiplier.

The minimum value is 200 (x2) and maximum is 500 (x5). Any values beyond this range will be set to the minimum (if under) or the maximum (if over). This value is signed and all negative values will be set to 200.

The Damage Multiplier applied to damage is after the increase or decrease. This must be noted because the Damage Multiplier in RAM is updated after the affected damage is dealt.

All Puck addresses are stored in the Battle GUI Linked List except the following:
0x23918CD 8-bit Current Puck Pass Count

### Hit Points

A single address contains the current amount of Hit Points despite the two characters seeming to have their own Hit Point bars. The game only uses the current Hit Points. The damage received by the characters is only for graphical purposes and specific clothing abilities.

0x23918B0 16-bit Current HP
0x23918B2 16-bit Maximum HP
0x23918B4 16-bit Damage Received on Top Screen
0x23918B6 16-bit Damage Received on Bottom Screen

### Item Drop

#### Drop Rate Multiplier (for Battles)

The Drop Rate Multiplier can be temporarily multiplied by the amount of chained battles. This value is moved to a new address after the chain is finalized for use in battle.

#### Item Drop Table

Each enemy has an item drop table containing one item and drop rate for each difficulty. Starting at the item for the current difficulty, a drop test is executed. If the test is successful, the item is dropped. If the test is unsuccessful, the game moves down a difficulty and tries again. If the game reaches the end of the enemy's drop table without dropping an item, no item is dropped.

#### Useful Item Drop Related Addresses

0x2071D24 16-bit Drop Rate Multiplier
0x2391872 16-bit Drop Rate Multiplier for Battle(s)

### Battle Field Object/GUI Linked Lists

All GUI elements and Field Objects are stored within Linked Lists during battles.
0x235406C 0x235408C Field Objects, Bottom Screen
0x235C0F8 0x235C118 Field Objects, Top Screen
0x2364184 0x23641A4 GUI Elements

#### Basic Struct

This is used by all following structs, which are extended from this struct.
0x08 maybe be used to point to where the assets for the object are located.
Offset Type Description
0x00 32-bit Unknown Purpose
0x51342403 if Valid Object
0x04 32-bit Pointer to Data Name
0x08 32-bit Size of Object
0x0C 32-bit End of List if 0xFFFFFFFF
0x10 32-bit Pointer to Head if Tail
0x14 32-bit Pointer to Tail if Head
0x18 32-bit Pointer to Next Object
0x1C 32-bit Pointer to Previous Object

#### Puck Data Struct

Found in the GUI Linked List.

This is available when a partner is present. This struct contains a preallocated linked list which is consistent enough for the following addresses to be static.
The value of 0x08 is usually 0x7E0.

0x032 16-bit Unknown
0x034 16-bit Unknown
0x0E4 32-bit Random 1a
0x0E8 32-bit Random 1b
0x7BC 32-bit Travel Time
0x7CC 32-bit Puck Decay
0x7D0 16-bit Damage Multiplier
0x7D4 16-bit Hold Time
Random 1: Set at beginning of battle. Unknown purpose

#### Rebootable Pin Struct

Found in the GUI Linked List.

This is used by most pins that are able to reboot.
The value of 0x08 is usually 0x2C0. Occasionally, a newly created GUI Object would share this value during battle.

Offset Type Description
0x3E 16-bit Attack Power
0x64 16-bit Uses Left
0x66 16-bit Maximum Uses
Not set until after a boot
0x68 16-bit Boot Time Left
0x0 if never booted yet
0xFFFF after a complete boot

#### Enemy Struct

Found in the Field Object Linked List.

This is used by all enemies.

Offset Type Description
0x7A 16-bit Invulnerability Left
0x8C 16-bit Current Hp
0x8E 16-bit Maximum Hp
0x98 32-bit Pointer to Mirrored Enemy
0x1C2 16-bit Unknown

#### Prize Struct

Found in the Field Object Linked List.

This is used by Item Drops that float to a character and is collected.

Offset Type Description
0x8C 16-bit Prize Collect Time
Collect Prize on 0

### Static enemy data

You can find the starting address of an enemy's data at 0x20E0E24 + (0x2670 * Enemy Id). The enemy id is their noise report number minus one.

#### Data Map

Offset Type Description
0x2C 16-bit Item Id for the "Easy Drop"
0x2E 16-bit Item Id for the "Normal Drop"
0x30 16-bit Item Id for the "Hard Drop"
0x32 16-bit Item Id for the "Ultimate Drop"
0x34 16-bit Drop rate for the "Easy Drop"
0x36 16-bit Drop rate for the "Normal Drop"
0x38 16-bit Drop rate for the "Hard Drop"
0x3A 16-bit Drop rate for the "Ultimate Drop"

0x2066A44 32-bit Total Session Time (In frames)
0x2071D29.0 2-bit Difficulty
0 = Easy
1 = Normal
2 = Hard
3 = Ultimate
0x2071D29.2 2-bit Auto Partner
0 = Manual
1 = Slow
2 = Mid
3 = Fast
0x2071D29.4 2-bit Current Pin Deck
0 = Deck 1
1 = Deck 2
2 = Deck 3
3 = Deck 4