Do we have a simple script...

Discussion in 'General Modification' started by Shiningted, May 28, 2006.

Remove all ads!
  1. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    ...to disequip an npc? unequip_best_all doesn't do it for me ;)
     
  2. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    I take it you mean just un_equip the item, rather than removing it from their inventory all together. Not that I know of.
     
  3. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Bugger.

    Ok, simple script to equip bare hands?
     
  4. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    try this:

    Code:
    def unequip( slot, npc):
        item = npc.item_worn_at(slot)
        holder = game.obj_create(1004, npc.location) 
        holder.item_get(item)
        npc.item_get(item)
        holder.destroy()
    
    Usage: slot is the equipped slot number. I believe there are 16, numbered 0 to 15. 0 is hats, 3 is for primary weapons. I forget the rest (I had a list but I misplaced it, sorry:)). npc is the character you want to unequip. So if you wanted to unequip the primary weapon of your party leader call the function like this.
    Code:
    unequip(3,game.party[0])
    You can add the function to the end of utilities.py but remember to:
    Code:
    from utilities import *
    either at the console or in your script before trying to call the function.

    Oh and remember to preserve the indentation in the function as that is important to python.

    Darmagon
     
  5. krunch

    krunch moving on in life

    Joined:
    Aug 9, 2005
    Messages:
    3,280
    Likes Received:
    0
    @darmagon: You should post that info in the "Well whaddya know?" thread.
     
  6. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    Maybe, but I have always thought of that thread as being for discovered game secrets. Not for the use of those game secrets in a specific script. Maybe a new thread of useful scripts would be appropriate in the same forum, what do you think? I have a number of useful functions and scripting tidbits that don't necessarily fit anywhere else and I am sure others have more.

    Darmagon
     
  7. krunch

    krunch moving on in life

    Joined:
    Aug 9, 2005
    Messages:
    3,280
    Likes Received:
    0
    Yah, I see what you mean. Maybe a stickied Scripting Secrets thread would be a good idea...one that would show the whole routine, not just a single line of code as a function call posted in the thread.
     
    Last edited: May 28, 2006
  8. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Thanks D, i knew your lurking would come in handy. ;)
    Gee, thanks :p
     
  9. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    If you don't mind, I will add this to Co8.py. That is the file into which I have moved all the functions developed by Co8 modders which used to be in utilities.py. Right now that means pretty much yours, mine and Ugignadl's scripts, Darmagon. I have added "from Co8 import *" to all your spells which use the scripts you had in utilities.py, and so far everything seems to work. I hope you don't mind that I took this liberty for 5.0.0 without consulting you.
     
  10. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    Cool Cerulean. That is actually what I wanted to do in the first place but I ran into problems with importing files along the way. I don't know, I may have been doing something wrong. If it works, then great. Thnx

    Darmagon
     
  11. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    Lurking? Lurking!!! Oh how unkind, how unfair!:) Anyway I am in the process of setting up a thread in the ToEE Toolset Project Documentation forum which will be appropriate for this kind of thing as per what I and Krunch discussed above. It seems tp be a needed thing and will allow me, personally, to divulge things that would not fit easily into another forum or thread. Anyone else with similar knowledge is invited to share. Oh, bye the way I will be postiing the item_worn_at slot numbers in "Well_Whadya_Know" momentarily.

    Darmagon
     
    Last edited: May 28, 2006
  12. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    I thought this was useful. Can't wait to set it as a first_hearbeat for pretty much every person in the Keep, no more of this dang clerics walking the church with mace and shield in hand.

    [EDIT] D, I can't get this script to work. I have applied it thusly:
    Code:
    def san_first_heartbeat( attachee, triggerer ):
    	unequip(3,attachee)
    	return SKIP_DEFAULT
    
    def unequip( slot, npc):
    	game.particles( "sp-summon monster I", game.party[0] )
    	item = npc.item_worn_at(slot)
    	holder = game.obj_create(1004, npc.location) 
    	holder.item_get(item)
    	npc.item_get(item)
    	holder.destroy()
    	game.particles( "sp-summon monster I", game.party[3] )
    	return SKIP_DEFAULT
    The script is called (first particles fire) but the second don't, and the chests don't disappear, they just sit there. So presumably the flaw (such as there is) is in the item_get() bit. What am I doing wrong?
     
    Last edited: May 28, 2006
  13. darmagon

    darmagon stumbler in the dark

    Joined:
    Mar 22, 2005
    Messages:
    295
    Likes Received:
    0
    Not too sure ShingingTed. The script functions perfectly on my end without the particles stuff and without the return SKIP_DEFAULT.

    Darmagon
     
  14. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,740
    Likes Received:
    374
    Ok maybe its that return thing. Silliness on my part: I will try again. Thanks for the quick reply.

    [EDIT] No joy, I have tried umpteen things and I can't get this to work. Hope you don't mind but I have emailed u the file, if you could have a look I'd appreciate it.
     
    Last edited: May 28, 2006
  15. Cerulean the Blue

    Cerulean the Blue Blue Meanie Veteran

    Joined:
    Apr 23, 2005
    Messages:
    1,962
    Likes Received:
    0
    It works for me too, even with the particles, but without the SKIP_DEFAULT. I did keep the return, though. Check that there aren't spaces instead of tabs. When I copied and pasted it there were.

    [EDIT] It works just fine on party members, but on NPCs not in the party, they instantly re-equip the weapon when you run it on them. I think that there might be something in the mobs to prevent this (that box of zeros and ones on the same tab as the inventory - I think one of those ones is a flag for equipping).

    Oh, and it works without any "return" at the end too.

    [EDIT 2] Those ones and zeros weren't what I thought they were. Furnok still instantly re-equipped his sword when I ran the function on him.

    [EDIT 3] I tried setting the flag ONF_NO_EQUIP on Furnok, and now he doesn't automatically re-equip his sword, but unfortunately he un-equips everything and just stands there naked. I think this is because his equipment is not MOBed in to particular inventory slots. I'm going to leave that up to you to test, Ted. Good luck.
     
    Last edited: May 28, 2006
Our Host!