lua_baseentity:getMeleeHitDamage returning 4294967295?

Forum rules
NO LONGER BEING MAINTAINED!
Post Reply
PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

lua_baseentity:getMeleeHitDamage returning 4294967295?

Post by PrBlahBlahtson » Mon Aug 13, 2012 11:51 pm

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.

bluekirby0
Developer
Posts: 707
Joined: Sun Jul 22, 2012 12:11 am

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Post by bluekirby0 » Tue Aug 14, 2012 4:44 am

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

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Post by PrBlahBlahtson » Tue Aug 14, 2012 11:54 am

You know more than I do :D

You're also correct.

bluekirby0
Developer
Posts: 707
Joined: Sun Jul 22, 2012 12:11 am

Re: lua_baseentity:getMeleeHitDamage returning 4294967295?

Post by bluekirby0 » Wed Aug 15, 2012 5:48 pm

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++).

Post Reply