Using protos bonuses in scripts

Discussion in 'Scripting' started by darmagon, Oct 5, 2005.

Remove all ads!
  1. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    Okay, I was messing around trying to find a way to implement the Iron Body spell and, in a moment of desperation, I tried directly applying the protos bonuses (things like; Armor Bonus, Skill Circumstance Bonus, Monster Juggernaut, DR etc) via the console using the condition_add_with_args function. To my immense surprise, it worked! Not only that but it seems you can do things like apply a shield bonus to a pc or npc and it will increase their armor class just as if they had an item with that bonus equipped! This (typed in the console)
    Code:
    game.party[0].condition_add_with_args('Shield Bonus',8,0)
    has the effect of raising the armor class of the left-most party member by 8!

    I tried the same with 'Skill Circumstance Bonus' skill_spellcraft to raise that skill by 20 points and that also worked. I even tried some feats (ie. Flurry of Blows and Toughness) and the effects were the same as if the character had those feats. However the feats do not show up on the character's feat list.

    I haven't tried any real scripting away from the console but this should work anywhere you can use a python script in ToEE. And it should work for any object you can get a handle to, not just pc's or npc's

    If you want to use this facility here are some things to note: 1) the bonuse type (the first argument to condition_add_with_args) must be enclosed in quotes and it must correspond to what you find in the protos exactly; 2)the other two parameters are what comes in the two spaces after the bonus type in the protos and they must come in the same order in the call. 3)If a word that does not contain an underscore is used then it must be in quotes as well. If there are just numbers or words with underscores don't use the quotes.4) use a zero (no quotes) for blank cells in the protos. 5) be careful, some of these things, to my knowledge, can't be undone (iie. adding feats) 6) if you try to add something that doesn't exist in the game you will probably get a CTD

    Oh, bye the way, just in case this was already common knowledge, Why didn't anyone tell me?!!

    Darmagon


    Edit by SA:

    It's only hinted at in here, but this technique was used to create status effects via applying conditions to a spell object and then adding that spell object to a PC's inventory.

    Example usage: (snippets, not full script)
    Code:
    	stench_obj = game.obj_create(OBJ_SPELL_STENCH, critter.location)
    	stench_obj.item_flag_set(OIF_NO_DROP)
    	stench_obj.item_flag_set(OIF_NO_LOOT)
    	set_spell_flag(stench_obj, OSF_IS_HEZROU_STENCH)
    
    		stench_obj.item_condition_add_with_args('sp-Unholy Blight', spell_id, STENCH_DURATION, 0)	# Doesn't penalise saves - does flag char info.
    		stench_obj.item_condition_add_with_args('Saving Throw Resistance Bonus', 0, -2)
    		stench_obj.item_condition_add_with_args('Saving Throw Resistance Bonus', 1, -2)
    		stench_obj.item_condition_add_with_args('Saving Throw Resistance Bonus', 2, -2)
    		stench_obj.item_condition_add_with_args('Attribute Enhancement Bonus', 0, 11 - strength)
    		stench_obj.item_condition_add_with_args('sp-Chaos Hammer', spell_id, STENCH_DURATION, 0)	# Only get move action. (+2 AC, -2 attack & damage rolls, +2 saves [shoddy implementation])
    		stench_obj.item_condition_add_with_args('sp-Feeblemind', 0,0,0)
    
    Where the proto for the spell object is OBJ_SPELL_STENCH = 6400.
     
    Last edited by a moderator: Nov 14, 2013
  2. Agetian

    Agetian Attorney General Administrator

    Joined:
    Aug 14, 2004
    Messages:
    2,526
    Likes Received:
    0
    This is simply awesome! Congrats on revealing this incredibly important information! And,uh... I don't think it was among known things before (at least I didn't know it either).

    Of course, this is going to work from scripts as well (since scripts and console are both interpreted by the same Python interpreter).

    - Agetian
     
  3. Cujo

    Cujo Mad Hatter Veteran

    Joined:
    Apr 4, 2005
    Messages:
    3,634
    Likes Received:
    1
    thats awesome :dance:
     
  4. Shiningted

    Shiningted I want my goat back Global Moderator

    Joined:
    Oct 23, 2004
    Messages:
    11,804
    Likes Received:
    42
    Another vote here for awesome! :thumbsup:
     
  5. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    A third vote for awsome. The possibilities this opens up are mindboggling.
     
  6. krunch

    krunch moving on in life

    Joined:
    Aug 9, 2005
    Messages:
    3,280
    Likes Received:
    0
    Question (for somebody who knows or can provide a guess which is most likely correct):

    Example, let's say a modder makes a NPC who without wearing armor has a base AC 20 [for whatever reason, AC 10 +10 = AC 20] and his/her AC increases beyond 20 with wearing armor. In this case, can the base AC 10 modified by natural protection of +10 be permanently given using the new technique prior to being encountered like when the mod is made, or, does the new technique only apply to data being stored like what is in a saved game? And, in this case, could a script, alternately, be used that would cause the base AC to be modified each time when the NPC is encountered in a game?

    [EDIT] I will start modding next year in 2006. I do not have sufficient time to devote to modding through, at least, sometime in January 2006. There is too much going on in my life right now for modding; I am the kind of person who is a workaholic and finishing things with 100 percent effort when I start involvement on projects. When I do start modding, it will be intensive and I can see using this kind of technique and determining new interesting and unusual ways to make stuff magically seem to happen. I am a fast learner with software [not a developer] as a Network Engineer and I am a quick study. I can see myself burning the midnight oil as long as it takes and learning animation, too. Who knows, maybe I can, eventually, learn pearl and python good enough to code my own new game in the future given time?
     
    Last edited: Oct 6, 2005
  7. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    an additional caveat. In my original post I said that you couldn't get rid of some of the bonuses. I was wrong you can't get rid of any of them AFAIK. The best you can do is add a further "bonus" to negate the earlier one for example you could add 'Monster DR All' 15. To negate it you would add 'Monster DR All' -15. Both bonuses remain and the second cancels out the first. So if you want to add an effect and have it go away later several times to a single object the object is going to end up with a whole bunch of conditions added to it. This could lead to really "big" objects taking up a lot of computer memory which could lead to other problems. I haven't been able to find a way to remove bonuses so this facility has limited...erm...facility.

    Darmagon
     
  8. bradrinwi

    bradrinwi Established Member

    Joined:
    Mar 18, 2005
    Messages:
    226
    Likes Received:
    0
    hmm this is incredible and might prove useful as i attempt to make Psionic s a char class
    ..
    hey does this discovery help get some of the in active monk HLA working??or added..
     
  9. Shiningted

    Shiningted I want my goat back Global Moderator

    Joined:
    Oct 23, 2004
    Messages:
    11,804
    Likes Received:
    42
    Pity. But I tested the 'workaround', creating an undroppable object that stays there as long as u want it to have an effect and then can be destroyed when necessary. The flag 'oif_no_drop' works perfectly: just hit it and whatever you got it on can't be dropped or fobbed off on someone else.

    "I'm fallen AGAIN? Hmmm... hey Furnok, hold this will you?"

    Unfortunately 'oif_no_display' doesn't prevent the item being displayed in the inventory - perhaps it does something else like not displaying the item on the ground (or does nothing). Otherwise we could have added our items and done the job unobtrusively as it should be.

    Creating a new item to add an effect is a pain but if it is going to be used often enough to make stacking 'bonus on' and 'bonus off', ummm, bonuses unworkable, then its a good workaround I think.
     
  10. Heavydan85

    Heavydan85 Drinking Champion

    Joined:
    Jun 21, 2005
    Messages:
    240
    Likes Received:
    0
    Yay i can change/add feats to npcs in game
     
  11. Moosehead

    Moosehead Rubber nipple

    Joined:
    Jun 18, 2005
    Messages:
    182
    Likes Received:
    0
    For the idea of a fallen priest, how about creating an undroppable holy symbol/foci (should work the same way as a familiar) for the priest that appears as starting equipment for priest PCs, and is automatically added to inventory the first time the character takes a priest level?

    My idea here is that the object could then be switched out with a "fallen" version of it that imposes the fallen characteristics if the character does anything that goes against their deity.

    In this context, I guess it would also make sense to create one clerical focus for each deity, and one "desecrated" version for each of them.

    The description of a clerical focus could read something like "This lightly radiant relic is a holy symbol of Ehlonna. It serves as a channelling focus for casting divine magic."

    The description of a desecrated focus could read something to the effect of "This holy symbol of Ehlonna has been desecrated. Its radiance has died and symbolizes Ehlonna's disapproval of its owner's actions. The priest this relic belongs to is unable to cast any divine magic."

    Hm. This could also be a neat way to add any special feats or abilities that you for any reason would want a holy symbol to bestow upon a priest, and even add different abilities for different dieties, if you would be so inclined.

    It seems like a pain in the ass, but absolutely doable.
     
  12. Shiningted

    Shiningted I want my goat back Global Moderator

    Joined:
    Oct 23, 2004
    Messages:
    11,804
    Likes Received:
    42
    Well, if we gotta have something in the inventory to do it, then a Holy Symbol is a great idea :)

    Rules buffs: does owning (or not owning) a holy symbol give a bonus for, say, turning in the manner that having theives' tools does?
     
  13. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,670
    Likes Received:
    136
    No, there is no penalty for not having a holy symbol (it just plain wont work) and no bonus for a masterwork holy symbol (there isn't one) they do come in two varieties though wooden (for poor clerics) and silver (for rich ones).

    DID YOU KNOW:
    According to the rules, an Evil cleric can counter a good cleric's turn undead, with a rebuke undead of his own (vice versa also works)? As long as he makes an equal or greater turning check than the good cleric, and the 2d6+clr lvl+chr bonus result is higher than the undead creatures HD, the act as if unaffected by the turn undead!

    Also an evil cleric may bolster his rebuked undead for 10 rounds by rebuking them again, with the posability of making the undead act as is they had +4 HD against turn undead.
     
    Last edited: Oct 21, 2005
  14. Agetian

    Agetian Attorney General Administrator

    Joined:
    Aug 14, 2004
    Messages:
    2,526
    Likes Received:
    0
    I moved this to the ToEE Toolset Project Documentation because the thread seems to belong here. Also, I stickied it and removed all 'bump' type threads. Later this thread may be partially merged with the "Well whaddaya know?" thread (all meaningful posts moved there, and the rest removed). This post is subject to removal within a few days as well.

    - Agetian
     
  15. Shiningted

    Shiningted I want my goat back Global Moderator

    Joined:
    Oct 23, 2004
    Messages:
    11,804
    Likes Received:
    42
    Having to bump every seven years would be a pain... ;)

    Quick update on this: Darmagon moved on before he explained how to add feats, and I have spent several years on and off trying to add feats by script and failing catastrophically every time (from 'does nothing' to 'crashes game'). In fact, I've been doing it so long I don't even remember why I started, but I think it was to add some missing Wizard or Monk weapon proficiencies at the start of a game. Or possibly to give Clerics of Hextor weapon focus for Light Flail as well as Heavy Flail. Or something.

    Anyways, last night I was looking for something (an example of a check for armour type (light - medium - heavy) - PM me if you have a working in-game example) and came across this. And out of the sort of sad tragic desperation that makes one a modder I decided to try again, but this time use the exact example Darmagon gives 'Toughness'. Its a good-un because you can tell immediately if it worked, you get +3 hp.

    And it did :)

    So I wanted to immediately record the working syntax here, and it is...
    Code:
    	pc.condition_add_with_args('Dodge', 0, 0)
    	pc.condition_add_with_args('Toughness', 0, 0)
    And as per the OP, these don't show in the character sheet but they do show up as relevant (so the PC doesn't have Dodge on their character sheet, but it does show up as an AC bonus in the roll breakdown when attacked).

    Possibly this was common knowledge, since it is so easy, but why didn't it work for me? 2 reasons I suspect:

    1) I overthought it: getting a skill bonus needs something like

    pc.condition_add_with_args('Skill Circumstance Bonus', skill_spellcraft, 20)

    so the feat one being so simple is... deceptive...

    2) weapon proficiencies don't seem to work. The reason for this (and why I am going on about this at length) is almost certainly because the syntax for proficiencies isn't recognised by the dll - reference to feats are normally from enums, I think, and there is no reference to 'proficiency' (or 'exotic', 'martial' or 'simple') in the string dump. So

    pc.condition_add_with_args('Exotic Weapon Proficiency (Bastard Sword)', 0, 0)

    just crashes the game. So does

    pc.condition_add_with_args('repeating_crossbow', 0, 0)

    which is from the string dump.

    Which leads to my main point: to get a feat working, you seem to have to use the string dump format rather than the enum one. Hence to get the ring of Evasion going, I added 'Evasion' as a bonus in protos.tab: I did not use feat_evasion as you would for an NPC. (It worked, too, which was gratifying).

    Sorry if this is common knowledge but I haven't seen anyone do it. I really do miss Darmagon :(

    (O and KotB status update later tonight ;) )
     
Our Host!