# Do you find this helpful?

#### Dirac

##### 22710180
Because i do, and i find it to be a very good replacement to the ugly Location native
The join method would be used to constantly have useful data of both locations at any time without repeating the same calculations
If you don't know what the "slope" variable is for, it's the relation between the difference of the height of two locs and the distance between them.
JASS:
``````library Loc /* v1.0.0

Replacement of the Location native.

***********************************************************************
*
*   struct Loc
*
*           -   These 3 read-only variables are the Loc's coordinates
*
*       static method create takes real x, real y, real z returns Loc
*           -   Creates a new Loc with the given coordinates.
*       method destroy takes nothing returns nothing
*           -   Deallocates the Loc.
*
*       method move takes real x, real y, real z returns nothing
*           -   Assigns the Loc new coordinates.
*
*       static method join takes Loc v1, Loc v2 returns nothing
*           -   Joins two Locs together.
*       method disjoint takes nothing returns nothing
*           -   Breaks the joint of the given Loc.
*
*           -   These 3 read-only members store the relation between
*           -   two joined Locs. Updates everytime a Loc is moved.
*
**********************************************************************/

struct Loc extends array

private static integer ic = 0
private static integer array next

readonly static location point = Location(0,0)

private static method refresh takes Loc v1, Loc v2 returns nothing
local real a = Atan2(v2.y-v1.y,v2.x-v1.x)
local real d = SquareRoot((v1.x-v2.x)*(v1.x-v2.x)+(v1.y-v2.y)*(v1.y-v2.y))
local real s = (v2.z-v1.z)/d
set v1.angle = a
set v2.angle = a+bj_PI
set v1.distance = d
set v2.distance = d
set v1.slope = s
set v2.slope = -s
endmethod

static method join takes Loc v1, Loc v2 returns nothing
call refresh(v1,v2)
set next[v1]=v2
set next[v2]=v1
endmethod

method disjoint takes nothing returns nothing
set next[next[this]]=next[this]
set next[this]=this
endmethod

method move takes real sx, real sy, real sz returns nothing
call MoveLocation(point,sx,sy)
set x=sx
set y=sy
set z=sz+GetLocationZ(point)
if this!=next[this] then
call refresh(this,next[this])
endif
endmethod

static method create takes real sx, real sy, real sz returns thistype
local thistype this
if next[0]==0 then
set ic = ic+1
set this = ic
else
set this = next[0]
set next[0] = next[next[0]]
endif
set next[this]=this
call this.move(sx,sy,sz)
return this
endmethod

method destroy takes nothing returns nothing
call this.disjoint()
set next[this]=next[0]
set next[0]=this
endmethod

endstruct

endlibrary``````

#### GFreak45

##### I didnt slap you, i high 5'd your face.
i would add something like this:
JASS:
``````static method compare takes thistype this, thistype this2 returns real
return SquareRoot((this.x - this2.x, 2) * (this.x - this2.x, 2) + (this.y - this2.y) * (this.y - this2.y) + (this.z - this2.z, 2) * (this.z - this2.z, 2))
endmethod //to return the real distance between points taking height into consideration``````

and if you werent limited to 2 points linked together

Also if you increased the link ammounts, something like this:

JASS:
``````static method compareChain takes thistype this returns real
local real dist = 0
local thistype i = this
loop
set dist = dist + .compare(i, i.next)
exitwhen i.next = this
set i = i.next
endloop
return dist
endmethod``````

thats actually something i would use (as long as its truly more efficient than just using x/y arguments and locals)

also... why do you use an integer array instead of a dynamic struct variable, ie:

JASS:
``````struct Example extends array
static integer array next
static integer array previous

----&gt;

thistype next
thistype previous

or just

thistype.next
endstruct``````

this makes it much simpler for deallocation and referencing next/previous

ie this.next.previous.next.previous = this

no need for
.next[.previous[.next[.previous]]]
or
thistype(thistype(thistype(this.next).previous).next).previous

which are way more complicated
it compiles the same but its more readable

Also also:

why do you link them with 0 when you destroy them? what happens when someone destroys a bunch 1 after another, do they just all point to 0 and not get pointed to at all?

#### Dirac

##### 22710180
Thanks for the feedback.
[ljass]loc.distance/Atan(loc.slope)[/ljass]
Would be equal to the distance of the locs considering the height of both

I limit myself to two points because of two reasons:
• It's the most common situation
• I would have to use Table instead, would be much slower

I guess i could implement some kind of "sync" between two locs, but would be monodirectional data.

Example, I have 5 locs and 4 of them are linked to the 5th one.
If i move the 5th one, all other 4 locs would get their data updated, but the 5th one would only get the data from 1 of them (as it can only be synced with 1 node)
In that case I would have to use LinkedList and it would be less user friendly

#### GFreak45

##### I didnt slap you, i high 5'd your face.
if you need to link 2 locations together to compare the distance i wouldnt find that useful, i would rather just compare them via regular math for slope/distance etc
i mean i guess it would be usefull to someone whos not to great at math and would spend a ton of time researching how to do it and still not get it, but other than that it would basically be a new version of the [ljass]PolarProjectionBJ[/ljass] with a slight twist, more efficient to use whats inside rather than the function

#### Dirac

##### 22710180
why do you link them with 0 when you destroy them? what happens when someone destroys a bunch 1 after another, do they just all point to 0 and not get pointed to at all?
It's a stack.

0 -> 0 -> 0

instance (4) gets deallocated
{
next[4] = next[0] -> 0
next[0] = 4
}

0 -> 4 -> 0

instance (7) gets deallocated
{
next[7] = next[0] -> 4
next[0] = 7
}

0 -> 7 -> 4 -> 0

[HR][/HR]

Using your way of doing things
JASS:
``````local real dist = 0
local thistype i = this
loop
set dist = dist + .compare(i, i.next)
exitwhen i.next = this
set i = i.next
endloop``````

Would update every other Loc "i" with "this" , but won't update the data on "this"
That would cause issues if the user has joined only 2 Locs together, because now only one of those locations knows the actual distance, the one you didn't move.
In case the user has more than 2 joined... as an example Locs A, B and C are together, if I move A then B and C would know their distance to A, but they won't know their distance to each other and A would know the distance between itself and one of the other Locs (chosen randomly)
A.distance = distance between A and ??
B.distance = distance between B and A
C.distance = distance between C and A

Current method i wrote using my linked list module
JASS:
``````private method refresh takes nothing returns nothing
local thistype exit = this
local real a
local real d
local real s
loop
set this = next
exitwhen this == exit
set a = Atan2(this.y-exit.y,this.x-exit.x)
set d = SquareRoot((exit.x-this.x)*(exit.x-this.x)+(exit.y-this.y)*(exit.y-this.y))
set s = (this.z-exit.z)/d
set exit.angle = a
set this.angle = a+bj_PI
set exit.distance = d
set this.distance = d
set exit.slope = s
set this.slope = -s
endloop
endmethod``````

General chit-chat
Help Users
• No one is chatting at the moment.
• C Cherry.Grove:
My boyfriend is super into Bethesda modding so I'm probably going to join him in that for a bit, then move on to making mobile/browser games.
• C Cherry.Grove:
I mostly just want to look at my old projects because I know I posted uploads on here somewhere.
• C Cherry.Grove:
My one game was basically Among Us but you sabotaged an entire medieval city simulated drastically inefficiently with dynamic NPCs :S
• C Cherry.Grove:
of course I never finished it x D
• jonas:
xD
• jonas:
I think you can still run the original game, just there's a chance your map won't work with the newer patches
• jonas:
what development framework have you been looking at for mobile development?
• jonas:
I'm currently creating (as a hobby) a space invaders like game for mobile using Xamarin, after starting a few larger projects that I also may not have finished
• The Helper:
Awesome! you should look at the Atari VCS platform it does not have a huge user base but the one it has is super active at around 11k and they have no games in there store
• The Helper:
basically it is linux
• The Helper:
OMG it is BanLord as Blackveiled on the forum
• The Helper:
what is up buddy
• jonas:
thanks for the tip, that sounds cool. Never heard about the VCS before but seems like it should be a good match
• tom_mai78101:
The winter vacation left a toll on me. I missed staying up late and sleeping in late.
• C Cherry.Grove:
i haven't looked into it yet
• C Cherry.Grove:
If I could use something Python compatible it would save me some learning
• C Cherry.Grove:
But Unity might be easiest
• C Cherry.Grove:
looking at old posts here makes me happy. Makes me be all like "wow I was pretty smart in 2009"
• C Cherry.Grove:
mostly failing at life through adulthood really demotivated me for a while
• C Cherry.Grove:
....what I don't get is why the fuck they would force us to permanently convert to a version of the game everyone fucking hated : \
• C Cherry.Grove:
Raid Shadow Legends texture pack smh
• jonas:
Most people fail at life throughout their adulthood. Sometimes we get to learn from it. Usually it just feels like crap.
+1
• The Helper:
What does not kill you makes you stronger is what they say
• C Cherry.Grove:
for real!

### Members online

No members online now.