Page 1 of 1

lua_baseentity:getMeleeHitDamage returning 4294967295?

Posted: Mon Aug 13, 2012 11:51 pm
by PrBlahBlahtson
Just checking if this is expected behavior before reporting it. The comments make it sound like I should be getting a -1 on miss, but according to printf("Damage: %u",damage); I'm getting a rather full 16-bit integer. Code in use is below, in case it's my gaffe.

Code: Select all

	damage = player:getMeleeHitDamage(target);
		-- Returns -1 on miss	
	printf("Damage: %u",damage);
	if(damage == -1 or damage == 0 or damage > 65000) then
		-- Return miss message how?  Try passing -1 eventually.
		player:messageBasic(324,66,target);
		return 0;
	else
		target:delHP(damage);
		target:updateEnmityFromDamage(player,damage);
		return damage;
	end
I'm also getting a "<Player> uses Jump. \ The <target> takes 65535 points of damage." message on misses without return 0, if anybody wants to tell me what I'm doing wrong. Not sure how I'm going to cross that hurdle, actually. (see edit below)

Yes, even with my "damage > 65k."

I've also tried return -1, which did the same thing.

Edit:
First half still stands, I'd like to know if that's expected behavior. I'll report it properly if it's not.

Second half... yeesh. Don't sweat that too much. Jump needs a dedicated core function. Just... there would be so many missing caveats to regular behavior with getMeleeHitDamage. Dual-wielding, TP return, crits, en-spell damage, additional effects, gear modifying all of that... I can dump my research/code somewhere if someone wants to pick the baton up, but it needs a core function and I can't code that. Sorry. I better understand why nobody's coded Jump now.

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Posted: Tue Aug 14, 2012 4:44 am
by bluekirby0
I'm not intimately familiar with LUA but I'm going to venture a guess and say the value you are getting in your printf is bullshit because you are printing it with %u (unsigned integer) and it is being fed a signed integer which would normally be represented with %i

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Posted: Tue Aug 14, 2012 11:54 am
by PrBlahBlahtson
You know more than I do :D

You're also correct.

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Posted: Wed Aug 15, 2012 5:48 pm
by bluekirby0
I know enough to know when something is an analogue with C/C++/Python syntax (this printf functions appears to be identical to the one in C/C++).