LPMuds.net
September 03, 2010, 11:28:13 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: CanMelee resolution  (Read 481 times)
detah
BFF
***
Offline Offline

Posts: 159


Ruler of 2D


View Profile
« on: September 05, 2008, 09:51:50 PM »

I have read thru eventExecuteAttack to eventMeleeRound to eventMeleeAttack to CanMelee. CanMelee (a misnomer if ever there was one) determines how tohit is resolved for the player and the npc.

CanMelee is broken into 2 pieces by an if-else statement.

Code:
if(!this_object()->GetMelee()) {  ...
then tohit is calculated one way.

else {} tohit is calculated a different way.

Surprisingly this function is pretty simple to read. My difficulty is that GetMelee is simply defined as
Code:
int GetMelee() return melee;
in /lib/body.c L1759.

There is also a SetMelee which is defined as
Code:
int SetMelee(int i) { melee = i; return melee; }

The weird part is that nowhere can I find where SetMelee is set for the player. So if melee is not ever set, what does GetMelee resolve to? null? 0? It is not clear to me.

Then one logic step further, what on earth does !this_object()->GetMelee mean if melee is not set/initialized?

Detah@Arcania
Logged
cratylus
Your favorite and best
Administrator
***
Offline Offline

Posts: 918


Cratylus@Dead Souls <ds> np


View Profile WWW
« Reply #1 on: September 05, 2008, 10:06:12 PM »

Quote
The weird part is that nowhere can I find where SetMelee is set for the player. So if melee is not ever set, what does GetMelee resolve to? null? 0?

Its value will be 0, right.

Quote
Then one logic step further, what on earth does !this_object()->GetMelee mean if melee is not set/initialized?

What it means is tricky. What it evaluates to is 1.

eval return !this_player()->GetMelee()

If your class is fighter, this may differ. Your mileage may vary
based on your customizations.

-Crat
Logged
detah
BFF
***
Offline Offline

Posts: 159


Ruler of 2D


View Profile
« Reply #2 on: September 05, 2008, 10:16:55 PM »

I don't like it. But I understand it.
Thank you.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!