• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Finding if a point x and y values are a multiple of 128

Status
Not open for further replies.
Level 2
Joined
Oct 29, 2011
Messages
13
Alright, so I, once again, find i need the community's help. I'm trying to create a road building system that, when finished, will work as such:

When the Road unit is built, the terrain under it changes to a Village-Stone Path, The Road unit is replaced with an invisible road unit that is walkable, but not buildable. When this unit is destroyed, the terrain under it changes to Rough Dirt.

All of this works fine. The problem I'm having is this:
Since you can build buildings on half-tiles of terrain, if you build the road unit on a half-tile, the terrain that changes is half under, half not-under, the built Road Unit. Thusly, the unbuildable;walkable unit that replaces the built unit is half on, half off the road.

I'm looking for a trigger that can detect whether the x value and y value of the replaced building's center is a multiple of 128(the center x and y of a terrain block 1 is always a multiple of 128, at least on the map I'm using) so that I can move the replaced unit as needed up(for y), or right(for x) by 64(To make it a multiple of 128).

If anybody knows how to do this, that would be awesome.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It's simple maths.
pseudo code :

if ( someInteger mod 128 ) == 0 then
// this is a multiple of 128
else
// this is not a multiple of 128
endif

I don't know the name of "mod" in gui but it's probably spelled "modulo"

EDIT : Or just round up like Dirac has suggested.
I just answered to your problem i don't really know what you need.
 
Level 2
Joined
Oct 29, 2011
Messages
13
Thanks, I'll try this and see if it works.

Edit: Thanks a lot. It worked perfectly. Troll-Brain, you're super awesome.
 
Last edited by a moderator:
Status
Not open for further replies.
Top