Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ ch->move = ch->move - 1;

ch->move = ch->move - 1;

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Klered   (24 posts)  Bio
Date Fri 25 Feb 2005 04:05 AM (UTC)

Amended on Fri 25 Feb 2005 03:32 PM (UTC) by Klered

Message
I put this in fight.c in the function

ch_ret damage ///Inflict damage from a hit!

My goal was to remove 1 move per strike = hit or miss. I don't understand why an extra move is removed except for the very last round. What am I missing about this loop? I used the send_to_char to report the loop....please help?

tia - travestin



    /*Travestin - Remove 1 move for each strike = hit or miss in a round*/
    
        ch->move = ch->move - 1;
       send_to_char("test the moves!\n\r", ch);



<snip>

[(867/954hp)(353/353ma)(651/690mv)]The master's apprentice->[|||| ]
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(867/954hp)(353/353ma)(648/690mv)]The master's apprentice->[|||| ]
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(867/954hp)(353/353ma)(646/690mv)]The master's apprentice->[|||| ]
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your crush massacres the master's apprentice!
test the moves!
The master's apprentice lacerates you!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(844/954hp)(353/353ma)(643/690mv)]The master's apprentice->[|| ]
Your crush obliterates the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(844/954hp)(353/353ma)(641/690mv)]The master's apprentice->[|| ]
Your crush annihilates the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(844/954hp)(353/353ma)(639/690mv)]The master's apprentice->[|| ]
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your crush annihilates the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
The master's apprentice decimates you!

[(819/954hp)(353/353ma)(636/690mv)]The master's apprentice->[|| ]
Your crush annihilates the master's apprentice!
test the moves!
Your crush **DESTROYS** the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
The master's apprentice misses you.

[(819/954hp)(353/353ma)(633/690mv)]The master's apprentice->[| ]
Your crush annihilates the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
The master's apprentice lacerates you!

[(797/954hp)(353/353ma)(631/690mv)]The master's apprentice->[| ]
Your crush annihilates the master's apprentice!
test the moves!
Your crush misses the master's apprentice.
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(797/954hp)(353/353ma)(628/690mv)]The master's apprentice->[ !dying! ]
Your crush annihilates the master's apprentice!
test the moves!
Your crush annihilates the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(797/954hp)(353/353ma)(625/690mv)]The master's apprentice->[ !dying! ]
Your crush annihilates the master's apprentice!
test the moves!
Your crush massacres the master's apprentice!
test the moves!
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.
Your armor deflects the master's apprentice's attack.

[(797/954hp)(353/353ma)(622/690mv)]The master's apprentice->[ !dying! ]
Your crush annihilates the master's apprentice!
test the moves!
The master's apprentice is DEAD!!
The Gods Have Bonused You For Your Dedication!
You receive 10243 experience points.
The master's apprentice gasps his last breath and blood spurts out of his mouth and ears.
You get 1000 gold coins from the corpse of the master's apprentice

[(797/954hp)(353/353ma)(621/690mv) - TNL:11071]
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Fri 25 Feb 2005 04:48 AM (UTC)
Message
Looks to me like its working as it should, every "strike" shows you the hit message and then your bug message. Are you trying to do one move per round? Because multi-hit and second/third attack allow for more than one per round.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Klered   (24 posts)  Bio
Date Reply #2 on Fri 25 Feb 2005 05:01 AM (UTC)
Message
Greven -

Trying to do 1 move per strike - hit or miss.

Its wierd how it does one move per strike + 1 - except at the last round.

One thing that I thought of was the difference in prompts(fprompt/prompt)...but they both are reporting from the same token %m/%M ....

not sure....
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Fri 25 Feb 2005 05:33 AM (UTC)
Message
I would tend to agree with Greven's suggestion, although you showed so little code and context that it's kind of hard to know for sure. OK, sure, your code removes 1 mp, but where? :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Klered   (24 posts)  Bio
Date Reply #4 on Fri 25 Feb 2005 05:47 AM (UTC)
Message
Ksilyan - not sure what you want me to show.

There is 1 line of code, and the bug message to make sure I got it in the right place.

fight.c function -


ch_ret damage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt )



just after


 /*
     * Hurt the victim.
     * Inform the victim of his new state.
     */
    victim->hit -= dam;


is where I placed my line. Seems that the location is ok. I would post the function but I think you would get mad at me =) you know..its huge.

got a stock fight.c?

Top

Posted by Klered   (24 posts)  Bio
Date Reply #5 on Fri 25 Feb 2005 03:31 PM (UTC)
Message
Is there anyone willing to put my code in your fight.c and just see what you get? (its 2 lines...see above)

Im just curious ... anyone wanna try? It would be appreciated.

TIA
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #6 on Sat 26 Feb 2005 01:59 AM (UTC)
Message
Did you take this part into consideration?
    if ( retcode == rNONE )
    {
	int move;

	if ( !IS_AFFECTED(ch, AFF_FLYING)
	&&   !IS_AFFECTED(ch, AFF_FLOATING) )
	  move = encumbrance( ch, movement_loss[UMIN(SECT_MAX-1, ch->in_room->sector_type)] );
	else
	  move = encumbrance( ch, 1 );
	if ( ch->move )
	  ch->move = UMAX( 0, ch->move - move );
    }
It is at the end of multi_hit, and will certainly have an effect, and could account for the extra movement loss.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Dace K   Canada  (169 posts)  Bio
Date Reply #7 on Sat 26 Feb 2005 09:40 PM (UTC)
Message
Yegh. I think Greven's got it.

Also, why use ch->move = ch->move - 1, instead of
ch->move --;
? :P

ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com

Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #8 on Sat 26 Feb 2005 10:08 PM (UTC)
Message
Because the macro expands it multiple times. Every time you execute ch->move--, you are changing ch->move, and if you have a macro like this:

#define UMAX(a, b) (a > b ? a : b)

You will note that a and b are potentially evaluated twice, which would in the end decrement two from your value which is certainly not what you want to do.

(Re-reading)
Sorry- I thought you were referring to the code Greven showed you. In your own code, where the whole entire statement is just "ch->move = ch->move - 1;" you are correct, there is no reason to not use ch->move--;.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Klered   (24 posts)  Bio
Date Reply #9 on Mon 28 Feb 2005 11:26 PM (UTC)
Message
ch->move--;

You learn something new everyday...

I will look at the multi-hit function, thanks for pointing it out. I supposed if I grep'd ch->move and looked at all the instances, I would have come across it. Thanks again for all your thoughts.

Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


26,008 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.