diepAPI icon indicating copy to clipboard operation
diepAPI copied to clipboard

arena size impossible to get now?

Open Cazka opened this issue 3 years ago • 8 comments

since they removed minimap viewport #64, it is not possible to determine the arena size anymore.

Should diepAPI transition from canvas based to memory based api?

Cazka avatar Jan 03 '23 05:01 Cazka

I noticed that, what will i change? you can do the same as on diepbox

tariteur avatar Jan 04 '23 09:01 tariteur

It totally should switch to memory interaction. going off of canvas/rendering is probably the most ineffective and unstable way to do things. (specially on low-end pc's).

Looking forward to it :)

emlinhax avatar Jan 04 '23 11:01 emlinhax

I would be willing to help with development. I have been experimenting on this game lately.

Discord contact is in my bio.

emlinhax avatar Jan 04 '23 11:01 emlinhax

I have an idea: for game modes you can manually (in script) set the size of the arena and for the sandbox detect the number of players and what size it corresponds to

tariteur avatar Jan 14 '23 17:01 tariteur

detecting the number of players is also challenging. But I agree, that we could hardcode de arenasizes for the other game modes

Cazka avatar Jan 14 '23 18:01 Cazka

i try something test arena size

tariteur avatar Jan 15 '23 11:01 tariteur

I had to redo the camera because it was not the right coordinate and the arena I just changed the size

class Camera {
            #position;
            constructor() {
                game.on('frame_end', () => {
                    const playerPos = player.position;
                    const topLeft = Vector.subtract(playerPos, new Vector(window.innerWidth / 2, window.innerHeight / 2));
                    const bottomRight = Vector.add(playerPos, new Vector(window.innerWidth / 2, window.innerHeight / 2));
                    this.#position = new Vector(topLeft.x, bottomRight.y);
                });
            }
            get position() {
                return this.#position;
            }
        }


  class Arena {
            #size = 1;
            constructor() {
                setInterval(() => {
                    if (player.gamemode === 'sandbox') {
                        const toggleButton = document.querySelector("body > d-base").shadowRoot.querySelector("d-game").shadowRoot.querySelector("#user-list-toggle");
                        const matches = toggleButton.textContent.match(/\d+/);
                        const number = parseInt(matches[0]);
                        this.#size = Math.floor(25 * Math.sqrt(Math.max(number, 1))) * 100; // I used ABC's diep Custom for this part but its working
                        console.log(`size: ${this.#size}`)
                    } else {
                        this.#size = 22300;
                    }
                }, 16);
            }
            /**
             * @returns {number} The Arena size in arena units
             */
            get size() {
                return this.#size;
            }
            /**
             *
             * @param {Vector} vector The vector in [0, 1] coordinates
             * @returns {Vector} The scaled vector in [-Arena.size/2, Arena.size/2] coordinates
             */
            scale(vector) {
                const scale = (value) => Math.round(this.#size * (value - 0.5));
                return new Vector(scale(vector.x), scale(vector.y));
            }
            /**
             *
             * @param {Vector} vector - The scaled vector in [-Arena.size/2, Arena.size/2] coordinates
             * @returns {Vector} The unscaled vector in [0, 1] coordinates
             */
            unscale(vector) {
                const unscale = (value) => value / this.#size + 0.5;
                return new Vector(unscale(vector.x), unscale(vector.y));
            }
        }

tariteur avatar Jan 15 '23 11:01 tariteur

for sandbox: on the other hand the problem is that the players will have to be alive to display the number of players unless we detect the "teleportation" of the player's arrow on the minimap when a new player connects

tariteur avatar Jan 15 '23 13:01 tariteur

coming back to this issue after 3 years, lol. The game is currently in active development thanks to the new owner.

I think diepAPI needs to transition to a hybrid approach and use memory injection aswell to get game information.

I will make a PoC that accesses memory to get arena size and camera position.

This should then be included in v4.0.0

Cazka avatar Dec 13 '25 17:12 Cazka

Hi, please check your Discord DMs when you get a chance. I have something related to memory that might interest you.

Image

tariteur avatar Dec 17 '25 17:12 tariteur