F_Damage

by Flick
Displays damage taken above a player or enemies head.
ID:1253889
 
BYOND Version:498
Operating System:Windows XP Home
Web Browser:Chrome 26.0.1410.64
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary: Every time I put the F_Damage code in for my mob, it comes up with the same error saying theres a Bad Argument Definition and it's always for something like 'obj' or 'world', etc. Does it have something to do with the atom or what ever?

Numbered Steps to Reproduce Problem: Place the code
F_damage(bug, "#FF5603", F_Damage.RIGHT_ALIGN)
into a new code file or at the bottom of a current one and it will bring up the error no matter what.

Code Snippet (if applicable) to Reproduce Problem:
F_damage(bug, "#FF5603", F_Damage.RIGHT_ALIGN)

And the error code is:
loading Devotion Online.dme
objects.dm:1:error: bad argument definition

Devotion Online.dmb - 1 error, 0 warnings (double-click on an error to jump to it)

But the error changes to something else such as main.dm for the same reason as soon as you delete the objects.dm file (just for debug purposes)

The code in objects.dm that it is bringing up an error is the word 'obj' at the beginning of the page

Expected Results:

Actual Results:

Does the problem occur:
Every time? Or how often? Yes
In other games? Yes
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur? When I don't put in the code, but then if I dont put in the code then I Im not even using F_Damage and I really want to.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) No

Workarounds: None
Can you provide a small project in a ZIP file, demonstrating this issue?

It sounds more to do with where you are calling F_Damage(), than a bug, per-say, but I need some kind of sample of how you're using it, from you to confirm that.
Its a procedure. You have to call it from another proc or a verb in code.
mob

verb
Ouch()
set desc="Causes up to 1000 damage to you."
F_damage(src, rand(-1000, -1), "#ff0000")


If you just place it by itself at the top of a .dm file, the compiler doesnt like it and you get the error you described. :)

Yours would generate a ''"[color] passed to F_damage is not a valid color' error since you skipped the value argument for the proc. It checks for color validity first, and 'F_Damage.RIGHT_ALIGN' is in the color position.

proc/F_damage(atom/Target, value, color = "#ff0000", F_Damage_Horizontal_Alignment/halign = F_Damage.CENTER_ALIGN)
Wow, thank you SO much Flick! I'm totally stupid haha. Works perfect now, i put it in as a proc for Ouch() as you said but for when the enemy attacks. Thank you!
One more thing, I got the hits working and all, but instead of your hits going over the enemy's head, it goes over your own. How can I fix this? Every time I replace src in F_damage(src, ---etc. it comes up with the ..is not at least an /atom... error when I attack in game. Here's my code that uses my Ouch() and F_damage procs:

mob

verb
Attack()
flick("attack",src)
for(var/mob/M in get_step(src,src.dir))
if (M == src) continue
var/Damage=rand(0,str)
damage=Damage
Ouch()
view(M)<<"[src] hit [M] for [Damage] Damage!"
M.TakeDamage(Damage,src)

mob

proc
Ouch()
F_damage(src, damage, "#ff0000")


But this code is the one that doesn't work when I replace src and add the var to Ouch():
mob

proc
Ouch(var/mob/Attacker)
F_damage(Attacker, damage, "#ff0000")


I had the same problem when trying to just use my var Damage by doing Ouch(var/Damage) and then replacing the value with Damage, but the same error happened. It all compiles fine though. So that is why I have the damage=Damage line in my Attack verb. Seems like anything I put it Ouch() never works and I don't know why... every other proc works like this.
There are all kinds of ways to set this up, and I'm not going to get into how you set up your attack stuff, but for what you have there, you would need to call the target 'M's Ouch proc. You could just do this in the targets TakeDamage() proc.
mob
proc
TakeDamage(damage, mob/attacker)
// Your stuff here...
F_damage(src, damage, "#ff000")


Something like that.