ID:148282
 
client
// Attack
Click(O)
var/mob/pc/M = usr
if(istype(O, /mob/mon)in view(M.attrange))
call(O, /mob/mon/proc/Dead)()
..()


Here is my code.. it compiles fine.. but what I need it to do is disable the Click of Death until the O is within M.attrange of the person's mob/player. If so then it makes that call of death. Just trying to combine a bit here.

LJR
1. What the hell is istype() doing there? That won't work ... =P

2. Why are you using call()?

3. I'll fix it up for you...

<code>client // Attack Click(mob/mon/O) var/mob/pc/M = usr if(istype(M) && istype(O)) if (O in view(M, M.attrange)) //Click of Death O.Dead() else //Call of Death walk_to(O,M) ..()</code>
In response to Crispy
Crispy wrote:
1. What the hell is istype() doing there? That won't work ... =P

2. Why are you using call()?

3. I'll fix it up for you...

<code>client > // Attack > Click(mob/mon/O) > var/mob/pc/M = usr > if(istype(M) && istype(O)) > if (O in view(M, M.attrange)) > //Click of Death > O.Dead() > else > //Call of Death > walk_to(O,M) > > ..()</code>

Your istype() calls are whacked.
In response to Deadron
Deadron wrote:
Your istype() calls are whacked.

I thought so too until recently. Apparently this one-argument syntax works to check a var against its reported type.

Lummox JR
LordJR wrote:
client
// Attack
Click(O)
var/mob/pc/M = usr
if(istype(O, /mob/mon)in view(M.attrange))
call(O, /mob/mon/proc/Dead)()
..()

Why is this in client/Click() instead of mob/mob/Click()?

Why did you think istype() here would work when it will work out to be if(1 in view(...)) or if(0 in view(...))?

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Deadron wrote:
Your istype() calls are whacked.

I thought so too until recently. Apparently this one-argument syntax works to check a var against its reported type.

Yup yup. It would probably be slightly more robust to define Click()'s argument as an /atom, but it's slightly less to type this way. =)