ID:171630
 
I have no idea where to start here except putting
mob/proc/Attack()


Could someone possibly demonstrate/guide me through the making of such proc to attack only whats in front of your mob(0 spaces away)? Maybe even show an overlay on the target?

~Zlegend~
ZLegend wrote:
I have no idea where to start here except putting
> mob/proc/Attack()
>

Could someone possibly demonstrate/guide me through the making of such proc to attack only whats in front of your mob(0 spaces away)? Maybe even show an overlay on the target?

~Zlegend~

You can use the get_step() proc to find the turf that's in front of your mob. Once you have that turf stored in a variable (let's call it T), you need to try and find something to attack in it.
// This attempts to find a /mob in the turf T. The first mob found is stored in M
var/mob/M = locate() in T
if(!M) return // Bail out if there's nothing found to attack


Once you have your /mob, /mob/monster, or whatever, you need to do the actual attacking. BYONDscape has some tutorials with basic attack procedures for causing damage, removing health, checking for death, etc.



If you want to show a targetting overlay over something, you can use image objects to do it. You'll need to create the image object, and you'll need a variable to store it in so you can easily delete it later.

mob/var
image/targetImage
target

// targettedMob is the "M" from earlier. This example doesn't show how to get it
mob/proc/Attack()
if(target != targettedMob) // If the mob being attacked has changed
target = targettedMob
del(targetImage) // Delete the old targetting overlay
targetImage = image('target.dmi', targettedMob)
// This creates an image from target.dmi which is placed on top of targettedMob
src << targetImage // Non-overlay images need to be specifically
// outputted to players
// Actual attacking goes here


That's an example of one (possibly buggy) way to show a targetting overlay over what you're attacking. It has some problems such as the overlay will stay on a mob until you attack another one. So a player could possibly run away from a battle, and come back later and see his targetting overlay on top of what he was attacking a while earlier.