Anyone knows what 'sp-Protection From Monster' does?

Discussion in 'General Modification' started by Rudy, Mar 14, 2015.

Remove all ads!
  1. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    So, I'm trying to add long descriptions to several items that are missing them, leaving them needlessly mysterious. Potion of Protection from Magic, and several of the Elixirs are finished. However, I'm stuck on Potion of Protection from Elementals/Outsiders/Undead.

    They do not create a duration effect thingy on your character portrait, which is annoying enough. The main issue is that the .py file for them indicates that they apply an effect called 'sp-Protection From Monster', with varying parameters.

    Does anyone know precisely what this effect does? My best guess is that it works similarly to 'sp-Protection From Alignment' used by Protection From Evil, and such, but I'd rather not be filling in item descriptions based on my educated guesses.

    Thanks for any insight.
     
  2. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    I think these potions are bugged. The effect should be similar to Protection From Evil in giving you a +2 bonus to AC and +2 bonus to saving throws against those types of creatures (undead, elemental, earth, etc.). The saving throw part works, but the AC actually reduces by 2. Sounds like an easy fix internally if someone wants to dig.

    Here are the pics. I tested this with a Potion of Protection from Undead against a Lacedon, and Potion of Protection from Outsiders against a Noble Salamander. Both potions worked as show in these pics.

    Protection.jpg

    Protection2.jpg

    They also don't protect you from mental control spells like Protection from Evil does, but I don't think it was meant to, that's probably not a bug.

    I suppose the +2 save boost against the salamanders is worthwhile in both encounters with them.


    Edit:

    Here are the durations for the 4 potions:

    Protection from Earth - 1 minute
    Protection from Elementals - 1 minute
    Protection from Outsiders - 5 minutes
    Protection from Undead - 1 minute

    A good way to test durations is to use the command game.fade(t,0,0,0), where "t" is game time in seconds. So just repeatedly executing game.fade(60,0,0,0) a few times will tell you how many minutes the effect will last, as you will see the "A Spell has Expired" floater come up eventually.

    This command is really meant to play sounds and slides (the 2nd and 3rd parameter), and the 4th parameter is the amount of real time (in seconds) that passes till it unfades. Just don't use the command while a dialog is open, because the fade won't unfade unless you type numbers to remove the dialog.
     
    Last edited: Mar 14, 2015
  3. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    The exact condition definitions are given in memory offset 102E2388. I've yet to decipher all the dispatcher types though (see temple.dll thread for more detail on condition definitions).

    Curiously, it seems that all the spells call this condition with the same argument (2). This may well be a bug, or maybe a lazy implementation (i.e. possibly the spell effect grants protection from all of the monster categories you mentioned).
     
  4. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    I noticed that too, I was wondering how it tells the difference. It definitely doesn't provide blanket protection against all 4 types. Somehow it can tell the difference. The command is:

    target_item.obj.condition_add_with_args( 'sp-Protection From Monster', spell.id, spell.duration, 2)

    so it must be keying off the spell.id internally.
     
  5. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    Thanks for the testing results, marc.

    When I examined it myself, my suspicion was that the "2" was the bonus applied, and that the monster type was based off spell.id, as marc suggests. Or, they just aren't distinguishing, which would be sad.

    Hmm.. -2 AC. Wonder if someone was still in 2nd edition AD&D thinking.

    Thanks for the game.fade command! That will be very useful in testing.

    Sitra: i'll need to familiarize myself with that thread, thanks!
     
  6. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    You nailed it! That 2 was the AC bonus, but it seems to be in reverse and gives an AC penalty (2nd edition indeed). So setting the value to -2 actually give the +2 AC bonus as it should be. So it looks like all these potions can be fixed from the script by making those lines:

    Code:
    target_item.obj.condition_add_with_args( 'sp-Protection From Monster', spell.id, spell.duration, [COLOR="Red"]-2[/COLOR])
    

    And just for fun, setting it to -5 gives this

    Protection +5.jpg


    Note that changing this number does not affect the Saving Throw bonus. Maybe there's an optional 5th parameter that changes the save. I'll keep exploring.


    Sitra, noob question: how do I get those print statements from the spell files to print to the console. The print from OnEndSpellCast( spell ) prints out "Protection From Undead OnEndSpellCast", but the ones in OnSpellEffect(spell) do not print.
     
    Last edited: Mar 14, 2015
  7. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Holy hardcoded Batman! Looks like it directly retrieves the spell's index to determine effect then. That's not too surprising actually, I've seen one such table at 102E2600 (an array of pointers to spell condition definitions followed by spell index).

    As for the print statements, you may need to enable the debug flag. See here:
    http://www.co8.org/forum/showthread.php?p=13620
     
    Last edited: Mar 14, 2015
  8. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    Excellent, thanks marc! I will incorporate and document that fix into the next version of my mod, and hopefully from there it will make its way into the official release.
     
  9. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    Actually, the worst thing about the hardcoding here is that the the *duration* seems to be hardcoded based on the spell.id. I confirmed, as marc tested, that the protections from outsiders lasts for 5 minutes, while the others last for 1. There is nothing in the .py files that could account for this difference in duration.
     
  10. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    This is insane.

    So, I've been testing these potions more extensively, and they do more than the +2 AC/+2 saves in some cases.

    In the protection from elementals case, it makes you invulnerable to the *physical* damage from the attacks of elementals (but not, for example, the fire damage dealt by fire elementals).

    In the undead case, it makes you invulnerable to the damage from SOME undead (tested on Lacedons), but NOT others (tested on Greater Temple Bugbear Zombies). To be clear, you get the +2AC/+2 saves for both, but only the damage invulnerability versus some undead. I'm not going to test out every undead, though.

    For the outsiders case, the few I tested it did not grant damage reduction against, but I obviously did not try every possible outsider.

    For the protection from earth case... I'm actually not sure what monsters that is supposed to be. If it's just earth elementals, it seems redundant. So, I haven't actually tested this one.

    And these distinctions are apparently all hardoded. ;.;
     
  11. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    Greater Temple Bugbear Zombies are actually a Co8-added undead, so you may want to test on something else for accurate results.
     
  12. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    It's possible that it grants immunity to NATURAL attacks - I'd guess the bugbear zombies have weapons.

    At any rate from what I've seen in the code it explicitly checks for the item wielded in the main / secondary hand slots, though I haven't analyzed what exactly it does with it. My guess would be that (and IIRC that's what the protection from... spell description says too)
     
  13. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    Ah, thanks for those suggestions; I'll do more testing along those lines.
     
  14. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    578
    Likes Received:
    60
    That's what it is. Just fought some gt zombie bugs and the invulnerability didn't work. Then I took their weapons away and the invulnerability kicked in. Also, the zombie bugs still get their inventory and AI from the original bugbear apparently, and when one of them got low on hit points he chugged a healing potion and finished himself off. :p

    Rudy you're right, total invulnerability. I don't know how I missed that. I guess I was so into checking the AC, and taking damage from the Salamander's fireballs and giant spears which you aren't invulnerable from, I didn't notice.

    Regarding the Protection from Earth. I can see in the protos that there are some critters that are of subtype mc_subtype_earth, but are not elementals. The potion worked against the 3 guys below I tested it on.

    Gargoyle: (type: mc_type_monstrous_humanoid, subtype: mc_subtype_earth)
    Kapoacinth: (type: mc_type_monstrous_humanoid, subtype: mc_subtype_earth)
    Stone Golem: (type: mc_type_construct, subtype: mc_subtype_earth)

    It amazes me that after all these years, stuff like this is still being revealed and documented.

    That reminds me. Does anyone know how to change that Monster Category? I can access it by obj.get_category_type(), but using pc.obj_set_int (obj_f_critter_monster_category, mc_type_ooze) yields a CTD.
     
  15. Rudy

    Rudy Established Member

    Joined:
    Jan 30, 2005
    Messages:
    345
    Likes Received:
    2
    I thought that the natural attacks was it, too, but I just tested it with "Hulking Corpse", which uses a big old axe, and I *was* invulverable to those attacks. So, either his axe is counting as a natural weapon, or there is something else going on there.
     
Our Host!