Skip to content

Instantly share code, notes, and snippets.

View ultraviolet-jordan's full-sized avatar

Jordan ultraviolet-jordan

  • United States
View GitHub Profile
[proc,moveallinv](inv $src, inv $dest)
def_int $size = inv_size($src);
def_int $i = 0;
while ($i < $size) {
def_obj $obj = inv_getobj($src, $i);
if ($obj ! null) {
inv_moveitem($src, $dest, $obj, inv_total($src, $obj));
}
$i = add($i, 1);
}
[opplayeru,christmas_cracker] @player_pull_christmas_cracker;
[label,player_pull_christmas_cracker]
if (inv_total(inv, christmas_cracker) = 0) {
return;
}
if(.busy = true) {
mes("<.displayname> is busy.");
return;
}
[ScriptOpcode.MAP_BLOCKED]: (state) => {
const coord = state.popInt();
if (coord < 0 || coord > Position.max) {
throw new Error(`MAP_BLOCKED attempted to use coord that was out of range: ${coord}. Range should be: 0 to ${Position.max}`);
}
const pos = Position.unpackCoord(coord);
const zone = World.getZone(pos.x, pos.z, pos.level);
[debugproc,test]
def_int $radius = 1; // 1, 2 or 3
def_coord $coord = coord;
def_int $x = coordx($coord);
def_int $z = coordz($coord);
def_int $centerX = divide($x, pow(2, 3));
def_int $centerZ = divide($z, pow(2, 3));
fun ByteBuffer.rsadec(exponent: BigInteger, modulus: BigInteger) {
val length = g1
val dec = BigInteger(gdata(length)).modPow(exponent, modulus).toByteArray()
position(0)
pdata(dec)
position(0)
}
======================================================================
fun main() {
val buffer = ByteBuffer.allocate(100)
buffer.withBitAccess {
pBit(2, 3)
pBit(1, 0)
}
}
inline fun ByteBuffer.withBitAccess(function: ByteBuffer.() -> Unit) {
position(position() * 8)
@JvmInline
value class MapSquareLandTile(
private val packed: Long
) {
constructor(
height: Int,
overlayId: Int,
overlayPath: Int,
overlayRotation: Int,
collision: Int,
class RSByteBuffer(
private val buffer: ByteBuffer
) {
constructor(array: ByteArray) : this(ByteBuffer.wrap(array))
private var accessBitsIndex = -1
fun readByte(): Int {
checkAccessingBytes()
return buffer.get().toInt()
class ActorRenderer(
val lowDefinitionRenderBlocks: Array<LowDefinitionRenderBlock<*>?> = arrayOfNulls(13),
val highDefinitionRenderBlocks: Array<HighDefinitionRenderBlock<*>?> = arrayOfNulls(13)
) {
fun <T : RenderType> update(type: T): T {
val block = type.toBlock()
highDefinitionRenderBlocks[block.index] = HighDefinitionRenderBlock(type, block)
return type
}
class Viewport(
val player: Player
) {
val nsnFlags = IntArray(MAX_PLAYERS)
val locations = IntArray(MAX_PLAYERS)
val highDefinitions = IntArray(MAX_PLAYERS)
val lowDefinitions = IntArray(MAX_PLAYERS)
val highDefinitionUpdates = ArrayList<Int>()
val lowDefinitionUpdates = ArrayList<Int>()
val players = arrayOfNulls<Player?>(MAX_PLAYERS)