RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RESOLVED][VX] Efficient eventing, distance checking and massive lag

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 84
Above Characters
Hello.

As I'm not experienced in scripting, I do most of the things by eventing, and often it causes extreme lag ingame. I know there are ways to do things more efficiently, so I came here for your advice!

So what I want to do and how I managed it to work:

Pretty large field (17 by 29), covered in very tall grass.
Spoiler for:

(Don't mind empty tiles, it's for testing - all of the tiles will be covered)

The grass reacts to player movements (splits when stepped on).
Spoiler for:

Insects can attack, if player steps on the wrong tile (there is a safe path, it can be navigated by carefully observing your surroundings - if grass moves near you, don't step there). If player gets caught again and again, attacks get progressively harder.

You can (if you want to) burn the whole field, but that will summon a tough boss.
The fire should start at the center (wherever the player stands at) and go to the sides, until all of the grass is burned.

-----------------------
I've managed to do all of it, but the last part gave me some trouble. How it works:
First, the switch turns on (triggers everything else below)
Then the ticker goes off as parallel process (it adds every 5 frames and counts from 1 to 29 - that's for the distance checking)
Spoiler for:

As it ticks, every (!) grass event checks if it's distance from the player is equal to ticker - if yes, then grass tile burns off.
Spoiler for:

The result looks pretty nice - fire goes off in a circle from the player to the sides of the field.
Spoiler for:



For distance checking I used Distance script by Jet:

Spoiler for:
Code: [Select]
class Game_Interpreter

  def tiles_away?(dist, char = -1)
    ev = get_character(0)
    char = get_character(char)
    (ev.x - char.x).abs + (ev.y - char.y).abs < dist
  end
end
So when every event on the map starts to do those script calls, it lags like hell. (duh)

UPDATE: It's resolved. Redone it with no lag. Thanks all for reading)


« Last Edit: May 17, 2014, 12:23:03 PM by 104251 »