genemm

Villager
Member
Joined
Aug 17, 2018
Messages
16
Reaction score
0
First Language
Filipino
Primarily Uses
RMMV
Hi everyone,

Great day! I am trying to make a diamond grid nested loop but I have a problem with it. There are excessive events created that are more than the desired diamond grid. Kindly check the attached files for the picture. Here are my event commands and scripts:

Control Variables : #0003 map.start = Map ID
Control Variables : #0001 player.start.x = 1
Control Variables : #0002 player.start.y = 1
Control Variables : #0006 player.walk.min = Random 0..7
Control Variables : #0007 player.walk.max = $gameVariables.value(6)+Math.randomInt(7-$gameVariables.value(6)+1);

Transfer Player : {map.start}({player.start.x},{player.start.y})

Script : Galv.SPAWN.overlap = 'chars';
Control Variables : #0014 player.walk.tilex = 0
Control Variables : #0015 player.walk.tiley = 0
Control Variables : #0014 player.walk.tilex += player.walk.min
Control Variables : #0015 player.walk.tiley = 0
Loop
If : player.walk.tiley <= player.walk.max
Loop
If : Script : $gameVariables.value(14)<=$gameVariables.value(7);
Script : Galv.SPAWN.event(3,$gameVariables.value(1)+$gameVariables.value(14)-$gameVariables.value(15),
$gameVariables.value(2)+$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)-$gameVariables.value(14)+$gameVariables.value(15),
$gameVariables.value(2)-$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)+$gameVariables.value(14)-$gameVariables.value(15),
$gameVariables.value(2)-$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)-$gameVariables.value(14)+$gameVariables.value(15),
$gameVariables.value(2)+$gameVariables.value(15));
: Else
Break Loop
Jump to Label : After Loop X
: End
Control Variables : #0014 player.walk.tilex += 1
: Repeat Above
Label : After Loop X
Control Variables : #0014 player.walk.tilex = player.walk.min
: Else
Break Loop
Jump to Label : After Loop Y
: End
Control Variables : #0015 player.walk.tiley += 1
: Repeat Above

The image I used for the diamond grid is the dog. Please help me remove the excessive dog events created.
 

Attachments

  • RMMV.PNG
    RMMV.PNG
    245.6 KB · Views: 12
  • RMMV2.PNG
    RMMV2.PNG
    114 KB · Views: 11
  • RMMV3.PNG
    RMMV3.PNG
    49.7 KB · Views: 9
  • RMMV4.PNG
    RMMV4.PNG
    64.9 KB · Views: 9

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
699
Reaction score
3,454
First Language
English
Primarily Uses
N/A
I'm not familiar with the plugin you've shown, but in the above image, if you wanted only a diamond shape made out of dogs, try adding this to your code. (I'll have to describe)

There is a function called $gameMap.distance
It accepts the following arguments
x1, y1, x2, y2

In the above image, if all excess was removed (dogs), it would be only the dogs that had a distance of 3 from the Player.

So when generating the dogs, if you add this condition (we'll called the dog event position being examined 'dog')

if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3)

The above condition requires that if the process is attempting to draw a dog, it must be a total (x and y) of 3 tiles from the player. If that rule
was followed in the image you've shown, it would leave a nice, even diamond shape.

I hope this helps.

*Also, There is a possibility that $gameMap.distance is a function added in by a Yanfly Core plugin, I'm not 100% sure. I just checked and it doesn't seem to be.
 

genemm

Villager
Member
Joined
Aug 17, 2018
Messages
16
Reaction score
0
First Language
Filipino
Primarily Uses
RMMV
Hi standardplayer,

Thank you for your reply. As for your if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3) formula, can you please provide me the full code to create the diamond grid dogs perfectly like this representation:

if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3) {
//generate dogs in diamond grid pattern <- please finish the code
}
 

Attachments

  • RMMV6.PNG
    RMMV6.PNG
    2 KB · Views: 1
  • RMMV7.PNG
    RMMV7.PNG
    1.7 KB · Views: 1

Latest Threads

Latest Posts

Latest Profile Posts

I have a really hard time keeping all these goodies secret til December... but I swear, it is worth the wait!
Working on a Premium version of my minimap plugin that will have advanced functionalities such as drawing a Terrain map based completely on the users tilesets, whatever they may be, and drawing minimap radar icons automatically based on texture of the event the note is applied to.
Psttt come look, this is the secret technique to tenderizing steaks, it makes it extra beefy. :rwink:

pixeldailyaxemeatsheild.gif
#screenshotsaturday update, featuring vaporwave angels lol
Lil' sketch I drew of Nico di Angelo :)
The spooky boi himself ♥
Nico sketch by Artemis Yates.jpg

Forum statistics

Threads
115,853
Messages
1,093,456
Members
151,061
Latest member
torsbein
Top