ID:2670577
 
Code:
 M << output("<center><b><font color = [usr.textcolor]>(Effect: [src.Effect]) Damage: (<a href='?src=\ref[src];cmd=damage'>Damage</a>)","IC")

mob/Topic(href,href_list[])
switch(href_list["action"])
if("damage")
var/tmp/damage1 = DamageCalc(src.strength, src.dexterity, usr.endurance, usr.agility)
usr.stamina -= damage1


Problem description:

Code above has been doctored simply for ease of viewing, but problem lies in how I'm attempting to make damage work through hyperlink in a project I'm working on.

Essentially, when a player uses an "obj/technique" in their contents, it outputs a bunch of text, and by clicking on this hyperlink I'd like other players to be able to accept damage.

So I need to access the variables of the player who activated the object, for attacking stats (strength and dexterity) and defender's stats (endurance and agility) for the time being.

I'm getting no error readouts, no runtime errors, and am genuinely at a loss after reading the documentation if there's a way around this beyond simply storing these stats inside of "obj/technique" on use so I can refer to the object directly as a source for variables.
mob/proc/Example(mob/target)
src << "<a href=?src=\ref[src]&target=\ref[target]>ATTACK</a>"


mob/Topic(_,list/l)
var mob/attacker = locate(l["src"])
var mob/defender = locate(l["target"])
world << "[attacker.name] attacks [defender.name]!"
In response to Kozuma3
The above may not be exactly be correct, since the source of the command is a obj/technique/verb.

But it does give me an idea, where on use of the verb I could create a target variable, and use that as the src. Along the lines of.
obj/technique
verb
Use()
var/mob/target = usr
src << "<a href='?src=\ref[target]'>ATTACK</a>"


mob/Topic(_,list/l)
var attacker = locate(l["target"])
var defender = usr
world << "[attacker.name] attacks [defender.name]!"


Since upon clicking the hyperlink, "usr" should refer to the person clicking it. The only data I'm missing is the attacker's and should be able to point to them in this manner?
In response to Kozuma3
Update on this: I've decided to simply store the data needed on every case that the use command is activated, though I was hoping there was a more efficient way to do so.

The data handling of this was wonky because I was using mob/Topic instead of obj/Topic

My working version is as follows

obj
Technique
var/pow=0
var/crit=0
Use()
pow=usr.strength
crit=usr.dexterity
usr << "(<a href='?src=\ref[src];cmd=damage'>Damage</a>)"

obj/Topic(href,href_list[])
switch(href_list["cmd"])
if("damage")
var/tmp/damage1 = DamageCalc(src.pow, src.crit, usr.endurance, usr.agility)
usr.stamina -= damage1
usr << output("[usr.name] has taken [DamageText(damage1)] damage from [src.name]'s attack!")


I'd still prefer not to store the data in the src object if possible, is this possible?
You could pass the pow/crit into the a href tag as well.
The "src=\ref[src]" part of the link can be changed to any reference. It determines whose Topic() proc gets called. In Topic(), usr is the mob who clicked the link. Also, the href_list list is an associative list of the parameters passed in the link after "src". You're checking for "action" in your Topic(), but as you found, you should have been checking for "cmd".

If you want the technique user's Topic() called, then you pass usr as the src of the link.
obj/technique
verb/use()
// src is the technique, usr is the user of the technique.
// Pass usr as the src of the topic link, so that usr's Topic() gets called.
world << "<a href=\"?src=\ref[usr];action=damage\">damage</a>"

mob
Topic(href, list/hrefs)
..()
// "action" here needs to match action=damage from above.
if(hrefs["action"] == "damage")
// src is the user of the technique.
// usr is the mob who clicked the link.