ID:173682
 
Ok I made a healing spell and it uses the click proc

obj/magic/Heal1
name = "Minor Healing"
icon = 'Spellicons.dmi'
icon_state = "Recovery"
Click()
if(usr.MP>=2)
if(usr.Casting == 1)
usr<< "You cannot perform this action now because you are currently casting a spell!"
else
if(usr.Death == 0)
for(var/mob/M in view())
And it heals all in site but I dont want that I wanter the user to have to choose what mob to heal if you could help thanks
Darkfirewolf5 wrote:
Ok I made a healing spell and it uses the click proc

obj/magic/Heal1
name = "Minor Healing"
icon = 'Spellicons.dmi'
icon_state = "Recovery"
Click()
if(usr.MP>=2)
if(usr.Casting == 1)
usr<< "You cannot perform this action now because you are currently casting a spell!"
else
if(usr.Death == 0)
for(var/mob/M in view())
And it heals all in site but I dont want that I wanter the user to have to choose what mob to heal if you could help thanks

The input() function can by handy (and ugly!) for choosing a particular mob. For example:

var/mob/Target = input("Which mob to heal?") in view()
This would give you a list of all of the mobs in src's view.

Check out the reference of input() for more info.
In response to Malver
It not working right its shows the turfs,objs, and mobs is there a way I can fix this?
In response to Malver
There is, however, a more elegant solution:
mob
var/obj/magic/curSpell
Click(atom/A)
if(curSpell)
curSpell.action(src, A)

obj/magic
var/cost
Click()
if(usr.MP>=cost)
if(usr.curSpell)
usr<< "You cannot perform this action now because you are currently casting a spell!"
else
if(usr.Death == 0)
usr.curSpell = src
usr.client.mouse_pointer_icon = 'casting.dmi'
proc
action(mob/caster, atom/A)

obj/magic/Heal1
name = "Minor Healing"
icon = 'Spellicons.dmi'
icon_state = "Recovery"
cost = 2
action(mob/caster, mob/M)
if(ismob(M))
M.heal(10)
else
caster.MP += cost
caster.curSpell = null


Then, for any spell, you just have to override action() to do what you want. Spells that don't need a target can override Click().
In response to Garthor
Do any of those have a popup that you select a mob?
In response to Darkfirewolf5
No. The way it works is that you click on the spell you want to cast, then click on the target. If the target is invalid, then you simply get your mana back and nothing happens.
In response to Darkfirewolf5
Darkfirewolf5 wrote:
It not working right its shows the turfs,objs, and mobs is there a way I can fix this?

Yep. You can specify what type to include using the as keyword. Another example:

var/mob/Target = input("What mob to heal?") as mob in view()