ID:2675558
 
(See the best response by Magicsofa.)
Code:
obj/MouseDrag()if(istype(usr,/mob/Witch))mouse_drag_pointer=icon(src.icon,src.icon_state,src.dir)
obj/New()
..()
mouse_drag_pointer=icon(src.icon,src.icon_state,src.dir)
obj/MouseDrop(o_o,s_l,o_l)
if(usr.orbobjectdrag== 1)
if(usr.Freeze)
usr<<"Your frozen, you can't use magic"
return
if(isturf(o_l))
if(usr.Energy<=0)
usr<<"You don't have the energy to do this"
return
if(usr.MagicBound||WorldMagicBound)
usr<<"Your Magic doesn't seem to work, it's bound!"
return
if(usr.Selforb)usr<<"You can't do this while orbing."
else
walk_towards(src,o_l)
view(6)<<OrbTk
var/obj/A = new(locate(src.x,src.y,src.z))
A.layer = 1000
A.icon = 'magicgood2.dmi'
flick("orbobj",A)
sleep (3)
overlays = null
usr.Exposing_Magic()
view(6)<<OrbTk
view(6)<< "[usr] Scorves [src]"
usr:Energy -= 5
del A
return
else usr<<"You can't just drop this into your inventory!"


Problem description:
ok so I'm not too well versed in this so if you just want to send my a link to a page that can help me that would be great too! Basically, the verb works fine the issue is that currently, the icon i have 'flick((orbobj")' just places the icon over the obj(Like a chair or something) what I WANT it to do is the orb icon almost replaces the shape of the chair icon when you click drag it instead of just plopping on top of it. Hoping that makes sense, thanks!
Not totally sure what you're trying to do. If you want to change the icon of the chair, you can just set icon and icon_state instead of creating a new object:

icon = 'magicgood2.dmi'
icon_state = "orbobj"


Just for future reference, creating and deleting objects is taxing and should be avoided whenever possible. In this case it seems like just a visual effect, so it might be better to use an overlay or other method:

overlays += 'orb.dmi'
sleep(3)
overlays -= 'orb.dmi'


Also, looks like a potential typo here:
usr:Energy -= 5


The : path operator is kind of esoteric and allows you to attempt to access a variable that isn't strictly defined for the preceding object. It can be useful but most of the time, better to stick with the . operator. That will catch errors for you at compile time, whereas the : operator will allow you to write anything and then only give an error during runtime.
Ok so I fixed the : and used the . operator, thank you :). Now I'm not trying to change the icon_state. I want the overlay icon to fill the chair icon instead of just being slapped over it.
Here is an example taken from CRoM.

https://vimeo.com/542731735

You don't have to download anything it plays in the webpage incase you've never used vimeo.

But this seems insane to me and it's something I would definitely like to utilize but I don't even know where to start looking.
Best response
I see what you're saying. To be honest, it looks to me that they are still using icon_states to accomplish the effect. Say you have the icons 'Chair.dmi', 'Player.dmi', and 'Bowl.dmi'. All three of these icon files can contain icon_states with the same name. Then, you can access that state for each object and BYOND will display the one that's found in the icon currently assigned to that object:

obj
Chair
icon = 'Chair.dmi'
Player
icon = 'Player.dmi'
Bowl
icon = 'Bowl.dmi'

proc/OrbMe()
icon_state = "orb" //set to "orb" until you change it
//or
flick("orb", src) //change to "orb" until animation completes, then go back to previous state


If you set an object's icon_state to something that doesn't exist in the icon file, it will just show the default state, without giving an error.

This method is the most tedious because you have to manually draw the animation for each object. The advantage is that it doesn't need any snazzy programming or processing power to accomplish.

Creating this effect programmatically is a little more complicated. You could cover the object using particles, but you would need some method of knowing the opaque parts of the icon. This could be accomplished using GetPixel(), but scanning whole icons a lot could end up eating a bunch of CPU, and storing arrays for particle locations for every single icon might also get out of hand. If going the particle route, I'd personally just create a generic effect that can be applied to any object, but it wouldn't conform to the shape of the graphic like you want.

You could also do this with masking. To be honest, I'm not -super- well versed in this area myself. If you haven't already experimented with things like blend_mode and appearance_flags, I recommend you do so, because their uses can be kinda hard to wrap the brain around without seeing it firsthand. But you can check out this post to see what masking is and how its done:

http://www.byond.com/forum/post/2466493
I mean however they managed it I doubt the drew animation for each obj. I only showed a few, most items in game can be orb'd like that and they all do conform to the obj. Either way, I dont want to draw them all LOL. I will do as you suggest and look into masking. Thank you for your help! and if anyone has any other ideas please let me know!
To "mask" the effect to the visible pixels of the moving object, you can give the effect blend_mode = BLEND_INSET_OVERLAY, and give the moving object appearance_flags = KEEP_TOGETHER.

The result should look like this: https://imgur.com/897Ybfb

The thread about masking is outdated with the new simpler built-in masking options.
I got it to work, thank you guys! :D I never knew it would be that easy lol. Thank you ^^!
obj
wlTKorb
icon='wlTKorb.dmi'


obj/MouseDrag()if(istype(usr,/mob/Witch))mouse_drag_pointer=icon(src.icon,src.icon_state,src.dir)
obj/New()
..()
mouse_drag_pointer=icon(src.icon,src.icon_state,src.dir)
obj/MouseDrop(o_o,s_l,o_l) //make it so if an object has been dragged to someplace...
if(usr.orbobjectdrag) //make sure it's a Witch doing it.
if(usr.Freeze)
usr<<"Your frozen, you can't use magic"
return
if(isturf(o_l)) //making sure it was dropped on the map, and not in a statpanel or off the map
if(usr.Energy<=0)
usr<<"You don't have the energy to do this"
return
if(usr.MagicBound||WorldMagicBound)
usr<<"Your Magic doesn't seem to work, it's bound!"
return
if(usr.Selforb)usr<<"You can't do this while orbing."
else
overlays += new /obj/wlTKorb
appearance_flags = KEEP_TOGETHER
walk_towards(src,o_l)
view(6)<< "[usr] waves a hand, moving [src]"
view(6)<<OrbTk
sleep (5)
overlays = null
usr.Exposing_Magic()
view(6)<<OrbTk
usr.Energy -= 5
return

So this is what I'm using and it's working awesome! My only complaint is some objs in-game are too big for my wlTKorb overlay. How can I get rid of the icon but show the overlay when it's masking the obj, which I want invis haha. I've tried changing the icon/icon_state, playing with layers, setting invis of the obj. What happens is the obj moves but everything is invisible, including the icon.