Shade1982 Posted July 28, 2012 Share Posted July 28, 2012 (edited) Hey all, I could really use any help in this area. I've been going through the script involved in using weapon cases and mannequins to display weapons and armor, but I'm getting lost really fast. So far, I've been able to get it working the way I like, with just one thing missing. Right now, I'm using one script for all the weapon cases and one script for the mannequins. Both of them are just variants of the vanilla script. That's as far as I can go with scripting. I would really like script with which I can specify the weapon type and armor type. For example, I have a weapon case for a dagger, a sword, a waraxe etc etc and mannequins for leather armor, glass armor steel armor... I need a script which tells the player only a dagger (or whatever specific weapon) can be put in this case... (Also, a minor request, but not as important. Is it possible to make item-specific scripts? For example, I have a separate rack for a pickaxe and a woodcutter's axe.) Thus far, I can see I need two script. One for the activator and one for the container, but that's it... Can anyone help me? Edited July 28, 2012 by Shade1982 Link to comment Share on other sites More sharing options...
Shade1982 Posted July 28, 2012 Author Share Posted July 28, 2012 Wow... 0 Views and 0 replies and I'm already on the second page? Link to comment Share on other sites More sharing options...
Shade1982 Posted July 29, 2012 Author Share Posted July 29, 2012 Wow, this is seriously disappointing... One day later, I'm on 21 views and 0 replies and on the third page... Nobody has any knowledge on scripts whatsoever? Why is that hard to believe to me? Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 29, 2012 Share Posted July 29, 2012 What you're asking for is not so easy to do. If you look at the scripts for mannequins/cases, they're quite complicated. The display case has two scripts: WeaponRackTriggerSCRIPT (placed on WeaponRackDisplayPlayerHouse) and WeaponRackActivateSCRIPT (placed on WeaponRackDisplayACTIVATORPlayerHouse). I think the WeaponRackActivateSCRIPT is the one you should look into especially this part: ;--------------------------------------------------- ;START------------------Standard Rack ;----------------------------------------- If ((RackType == 1) && (Patch14COARacks == FALSE)) ; This is the Standard Weapon Rack if (TriggerRef == Game.GetPlayer() as Actor) ; Only the player can activate this MessageAlreadyShown = WRackGlobal.GetValue() if (MessageAlreadyShown == FALSE) ; If the help message hasn't been shown before then show it. WeaponRackActivateMESSAGE.Show() WRackGlobal.SetValue(1) else Trace("DARYL - " + self + " Player activated the weapon rack") PlayersEquippedWeaponType = Game.GetPlayer().GetEquippedItemType(1) ; Get the EquippedItemType that is in the players right hand if (PlayersEquippedWeaponType == 0) || (PlayersEquippedWeaponType == 9) || (PlayersEquippedWeaponType == 10) || (PlayersEquippedWeaponType == 11) ; If the player is unarmed, or has a spell/shield/torch equipped, tell him he needs a weapon equipped. WeaponRackNoWeaponMESSAGE.Show() ;elseif (PlayersEquippedWeaponType == 2) ; If the player has a dagger equipped tell him it doesn't fit. ;WeaponRackNoDaggerMESSAGE.Show() else HandleWeaponPlacement() ; Grabs the weapon from the player and places it in the correct place. endif endif endif ;----------------------------------------- ;END------------------Standard Rack ;--------------------------------------------------- The lines that check for the placed weapon types are these: if (PlayersEquippedWeaponType == 0) || (PlayersEquippedWeaponType == 9) || (PlayersEquippedWeaponType == 10) || (PlayersEquippedWeaponType == 11) ; If the player is unarmed, or has a spell/shield/torch equipped, tell him he needs a weapon equipped. WeaponRackNoWeaponMESSAGE.Show() if you wanted for example only swords to be placed in the case, you could extend the if-statement like this: if (PlayersEquippedWeaponType == 0) || (PlayersEquippedWeaponType == 9) || (PlayersEquippedWeaponType == 10) || (PlayersEquippedWeaponType == 11) ; If the player is unarmed, or has a spell/shield/torch equipped, tell him he needs a weapon equipped. WeaponRackNoWeaponMESSAGE.Show() elseif (PlayersEquippedWeaponType == 3) || (PlayersEquippedWeaponType == 4)|| (PlayersEquippedWeaponType == 6) || (PlayersEquippedWeaponType == 7) || (PlayersEquippedWeaponType == 8) ; if player has no sword equipped, tell him debug.notification("Wrong weapon! Only swords can be placed here!") That would only allow to place weapons of type 1 (1H-Sword) and 5 (2H-Sword). A list of weapon types can be found here. You could also make duplicates of the base objects to give them unique names such as 'Sword Case'. Maybe this helps you to get started. Link to comment Share on other sites More sharing options...
Shade1982 Posted July 29, 2012 Author Share Posted July 29, 2012 (edited) That actually looks great, thanks :). I apologise if I seem rude, it was just really frustrating to me and I didn't realise it was so hard to do... When looking at the script, it looks like it was designed to use one script for all weapon types, but your solution seems to require a different script for each display case... Am I wrong on this one? Or do you have another idea on this? Also, do you know if there is a way to do the same for armor types? Maybe something related to material type? Thanks for the help anyway :). Edited July 29, 2012 by Shade1982 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 30, 2012 Share Posted July 30, 2012 You can use different scripts for each weapon type. It's also possible to add a property to the script, that defines the weapon type and then check for this property in the if-statement. It could look like this: int Property RackTypeWeapon = 1 Auto {The type of weapon that can be placed in this case 1 = 1H-Sword 3 = 1H-Axe 4 = 1H-Mace 5 = 2H-Sword 6 = 2H-Axe/Mace 7 = Bow 8 = Staff }..;--------------------------------------------------- ;START------------------Standard Rack ;----------------------------------------- If ((RackType == 1) && (Patch14COARacks == FALSE)) ; This is the Standard Weapon Rack if (TriggerRef == Game.GetPlayer() as Actor) ; Only the player can activate this MessageAlreadyShown = WRackGlobal.GetValue() if (MessageAlreadyShown == FALSE) ; If the help message hasn't been shown before then show it. WeaponRackActivateMESSAGE.Show() WRackGlobal.SetValue(1) else Trace("DARYL - " + self + " Player activated the weapon rack") PlayersEquippedWeaponType = Game.GetPlayer().GetEquippedItemType(1) ; Get the EquippedItemType that is in the players right hand if (PlayersEquippedWeaponType == 0) || (PlayersEquippedWeaponType == 9) || (PlayersEquippedWeaponType == 10) || (PlayersEquippedWeaponType == 11) ; If the player is unarmed, or has a spell/shield/torch equipped, tell him he needs a weapon equipped. WeaponRackNoWeaponMESSAGE.Show() elseif (PlayersEquippedWeaponType != RackTypeWeapon) debug.notification("This type of weapon can not be placed here!") ;elseif (PlayersEquippedWeaponType == 2) ; If the player has a dagger equipped tell him it doesn't fit. ;WeaponRackNoDaggerMESSAGE.Show() else HandleWeaponPlacement() ; Grabs the weapon from the player and places it in the correct place. endif endif endif ;----------------------------------------- ;END------------------Standard Rack ;---------------------------------- This way, only weapons of one specific type could be placed. It would not be possible to use it for swords and greatswords, for example. I didn't look at the mannequin script yet, but I can imagine it'll be much more complicated to check for the different types of armor and especially for the materials. I'll do a little research on the wiki and post back if I find something usable. Link to comment Share on other sites More sharing options...
Shade1982 Posted July 30, 2012 Author Share Posted July 30, 2012 (edited) Also looks like a great idea. This saves me the trouble of having to create a bunch of scripts :). The issue remains however. It does the check and shows the error message if I try to drop the wrong weapon type, but then drops the weapon regardless. I double-checked and the properties were set correctly. Edited July 30, 2012 by Shade1982 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 30, 2012 Share Posted July 30, 2012 I really don't know what's going wrong on your side. I tested it with a display case of my mod and it actually worked. If it didn't worked, I wouldn't have posted it. I only can recall the steps I took to test it: 1. I copied the WeaponRackActivateSCRIPT entirely and pasted it to a new script, made the changes to the if-statement and compiled. 2. Added the new script to the WeaponRackDisplayACTIVATORPlayerHouse object. 3. Set the properties to the new scripts exactly like it's for the vanilla script, then removed the vanilla script from the object. 4. Finally I tested it from a clean save that was made without the mod/script activated. Link to comment Share on other sites More sharing options...
Shade1982 Posted July 30, 2012 Author Share Posted July 30, 2012 (edited) I'm an idiot... I was testing with the wrong save, the unclean one... Sorry, and thanks for your help and support :). Btw, I hate to ask even more of you, but do you know if it's at all possible to create a script for a specific item? Not just a type? For example, I have a rack for my pickaxe and woodcutters axe. A sort of 'Tool Rack'. Edited July 30, 2012 by Shade1982 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 31, 2012 Share Posted July 31, 2012 (edited) Of course it's possible. This function will read the formID of the players equipped weapon: int PlayersWeapon = Game.GetPlayer().GetEquippedWeapon().GetFormID() It will read it as a decimal value, so to compare with a formID of CK, you'll have to convert the hex value to decimal. For a pickaxe, it's 000E3C16 hex -> 932886 decimal, and for a woodcutters axe it will be 0002F2F4 hex -> 193268 decimal. Maybe there's a better, more elegant way to do this, but it works. The if-statement then will look like this: if (PlayersWeapon != 932886) && (PlayersWeapon != 193268) debug.notification("You have to place a Pickaxe or a Woodcutters Axe!") And this will be the code for the standard rack: ;--------------------------------------------------- ;START------------------Standard Rack ;----------------------------------------- If ((RackType == 1) && (Patch14COARacks == FALSE)) ; This is the Standard Weapon Rack if (TriggerRef == Game.GetPlayer() as Actor) ; Only the player can activate this MessageAlreadyShown = WRackGlobal.GetValue() if (MessageAlreadyShown == FALSE) ; If the help message hasn't been shown before then show it. WeaponRackActivateMESSAGE.Show() WRackGlobal.SetValue(1) else Trace("DARYL - " + self + " Player activated the weapon rack") PlayersEquippedWeaponType = Game.GetPlayer().GetEquippedItemType(1) int PlayersWeapon = Game.GetPlayer().GetEquippedWeapon().GetFormID() ; Get the EquippedItemType that is in the players right hand if (PlayersWeapon != 932886) && (PlayersWeapon != 193268) debug.notification("You have to place a Pickaxe or a Woodcutters Axe!") else HandleWeaponPlacement() ; Grabs the weapon from the player and places it in the correct place. endif endif endif ;----------------------------------------- ;END------------------Standard Rack ;--------------------------------------------------- Btw, I think normally it's not possible to place a woodcutters axe into a rack. To make it work, you can edit the base form of Axe01 in CK and add the keyword WeapTypeBattleAxe. (Hope this will not break anything :whistling:) Edited July 31, 2012 by Ghaunadaur Link to comment Share on other sites More sharing options...
Recommended Posts