Welcome to the Builder Academy

Question suffering from poison

More
18 Oct 2016 22:28 - 19 Oct 2016 10:00 #6203 by JTP
suffering from poison was created by JTP
I tried to add code to damage a char without globe of darkness.

It seems that part is ok, but now if someone is poisoned, they get 2 sets of messages:

A little white mouse looks really sick and shivers uncomfortably.
A little white mouse is incapacitated and will slowly die, if not aided.
A little white mouse lies helplessly on the ground and suffers...
A little white mouse is incapacitated and will slowly die, if not aided.


What am i missing ?



Original code
Code:
gain_condition(i, HUNGER, -1); gain_condition(i, DRUNK, -1); gain_condition(i, THIRST, -1); if (GET_POS(i) >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if (!IS_NPC(i)) { update_char_objects(i); (i->char_specials.timer)++; if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL) check_idling(i); } }



My add on
Code:
gain_condition(i, HUNGER, -1); gain_condition(i, DRUNK, -1); gain_condition(i, THIRST, -1); if (GET_POS(i) >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if (!IS_NPC(i)) { update_char_objects(i); (i->char_specials.timer)++; if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL) check_idling(i); } if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) continue; if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } }
Last edit: 19 Oct 2016 10:00 by JTP.

Please Log in or Create an account to join the conversation.

More
19 Oct 2016 19:48 #6204 by thomas
Replied by thomas on topic suffering from poison
I think the easiest way to explain this is to use pseudocode:
Code:
The way it was: If they are alive (stunned+): let them gain mana, move and hp if they are poisoned try damaging them ("looks really sick") if the damage didn't kill them, make sure they're in the right position and send them a message ("is incapacitated"). Then go to the next char. if they are unconscious damage them ("and suffers") if they die, move on What you added: let them gain mana, move and hp if they are poisoned try damaging them ("looks really sick") if the damage didn't kill them, make sure they're in the right position and send them a message ("is incapacitated"). Then go to the next char. if they are unconscious damage them ("and suffers") if they die, move on Now, regardless of whether they were damaged above, if they are unconscious, hurt them again.

What you really want is to have the new code happen where you check for poison, like this:
Code:
let them gain mana, move and hp if they are poisoned try damaging them ("looks really sick") if the damage didn't kill them, try damaging them by sunlight if the damage didn't kill them, make sure they're in the right position and send them a message ("is incapacitated"). Then go to the next char. if they are unconscious damage them ("and suffers") if they die, move on
Here's the fixed version for that example:
Code:
gain_condition(i, HUNGER, -1); gain_condition(i, DRUNK, -1); gain_condition(i, THIRST, -1); if (GET_POS(i) >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ if (GET_POS(i) <= POS_STUNNED) update_pos(i); + if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { + if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) + continue; } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if (!IS_NPC(i)) { update_char_objects(i); (i->char_specials.timer)++; if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL) check_idling(i); } }

However, you might be wanting this damage to strike also if they're unconscious - after all, if they're lying in the sunlight, you might want the damage to occur even if the culprit is near death.
In this case you will want to change the logic a bit in this function. This might work, though I haven't tested it:
Code:
Somewhere near the top of the function: int position_before_update; ... gain_condition(i, HUNGER, -1); gain_condition(i, DRUNK, -1); gain_condition(i, THIRST, -1); position_before_update = GET_POS(i); if (position_before_update >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ } else if (position_before_update == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (position_before_update == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) continue; } if (position_before_update != GET_POS(i)) update_pos(i); if (!IS_NPC(i)) { update_char_objects(i); (i->char_specials.timer)++; if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL) check_idling(i); } }

Please Log in or Create an account to join the conversation.

More
20 Oct 2016 14:37 - 20 Oct 2016 15:51 #6205 by JTP
Replied by JTP on topic suffering from poison
Hi

There seems to be a missing } in your first option, that im trying now ?
Code:
if (GET_POS(i) <= POS_STUNNED) update_pos(i); + } /* i put one here and it compiled */ + if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { + if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) + continue; } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue;


But as you can see below, the first 4 times just 1 message, then two times just one message where mob is stunned, but suddently one time i see double message from poison when mob is incapacitated, but the next two ticks just 1 when mob is mortally wounded.

Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.
A little white mouse is stunned, but will probably regain consciousness again.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.
A little white mouse is stunned, but will probably regain consciousness again.


Uno suffer's from being exposed to light.
A little white mouse looks really sick and shivers uncomfortably.
A little white mouse is incapacitated and will slowly die, if not aided.
A little white mouse lies immobile on the ground, suffering...
A little white mouse is incapacitated and will slowly die, if not aided.


Uno suffer's from being exposed to light.
A little white mouse lies immobile on the ground, suffering...
A little white mouse is mortally wounded, and will die soon, if not aided.


Uno suffer's from being exposed to light.
A little white mouse lies helplessly on the ground and suffers...
A little white mouse is mortally wounded, and will die soon, if not aided.


Then the mouse dies:
Uno suffer's from being exposed to light.
A little white mouse suffers from bloodlack, and the lack of a beating heart...
A little white mouse is dead! R.I.P.
Your blood freezes as you hear a little white mouse's death cry.


And then only Uno's message:
Uno suffer's from being exposed to light.
Uno is mortally wounded, and will die soon, if not aided.


Finally Uno dies:
Uno screams in pain, keels over and dies.
Uno is dead! R.I.P.
Your blood freezes as you hear Uno's death cry.




So your first option, seems to Work 99% except for that one time with double message, where the mob gets incapacitated. Any ideas why it came ?
Last edit: 20 Oct 2016 15:51 by JTP.

Please Log in or Create an account to join the conversation.

More
21 Oct 2016 22:30 #6206 by thomas
Replied by thomas on topic suffering from poison
You're almost there:

This your current code:
Code:
if (GET_POS(i) <= POS_STUNNED) update_pos(i); } /* this one is the reason for your problem. It makes the next statement the "if" for the "else if"s below it*/ if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) continue; } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue;

This is what you need:
Code:
+ if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED(i, AFF_GLOBE_OF_DARKNESS))) { + if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) + continue; + } /* here it matches the { three lines up */ if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue;

Please Log in or Create an account to join the conversation.

More
22 Oct 2016 13:04 - 22 Oct 2016 17:54 #6207 by JTP
Replied by JTP on topic suffering from poison
Looks like poison now works, though now its 2 ticks of incapasitated, before just 1 tick.
And takes 3 ticks of mortally wounded, before it was 2 ticks.


So it takes 2 ticks longer to die. Any idea why there suddently are more rounds ?



Dying from sunlight, lots of suffering cus my test char has lots of hp, then 3 mortally wounded and then next tick dead.

So there was no incapasitated.
Last edit: 22 Oct 2016 17:54 by JTP.

Please Log in or Create an account to join the conversation.

More
14 Dec 2016 14:55 - 14 Dec 2016 14:59 #6400 by JTP
Replied by JTP on topic suffering from poison
It seems that there might still be something wrong with below code. Have had reports that the mud halted when being incapasitated. Then having to kill it and restart. Any ideas ? Also that it take more rounds now to die, then before. Like i wrote above.
Code:
if (GET_POS(i) >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ if ((!ROOM_FLAGGED(IN_ROOM(i), ROOM_DARK) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_INDOORS)) && (!ROOM_FLAGGED(IN_ROOM(i), ROOM_TUNNEL))) && (GET_RACE(i) == RACE_DROW) && (!AFF_FLAGGED($ if (damage(i, i, GET_LEVEL(i), SPELL_SUN_LIGHT) == -1) continue; } if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if (!IS_NPC(i)) { update_char_objects(i); (i->char_specials.timer)++; if (GET_LEVEL(i) < CONFIG_IDLE_MAX_LEVEL) check_idling(i); } }
Last edit: 14 Dec 2016 14:59 by JTP.

Please Log in or Create an account to join the conversation.

Time to create page: 0.353 seconds