ID:134338
 
Okay, whilst developing my current game, which features tanks, I found the need to make overlays turn towards an object but not just instantly face the object, as the current Turn can allow. I wanted the tanks barrel to slowly turn to face the enemy, for a semi-realistic look I guess. But I was saddened to find no such available feature, from where I looked in the "turn" involved coding.

So therefore I want to suggest a new feature:

Format:
turn_towards(Ref,Dir,Angle)

Returns:
The rotation of an object towards.

Args:
Ref: A mob or obj.
Dir: One of NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST.
Angle: An angle in degrees. Positive value turns the src towards ref. Negative value turns src away from ref.

Example:

var/mob/M
for(var/mob/Enemy/L in world)
M = L
src.dir = turn_towards(M,NORTH,45) //dir = Northwest towards M
src.dir = turn_towards(M,NORTH,-45) //dir = Northeast away from M



Simply use get_dir() and turn() to acheive the same effect.
turn(get_dir(src,ref),angle)


Or if you really must hve this procedure:
proc/turn_towards(loc1,loc2,dir,angle) turn(get_dir(loc1,loc2),dir,angle)

In response to Popisfizzy
Oh I know how to code it, just thought it'd be nice to make it easier.

Also:

turn(get_dir(loc1,loc2),dir,angle)


won't work. You can only havetwo arguements in the turn, not three.
In response to FinalFantasyFreak
If the staff added in every little thing that every person could program easily, it would be another decade before 4.0 came out.
In response to Popisfizzy
There's not much more they can add.... Not like they're going to add on a code just to create text. But they did make "walk_towards" and the like, so it'd be right to make a "turn_towards."
FinalFantasyFreak wrote:
Example:

var/mob/M
> for(var/mob/Enemy/L in world)
> M = L
> src.dir = turn_towards(M,NORTH,45) //dir = Northwest towards M
> src.dir = turn_towards(M,NORTH,-45) //dir = Northeast away from M


Of course, that proc makes no sense at all. From your first usage, it would basically mean to "turn counter-clockwise 45° from NORTH, to M." Now, a 45° rotation from NORTH is pretty constant; it's NORTHWEST.

However, you can write your own function to handle this task:
proc/turn_towards(atom/ref, atom/targ, wait=0, angle=45)
if(!(angle-angle%45) || !ref || !targ)
return 0
var/endDir = get_dir(ref, targ)
var/totalTurn = 0
while(ref.dir != endDir && totalTurn < 360)
ref.dir = turn(ref.dir, angle)
totalTurn += angle
sleep(wait)


Hiead
In response to Hiead
Now your comment made no sense. Did you even bother to read what I said? No, of course you didn't. Angles in this proc would be meaningless because the game would be turning you towards the object. However, I wanted the proc to let you decide if you'd be turning in the opposite direction or actually towards it, and at how many degrees (because not all games will use northeast and the like). So what did I do? I said this:

Angle: An angle in degrees. Positive value turns the src towards ref. Negative value turns src away from ref.

Read the bold part. I clearly said that positive turns you towards the ref. and negative away from. This would give the user more control and is more easily controlled. Also, please read my other posts. My entire reason for suggesting this is not for myself, as I can code the thing later if I want to, tanks aren't dire at the moment in my game, it's for those users that aren't as fluent in programming as we might be that'd have trouble with this. I'm sorry if you didn't read my very fine print, but I am only refering you to my previous statements.
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
My entire reason for suggesting this is not for myself, as I can code the thing later if I want to, tanks aren't dire at the moment in my game, it's for those users that aren't as fluent in programming as we might be that'd have trouble with this.

If procs like that would be useful to other users, somebody could make a library of them.
In response to FinalFantasyFreak
[Ignoring the part where you totally attacked Hiead for no obvious reason...]

FinalFantasyFreak wrote:
My entire reason for suggesting this is not for myself, as I can code the thing later if I want to, tanks aren't dire at the moment in my game, it's for those users that aren't as fluent in programming as we might be that'd have trouble with this. I'm sorry if you didn't read my very fine print, but I am only refering you to my previous statements.

This procedure is extremely easy to implement in soft-code.

In general, BYOND does not integrate easy features into the language -- it integrates features which cannot be accomplished in soft-code or which are prohibitively difficult to track in soft-code. For instance, an "atom/Bumped()" proc is a very simple construct which hasn't been implemented as a standard function because there's no point in doing so.
In response to Jtgibson
Attacked him? I was only repaying him for not reading my entire post and then insulting me...
FinalFantasyFreak wrote:
Okay, whilst developing my current game, which features tanks, I found the need to make overlays turn towards an object but not just instantly face the object, as the current Turn can allow. I wanted the tanks barrel to slowly turn to face the enemy, for a semi-realistic look I guess. But I was saddened to find no such available feature, from where I looked in the "turn" involved coding.

So therefore I want to suggest a new feature:

Format:
turn_towards(Ref,Dir,Angle)

Returns:
The rotation of an object towards.

I've already written a proc that does this in [link]. It can be generalized further to allow you to simply put in a target direction, not a target atom.

Lummox JR
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
Attacked him? I was only repaying him for not reading my entire post and then insulting me...

I saw no insult on his part and thus no insult to "repay". Besides, "repay" is just another word for "attack" in this context. Even if he did "attack" you, a counter-attack is also an attack. =P
In response to Jtgibson
He seems to be attacking everyone, just read a recent blog comment he made: http://members.byond.com/?command=view_comments&post=21514

And yes he did attack me, perhaps not directly, but he intended to hurt my programming pride (if you know what I mean): "Of course, that proc makes no sense at all." And then he didn't even read my entire explanation!
In response to FinalFantasyFreak
He knows Branks, that was just a playful comment. And he was right, that snippet you posted made NO sense. Maybe if you aren't too keen on finding out you aren't such the hotshot you think you are, maybe try avoiding showing snippets.
In response to Papoose
And maybe if you actually read my comment (and go to it now if you need to, I understand), then you would have clearly seen that I very obviously made it clear what my intentions were. Read under the Args, last few lines. Anmd also, after being on BYOND for 4-5+ years I think I deserve some sort of right to call myself a good programmer (I've been programming that long here as well FYI). You however appear to have just joined in March. Do you happen to have any other keys to prove that you're not a total newbie to BYOND?
In response to FinalFantasyFreak
My time on BYOND is irrelevant, so what if I have an older key(s). And with programming practices like the one below, you have no right to even think you're a good programmer.
var/mob/M
for(var/mob/Enemy/L in world)
M = L

In response to Papoose
Based on your lack of explanation, I assume that that's your evidence. Examples (for the F1 key in BYOND DM) are put in the simplest, easiest terms for any BYONDer to understand. Newbie or not. Using M after you already defined M wouldn't give a full explanation as to what's happening. Sure, purhaps to a lot of coders, but they are out-weighed by all the non-coders that need a quick explanation.

Oh yeah, and I have no right to call myself a coder? Okay, look up my game Hurricane. I've had many people try and recode it and fell with their server crashing due to all the procs being run. You think you're a better coder, prove them wrong and make a game like that. FYI, at any given time in the game (1 minute in to it), there are about 1000+ (I'd estimate in the 4000's, but since I'm nopt sure, I'm going with what I know for sure) objects calling for proc activation and resolution. Try making that not lag in a decent server, I nearly reduced all the lag.

I have more examples if you want a challenge, just ask. Unforutunately I do not have all their source codes or files themselves (worms and hackers crashing your computer three times sucks), but I can explain what the game did.
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
Based on your lack of explanation, I assume that that's your evidence.

If this is in connection to Papoose's BYOND activity period, he's been here for a while. Papoose is obviously not his first key.

Please not that the examples are put in the simplest, easiest terms for any BYONDer to understand. Newbie or not.

This is not the point he's making. Simple terms does not mean a crud program. What reason is there to loop through every /mob/Enemy and assign it to the same variable? Since there's no control of order, the first iteration is just as good as the last, so you may as well simply use locate() to snag it.

Oh yeah, and I have no right to call myself a code?

No response there. I'm a code, too.

Okay, look up my game Hurricane.

This isn't a competition, as far as I know. Nor is this the place for an ego bout from anyone.

On a lighter note, I don't see where I've insulted you as was implied in [link]. Nor do I see a need for you to continue to badger others for trying to point out that this function is not needed. If you've felt insulted, then I am sorry. I was just pointing out the nonsensical points in this request and, as Mr. Gibson clearly said, BYOND doesn't include simple features. turn_towards() is a simple feature, and is unneeded.

Hiead
In response to Hiead
I was typing with my two middle fings, seems weird I guess, but the other fingers all had this thing on them that I didn't want to touch my new keyboard.

So turn_towards is too simple? Then I take it step_towards is too simple? Walk_towards is too simple? Yes, they are, but did the BYOND staff include them? Yes they did, because while they're simple, they're very useful in certain games. As is turn_towards.

As for the /mob/Enemy thing, I was making that quick, I had to go somewhere. Sure I could have made it semi-complex and made it define a certain point, but I found no need as the mob/Enemey clearly defines that you'll be turning towards that one enemy, or multiple. Though I meant for the example to only use one. Now, please don't respond to this again if you're only going to insult me for posting a logical suggestion. Notice how this sub-forum WAS designed for suggestions also.
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
Anmd also, after being on BYOND for 4-5+ years I think I deserve some sort of right to call myself a good programmer (I've been programming that long here as well FYI). You however appear to have just joined in March. Do you happen to have any other keys to prove that you're not a total newbie to BYOND?

FYI, chill out for pete's sake. FYI, nobody gives a damn when they or another person joined. FYI SHUT
Page: 1 2