ID:2084941
 
(See the best response by Rotem12.)
Code:
mob/Akimichi
verb
NikudanSensha()
set category = "Jutsus"
set name = "Nikudan Sensha"
if(usr.inbaika == 0)
usr<<"<font size=1><font face=verdana><b><font color=white> Você precisa usar Baika no Jutsu primeiro!"
return
if(usr.ingat == 1||usr.Kaiten == 1||usr.intank == 1||usr.firing)
return
else
var/list/O = usr.overlays.Copy()
view()<<"<font size=1><font face=verdana><b><font color=white>[usr]<font color=green> Says: Nikudan Sensha!"
usr.MN += 1
//usr.step_size = 64
usr.bound_height = 64
usr.bound_width = 64
usr.intank = 1
usr.overlays = usr.overlays.Remove(usr.overlays)
usr.icon='sensha.dmi'
if(usr.inchobaika)
var/matrix/M = matrix()
M.Scale(2)
animate(src, transform = M, time = 0)
usr.Move_Delay = 0
usr.firing = 1
var/cont = 300
while(cont > 0 && usr.intank)
//step(usr,usr.dir)
sleep(1)
cont -= 1
if(usr.inchobaika)
var/matrix/M = matrix()
M.Scale(3)
animate(src, transform = M, time = 0)
usr.icon='white.dmi'
usr.step_size = 32
usr.bound_height = 32
usr.bound_width = 32
usr.overlays = O.Copy()
usr.intank = 0
usr.Move_Delay = 1.2
usr.firing = 0



mob/Bump(mob/src)
..()
if(istype(src,/turf))
return
if(istype(src,/obj))
return
if(usr.intank)
usr.loc = locate(src.x,src.y,src.z)
var/Damage = round(usr.tai*20)
view()<<"[usr] acerta [src] com o Nikudan Sensha por [Damage]!"
src.health -= Damage
src.Death(usr)
else if(usr.inspike)
usr.loc = locate(src.x,src.y,src.z)
var/Damage = round(usr.tai*25)
view()<<"[usr] acerta [src] com o Nikudan Hari Sensha por [Damage]!"
src.health -= Damage
src.Death(usr)


Problem description:
When i use this skill, it turns my bound height/width to 64, and when i bump into someone, it damages then and move me to that person loc.
My problem is: if i bump two people at one time, depending on the position that i bump then, it goes kinda glitchy and warps me somewhere that i don't want it to go.
Here's a video:
https://youtu.be/Su1VTyT5QHI
Hope someone can help me ;-;
I didn't see a bug. Your mob's origin is at the bottom left and everything I saw lined up with that. Not sure what you are expecting, but you are going to have to manage that yourself in soft-code.
Lots of problems with this code.

if(usr.inbaika == 0)

If this value is only ever true or false, then this is wrong. You should put if(!usr.inbaika) instead. The reason is, you don't want to rely on the value being strictly a number.

if(usr.ingat == 1||usr.Kaiten == 1||usr.intank == 1||usr.firing)

This is the same deal. That should be if(usr.ingat || usr.Kaiten || ...), because you only want to see if the var is true. However, when you have an if() with multiple bailout conditions like this, representing player states, this is a sign of a serious design flaw. You should change these states to use a set of bitflags instead, so you only need one var instead of a hundred of them.

mob/Bump(mob/src)

Never use "src" as the name for a proc argument or a local var. You already have a var named src, and you need it. The argument is the atom you bumped into, so name it something meaningful like "obstacle". Or, give it a simple name like A or M. Do not call it src.

if(usr.intank)

This is just one of many lines in your Bump() proc that is misusing usr. Bump() is a proc, not a verb, and therefore it is not usr-safe. Do not use usr here. The only things you need to care about are src (the actual real src, which is your mob that tried to move), and the argument (the obstacle it bumped into).
Ok, fixed these... But the problem is still happening :v

FKI wrote:
I didn't see a bug. Your mob's origin is at the bottom left and everything I saw lined up with that. Not sure what you are expecting, but you are going to have to manage that yourself in soft-code.


Yeah, i thought so to... But the strange thing to me is that the warp-thing only happens in specific cases...
Best response
Imagine each - is a tile, we'll mark the actual loc with +

This is your mob:
--
+-

This is the mob you're bumping:
-- --> +
+-

Let's swap them! By swap them, I mean let's swap their locs:
       --
--> +-
+

I hope this is enough visuals to help explain your problem, the loc is always at the bottom left, not the center, however you still have 3 tiles you are standing on that aren't your loc, when those tiles bump just about anyone, you'll instantly "warp".

How can you solve it? As FKI said, you can write more code to handle it inside Bump(), you know the bound_height/width, you can get the direction of the bump with get_dir(), now you can make adjustments when setting the loc to properly set bottom left loc to where it should be.

It'll basically be -/+1 for either x, y or both.



This is unrelated to your current problem but wouldn't hurt:
                usr.overlays = usr.overlays.Remove(usr.overlays) // to remove all overlays, just do overlays = list()
...
...
...
usr.overlays = O.Copy() // the overlays were already copied into a list, there's no need to copy the copied list. You can just do overlays = O
usr.intank = 0
usr.Move_Delay = 1.2
usr.firing = 0


Although usr is correct in the verb, I'd get rid of it just on general principle and usr src; since it's a mob verb, usr = src is implied unless you change it.

For clarity I also advise against writing src.var or src.proc() everywhere, because unless you have a local or global var with the same name, the fact that it's a src var is readily apparent; the src. addition just clutters the code.
Oh, thanks for the help guys, i just solved the problem, thanks a lot o/