ID:1199023
 


What I want: Think of it as a lawnmower attack. Players toggle horn() on and off. If toggled, should be facing in front of player at all times.

Image and video hosting by TinyPic
Code:
/////////////////////////////////////// trigger  ////////
ATTACK5(player/p)
if(!p.horse_mode) return //if not a horse do not let use 5th attack.
if(!p.horns)
world <<"horn should appear"
p.start_attack()
p.horns = new/combat_obj/antelope/horns(p)
else
world <<"NO HORNS"
del p.horns
p.stop_attack()
/////////////////////////////////////////////////////////////////
mob
Move()
if(src.horns) //If antelope horns activated
src.horns.SET_BOUNDS()
src.horns.refresh()
usr <<" TRUE"
..()
combat_obj
antelope

New(player/p)
..()
// SET_BOUNDS()


DAMAGE()
for(var/player/p in obounds(src))
if(p.team == owner.team||p.dead) continue
DAMAGE(owner,p)

SET_BOUNDS()
loc = owner.loc
dir = owner.dir
step_x = owner.step_x
step_y = owner.step_y
horns
icon = 'ant_horns.dmi'
layer = FLOAT_LAYER

New(player/p)
owner = p
owner.horns = src
world << "Horn owner = [owner]"
SET_BOUNDS()
..()

Del()
world << "delete is being called"
..()
proc
refresh() //pointless
owner.overlays -= src
owner.overlays += src

SET_BOUNDS()
..()
world <<" dir = [dir] "
switch(dir)
if(NORTH)
bound_x=32
bound_y=4
bound_height=48
bound_width=5
step_x+=16
step_y+=70
if(SOUTH)
bound_x=32
bound_y=12
bound_height=48
bound_width=5
step_x+=16
step_y-=43
if(EAST)
bound_x=4
bound_y=29
bound_height=5
bound_width=48
step_y+=9
// step_x+=70
step_x+=300
pixel_x+=300
if(WEST)
bound_x=12
bound_y=32
bound_height=5
bound_width=48
step_y+=6
step_x-=40


Problem description:
Icon wont refresh to proper location. Icon only keeps offsets of original "dir"(where your facing when you started the attack). It does not use the offsets for other directions #SET_BOUNDS().

It pretty much just rotates N/S/E/W like a normal icon only it ignores the bound offsets that are supposed to happen.
Are you saying the overlay doesn't rotate at all? Implied by your first sentence, or is the overlay's bounds inconsistent with the players direction, stated in the latter.

To solve your bounding issue, it would help if SET_BOUNDS() received the correct information relating to the player.

mob
Move()
..() //move the player first before calculating bounds
if(src.horns) //If antelope horns activated
src.horns.SET_BOUNDS()
src.horns.refresh()
usr <<" TRUE"
Hulio-G wrote:
What I want: Think of it as a lawnmower attack. Players toggle horn() on and off. If toggled, should be facing in front of player at all times.

Image and video hosting by TinyPic
Code:
/////////////////////////////////////// trigger  ////////
> ATTACK5(player/p)
> if(!p.horse_mode) return //if not a horse do not let use 5th attack.
> if(!p.horns)
> world <<"horn should appear"
> p.start_attack()
> p.horns = new/combat_obj/antelope/horns(p)
> else
> world <<"NO HORNS"
> del p.horns
> p.stop_attack()
> /////////////////////////////////////////////////////////////////
> mob
> Move()
> if(src.horns) //If antelope horns activated
> src.horns.SET_BOUNDS()
> src.horns.refresh()
> usr <<" TRUE"
> ..()
> combat_obj
> antelope
>
> New(player/p)
> ..()
> // SET_BOUNDS()
>
>
> DAMAGE()
> for(var/player/p in obounds(src))
> if(p.team == owner.team||p.dead) continue
> DAMAGE(owner,p)
>
> SET_BOUNDS()
> loc = owner.loc
> dir = owner.dir
> step_x = owner.step_x
> step_y = owner.step_y
> horns
> icon = 'ant_horns.dmi'
> layer = FLOAT_LAYER
>
> New(player/p)
> owner = p
> owner.horns = src
> world << "Horn owner = [owner]"
> SET_BOUNDS()
> ..()
>
> Del()
> world << "delete is being called"
> ..()
> proc
> refresh() //pointless
> owner.overlays -= src
> owner.overlays += src
>
> SET_BOUNDS()
> ..()
> world <<" dir = [dir] "
> switch(dir)
> if(NORTH)
> bound_x=32
> bound_y=4
> bound_height=48
> bound_width=5
> step_x+=16
> step_y+=70
> if(SOUTH)
> bound_x=32
> bound_y=12
> bound_height=48
> bound_width=5
> step_x+=16
> step_y-=43
> if(EAST)
> bound_x=4
> bound_y=29
> bound_height=5
> bound_width=48
> step_y+=9
> // step_x+=70
> step_x+=300
> pixel_x+=300
> if(WEST)
> bound_x=12
> bound_y=32
> bound_height=5
> bound_width=48
> step_y+=6
> step_x-=40
>

Problem description:
Icon wont refresh to proper location. Icon only keeps offsets of original "dir"(where your facing when you started the attack). It does not use the offsets for other directions #SET_BOUNDS().

It pretty much just rotates N/S/E/W like a normal icon only it ignores the bound offsets that are supposed to happen.

I have experience with this and once you set an overlay, it's pixel_x or pixel_y cannot be altered. You would have to remove the first overlay, and set the bounds on the next, then add that again .

Manually that would mean you'd have to add the first overlay in the direction you want the character facing, show that attack animation, then remove overlay 1, turn to direction 2, apply overlay 2, remove overlay 2, turn to direction 3.


Or as a simpler approach to fixing it, somehow edit the single overlay's directions to fit what you need them to look like . This might require you to make the overlay larger than it already is, but technically it would be worth it since this is alot easier than the described method up above.

icon size is 32x32 for instance. Your overlay would normally be the same size, but if you make the overlay say, 128x128, then position the overlay based on where your character would be in the center of the picture, you could then set the pixel_x and pixel_y and align the overlay before you apply it. In this way, the overlay will look correct and since it's transparent it won't matter that the size is much larger than your character.