- Joined
- Jul 10, 2007
- Messages
- 6,306
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Actually, as the first post says, I initially made this for a combat system... when a target is passed around across multiple resources, that target may be anything (location, unit, destructable, item) and it may be used by many things. If it's used by many things, when do you know to destroy a location?
Furthermore, if you have a spawn, the origin of that spawn may be a location, unit, destructable or item.
Also, I disagree with how useful locations are... if you share a location across multiple systems, then you can update that location, which will properly update all of the systems. If you use x,y, then you have to update it for each and every system.
Furthermore, locations allow for handle attachment where as an x,y does not.
I think it's quite useful for both spawning and custom combat systems. I'm not sure what other uses there are, but the spherical coordinate projection relative to a point made easy by PositionOrigin seems like it could make making really cool visual spells a bit easier =P.
I hardly see a case where you don't know what is the nature of the target.
The target of an attack or spell could again be anything.. I once saw a spell in a map that could target items or units and acted differently for each.
>.>... if you're doing a generic custom combat system, you want to be able to support any and all possible targets.
If you're doing generic spawning, you want to be able to support any and all origins.
For both cases, any and all means that you have no clue what you're referencing.
You can consider me as a fool or/and as a stupid guy, but i still don't see the problem with using coordinates X/Y instead.
First, why the hell would i have 2 or more totally unrelated things which use the same position, and then suddenly i want to link them and move the position for each of them.
I mean it's related or it's unrelated, can't be both.
And if it's related i still can use a struct and anyway it's more likely i will have to link more data, and so the struct is not a waste.
set spawn.origin = position //any type of position
set spawn.origin.x = 33 //woo, easily moved it for everything that uses it
call attack(position) //if the position is a unit or destructable,
//direct attack w/ homing, if it's a position,
//ground attack with enum, if it's an item, debuff the item
class location
{
public:
float getLocationX(void)
{
return x;
}
float getLocationY(void)
{
return y;
}
float getLocationZ(void)
{
return z;
}
// ... more functions bla bla bla
private:
float x;
float y;
float z;
};
// Location.h
// A location class header file for reusability
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;
const double pi = 3.141592653589793238462643383;
const double d2r = pi/180.0;
const double r2d = 180.0/pi;
class Location
{
public:
// The constructor for each object
Location(double xn, double yn, double zn)
{
setLocationX( xn );
setLocationY( yn );
setLocationZ( zn );
}
// The Get functions
double getLocationX()
{
return x;
}
double getLocationY()
{
return y;
}
double getLocationZ()
{
return z;
}
// The Set functions
void setLocationX( double newx )
{
x=newx;
}
void setLocationY( double newy )
{
y=newy;
}
void setLocationZ( double newz )
{
z=newz;
}
void applyVector( double ax, double ay, double az )
{
x=x+ax;
y=y+ay;
z=z+az;
}
double getDistanceBetweenLocations( double ox, double oy )
{
double bx = (ox-x) * (ox-x);
double by = (oy-y) * (oy-y);
return sqrt( bx+by );
}
double getDistanceBetweenLocationsEx( double ox, double oy, double oz )
{
double bx = (ox-x) * (ox-x);
double by = (oy-y) * (oy-y);
double bz = (oz-z) * (oz-z);
return sqrt( bx+by+bz );
}
void destroyLocation()
{
x = 0.0;
y = 0.0;
z = 0.0;
// still WiP
}
void displayCoordinates()
{
cout << "The location X is: " << x << endl;
cout << "The location Y is: " << y << endl;
cout << "The location Z is: " << z << endl;
}
double getAngleToLocation( double ax, double ay )
{
return atan2(ay-y,ax-x) * r2d;
}
void applyProjection( double distance, double angle )
{
x = x + distance * sin(angle * d2r);
y = y + distance * cos(angle * d2r);
}
private:
double x;
double y;
double z;
};
I say the cloud and spawn are unrelated but use the same position, so that's how it's going to be.
It's my theoretical thingie, you can't change it >.>.
If you couple them together, then you have to redo the cloud for attacks and etc... I say the cloud can be used by itself as well, or with a spawn. And the spawn doesn't have to be linked to a cloud, it could also be on a mountain or a ship. Why? Because I say so, it's my theoretical thingie.
The only link they have between them is the spot =P, so take that, and that is only because I say so. They might not have the same spot, they only do because in this instance I say they do.
And there is a cloud that is linked to a mountain without a spawn, so boom.
Do you get it yet?
never ever couple or the couple monsters will come after you
And here is another fact.
If your only argument is that this is useless (no concrete evidence or anything), then it's pointless to argue with me. You are totally wasting your time right now because I'm never going to agree with you.
Essentially, it's impossible to prove that this is useless because it would either have to be broken with no possible fix or it would have to be incredibly simple to do (talking like 3 lines total) another way (exact, and I mean exact same features supported).
So just give up the this is useless argument. The fact that I'm using it means that you're obviously wrong.
-----
JASS:set spawn.origin = position //any type of position set spawn.origin.x = 33 //woo, easily moved it for everything that uses it call attack(position) //if the position is a unit or destructable, //direct attack w/ homing, if it's a position, //ground attack with enum, if it's an item, debuff the item
struct tests extends array
private static method onInit takes nothing returns nothing
local Position p = Position[CreateUnit(Player(0), 'hpea', WorldBounds.centerX, WorldBounds.centerY, 270)]
local Position p3 = Position[CreateUnit(Player(0), 'hfoo', WorldBounds.centerX, WorldBounds.centerY, 180)]
local Position p4 = Position[CreateUnit(Player(0), 'hrif', WorldBounds.centerX, WorldBounds.centerY, 0)]
set p.z = 300
set p3.z = 450
set p4.z = 150
set p3.x = WorldBounds.centerX
set p3.y = WorldBounds.centerY+300
set p4.x = WorldBounds.centerX
set p4.y = WorldBounds.centerY-300
call p.lock()
call p3.lock()
set p3.origin = p
set p3.locked = true
call p4.lock()
set p4.origin = p
set p4.locked = true
set p3.relative = true
set p4.relative = true
endmethod
endstruct
struct tests extends array
private static integer i = 100
private static Position p
private static real r = 0
private static integer is = 0
private static Position array pos
private static method ca takes nothing returns nothing
local integer x = is
loop
exitwhen x == 0
set x = x - 1
set pos[x].theta = pos[x].theta + .06283185
endloop
endmethod
private static method cr takes nothing returns nothing
local Position p2
local integer x = 50
set i = i - 50
if (i <= 0) then
set x = x + i
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
loop
exitwhen x == 0
set x = x - 1
set p2 = Position[CreateUnit(Player(0), 'hfoo', WorldBounds.centerX, WorldBounds.centerY, 180)]
set pos[is] = p2
set is = is + 1
call p2.lock()
set p2.origin = p
set p2.locked = true
set p2.theta = r
set p2.phi = 1.57079632
set p2.distance = 500
set p2.relative = false
set r = r + .06283185
set p2.z = is*5
endloop
endmethod
private static method onInit takes nothing returns nothing
set p = Position[CreateUnit(Player(0), 'hpea', WorldBounds.centerX, WorldBounds.centerY, 270)]
call p.lock()
set p.z = 500
call TimerStart(CreateTimer(), .03125, true, function thistype.cr)
call TimerStart(CreateTimer(), .03125, true, function thistype.ca)
endmethod
endstruct
struct tests extends array
private static constant integer A = 25
private static integer i = A
private static Position p
private static real r = 6.28318530/(A+0.)
private static integer is = 0
private static Position array pos
private static method ca takes nothing returns nothing
local integer x = is
local real h
local real m = p.x
local real v = p.y
loop
exitwhen x == 0
set x = x - 1
set pos[x].theta = pos[x].theta + .06283185
//set pos[x].phi = pos[x].phi + 0.1256637
//set h = pos[x].theta
//set pos[x].x = 250*Cos(h)+m
//set pos[x].y = 250*Sin(h)+v
endloop
endmethod
private static method cr takes nothing returns nothing
local Position p2
local Position p3
local integer x = 50
set i = i - 50
if (i <= 0) then
set x = x + i
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
endif
loop
exitwhen x == 0
set x = x - 1
//set p3 = Position.create(0,0,0)
set p3 = Position[CreateUnit(Player(0), 'hfoo', WorldBounds.centerX, WorldBounds.centerY, 180)]
set pos[is] = p3
set is = is + 1
call p3.lock()
set p3.origin = p
set p3.locked = true
set p3.theta = r+1.57079632
set p3.phi = r
set p3.distance = 200
set p3.relative = false
set r = r + 6.28318530/(A+0.)
set p3.z = 300/(A+0.)*is
/*
set p2 = Position[CreateUnit(Player(0), 'hfoo', WorldBounds.centerX, WorldBounds.centerY, 180)]
call p2.lock()
set p2.origin = p3
set p2.locked = true
set p2.theta = 0
set p2.phi = 1.57079632
set p2.distance = 0
set p2.relative = true
*/
endloop
endmethod
private static method onInit takes nothing returns nothing
set p = Position[CreateUnit(Player(0), 'hpea', WorldBounds.centerX, WorldBounds.centerY, 270)]
call p.lock()
set p.z = 350
call TimerStart(CreateTimer(), .03125, true, function thistype.cr)
call TimerStart(CreateTimer(), .03125, true, function thistype.ca)
endmethod
endstruct
static if LIBRARY_PositionOrigin then
if (o.va and l) then
return rot+o.facing
endif
endif
//
static if LIBRARY_PositionOrigin then
if (originOwner and o.va) then
return o.owner
elseif (isItem and IsItemOwned(item)) then
return GetOwningPlayer(GetItemOwner(item))
elseif (isUnit) then
return GetOwningPlayer(unit)
endif
else
//is handle type properties
public method operator isLoc takes nothing returns boolean
return type == LOC
endmethod
public method operator isUnit takes nothing returns boolean
return type == UNIT
endmethod
public method operator isDest takes nothing returns boolean
return type == DEST
endmethod
public method operator isItem takes nothing returns boolean
return type == ITEM
endmethod
public method operator isPos takes nothing returns boolean
return type == POSITION
endmethod
Why not just make "type" readonly?
