I'm working on a project, and one of the features I would like to add in is a pull mode. You know? Click on a button to turn the mode on then click another obj and the player's mob will start dragging the object the automatically with it following behind the mob, then click on the obj again to stop pulling it. I've seen many games with it, so I know it's possible somehow. I looked everywhere for some sort of tutorial or library and on the forums, but I found absolutely nothing. Can someone help me get started with a proc or something so I know where to go? Also, once I find something, would I be able to adapt it into a follow mode (turn on the follow then use it to have the player mob follow another mob)?
Thanks in advance!
ID:157505
![]() Feb 25 2010, 10:33 am
|
|
This is how I'd implement it.
obj |
Fixing a typo before they come back because "it doesn't work".
proc/Pull(atom/newloc, mob/m) You can simplify your PullSwap() proc by using the ? operator. proc/PullSwap(obj/o) |
Ulterior Motives wrote:
Also you can simplify your PullSwap() proc by simply using the ? operator. > proc/PullSwap(obj/o) Yes, you can, but that doesn't make it any easier for newbies to understand. |
Popisfizzy wrote:
Yes, you can, but that doesn't make it any easier for newbies to understand. because your code was so newbie friendly to begin with |
This proc will first check to see if the player is close to the object, within one tile. Then it checks to see if the player is already pulling the object. If they are, it stops pulling it.
If they weren't already pulling the object, then it stops pulling anything the player may have been pulling before, and then starts pulling the object that was just clicked.