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
702
Reaction score
3,473
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 love this job (as a programmer), coding is fun sometimes. It is just the deadline that needs to CHILL.
Best explanation of "Confirmation Bias": "If you go looking for a fight, you will always find one". If you always look for something, you'll find it. Negativity or Positivity. This is just a reminder to spend time looking for some Positivity today. :D Ya'll have earned it and deserve it.
And now all my attacking skills suddenly heal instead of doing damage...Even kills and revives. Because ofc they do xD
Spend more time building up what you like, and stop tearing down things you don't. If you only tear stuff down, nobody will get to enjoy anything.
Work, work. Streaming in 20 minutes or so.

Forum statistics

Threads
129,931
Messages
1,206,340
Members
171,130
Latest member
thepipa666
Top