ID:2103654
 
Code:
mob/proc
Basic_Combat_Hit(Attack_Number)
for(var/mob/M in get_step(src,src.dir))
if(M==src)return
src.exp_tai+= rand(3,5)
src.Level_Up()
M.Recieve_Physical_Damage(src,src.Taijutsu*src.Tai_Boost,M.Vitality*M.Vitality_Boost,0.5,Attack_Number,"Punch")
return


Problem description:
The problem here is, when i stand next to another player/mob the for(var/mob/M in get_step(src,src.dir)) proc isn't always called. i have to stand in a certain position, or on exactly the same pixel location as the other player i believe. i know it has to do with pixel movement and the platforming system I am using, but doesn't anyone know a better way to do this or whatever may help?
Ur returning for no reason in some cases also you would benefit from looking up bounds() and trying to make damage boxes instead of relying on get step
Hmm, I'm would new to bounds() care to explain more on how it works? & i actually solved the issue another way with bound_x,bound_y vars but im interested in bounds()
The if(M==src) line should be a continue, not a return; what you want to happen in that case is to keep looping, but simply ignore src as a target. You probably also don't want to simply stop, if for any reason two mobs are in front of you, so that last return line should be removed as well.

And of course get_step() will return a turf. You may be in that turf's contents, and your target may not. So bounds() is the way to go. Specifically, you want this version:

bounds(Ref, x_offset, y_offset, extra_width=0, extra_height=0)

So I'd redo the loop like so:

var/dx=0, dy=0, b
b = min(bound_width, bound_height)
if(dir & (NORTH|SOUTH)) dy = (dir & NORTH) ? b : -b
if(dir & (EAST|WEST)) dx = (dir & EAST) ? b : -b
for(var/mob/M in obounds(src,dx,dy))
exp_tai += rand(3,5)
Level_Up()
M.Recieve_Physical_Damage( ... )

That setup will offset your bounding box by a certain amount in whatever direction you're facing, and look for mobs other than yourself in that new bounding box. (The if(M==src) line can therefore be removed entirely, because this is using obounds().)

This can be altered in a number of interesting ways; like for instance you can have a weapon that hits wider bounds or reaches out further. I simply based the reach on your own bounds, and didn't alter the size of the box at all.
Thank you Lummox! great help indeed, but if i may ask. i'm not completely sure what this mean't. " ? b : -b"
The ? : operator is a conditional.

Whenever you see a ? b : c, it means that when a is true, b is the result of that expression; otherwise, c is the result.
Oh ok, i figured, just had to make sure. Thank you, you're a great help and everything is running smoothly.
In response to Lummox JR
Lummox JR wrote:
This can be altered in a number of interesting ways; like for instance you can have a weapon that hits wider bounds or reaches out further. I simply based the reach on your own bounds, and didn't alter the size of the box at all.

How would you alter the size of the box? It won't let me pass extra_width/height into the arguments for obounds()
In response to SolarOblivion
What's the code you're using to alter the width and height? Those arguments should simply drop in.
In response to Lummox JR
Lummox JR wrote:
What's the code you're using to alter the width and height? Those arguments should simply drop in.

proc/get_front(atom/movable/Ref)
var/dx=0, dy=0, b
b = min(Ref.bound_width, Ref.bound_height)
if(Ref.dir & (NORTH|SOUTH)) dy = (Ref.dir & NORTH) ? b : -b
if(Ref.dir & (EAST|WEST)) dx = (Ref.dir & EAST) ? b : -b
return obounds(Ref,dx,dy)


I just used the example you gave to Anime HQ to create a universal proc that I can use as a faux "get_step(ref,ref.dir)" (usable in for loops for the same purpose). My world's icon size is 16x16 but my players have 16x10 bounding boxes with 32x32 icons (allows them to approach things northward in a more visually-accurate way with the foreshortened bound box height). However, for the sake of correct calculations, I want the simulated bound box to be a full 16x16. Wouldn't let me pass the extra height into the return obounds() though. Also tried changing b to 16
In response to SolarOblivion
What do you mean when you say it wouldn't let you pass the extra width/height, though? What code did you use when you tried to do that?
In response to Lummox JR
Lummox JR wrote:
What do you mean when you say it wouldn't let you pass the extra width/height, though? What code did you use when you tried to do that?

I realized it was because I tried to pass in named arguments; it allowed it when I simply passed in integers (return obounds(Ref,dx,dy,2,2) for example)

However, I'm still not sure how to simulate a 16x16 bounding box in front of Ref. I created a system to show the bounds of movable atoms using DrawBox() for the sake of giving you a visual example of my last comment:
Image and video hosting by TinyPic
Image and video hosting by TinyPic

EDIT: Changing b to 16 actually DID achieve the desired result; thanks for your help Lummox
If you want to always have the bounding box in front be a specific size:

proc/get_front(atom/movable/Ref,w,h)
var/dx=0, dy=0, b
var/d = get_dir(src, Ref)
if(!w) w = bound_width
if(!h) h = bound_height
if(d & (NORTH|SOUTH))
dy += (d & NORTH) ? bound_height : -h
if(!(d & (d-1))) dx += round((bound_width-w) / 2)
if(d & (EAST|WEST))
dx += (Ref.dir & EAST) ? bound_width : -w
if(!(d & (d-1))) dy += round((bound_height-h) / 2)
return obounds(Ref,dx,dy,w-bound_width,h-bound_height)/dm>
If you call that without the w and h arguments, then the original bounding box size is used. Otherwise, it adjusts to the size you want.
In response to Lummox JR
Lummox JR wrote:
If you want to always have the bounding box in front be a specific size:

...

If you call that without the w and h arguments, then the original bounding box size is used. Otherwise, it adjusts to the size you want.

Awesome. Only issue now is that during testing, EAST and WEST boxes are behaving a little weird. If the bottom of my bounding box is touching another bound but I'm facing East/West, it's displacing the simulated bounding box 1 pixel down. Because I know that sounds a bit convoluted, I attached a visual example. In my project, you're able to push,lift, and drop boxes. In the first picture, it shouldn't allow me to drop a box there because my simulated 16x16 bounding box should overlap the orange wall (which is why the green box overlaps). In the second picture, it SHOULD but doesn't allow me to drop a box in front of myself.
Image and video hosting by TinyPic
Image and video hosting by TinyPic
Anime HQ wrote:
Code:
> mob/proc
> Basic_Combat_Hit(Attack_Number)
> for(var/mob/M in get_step(src,src.dir))
> if(M==src)return
> src.exp_tai+= rand(3,5)
> src.Level_Up()
> M.Recieve_Physical_Damage(src,src.Taijutsu*src.Tai_Boost,M.Vitality*M.Vitality_Boost,0.5,Attack_Number,"Punch")
> return
>

Problem description:
The problem here is, when i stand next to another player/mob the for(var/mob/M in get_step(src,src.dir)) proc isn't always called. i have to stand in a certain position, or on exactly the same pixel location as the other player i believe. i know it has to do with pixel movement and the platforming system I am using, but doesn't anyone know a better way to do this or whatever may help?

you havent been on byond for awhile have you?, lol.
In response to Lummox JR
Lummox JR wrote:
...

After trial and error, testing in my "debug mode" and gaining understanding of the code you and Kaochao swung me, I finally get what's happening. The player's displaced bound box during the get_front() check is being centered from the player's existing bound box, which is why the problems in my pictures are happening. Now that I know what's going on, how would I be able to tell get_front(), to align the bottoms of the existing and displaced bound boxes when the player is facing East/West?

...or should I just uncomplicate my life by giving players a proper 16x16 bound box? xD