12th Archivist
Level: Smitemaster
Rank Points: 789
Registered: 12-07-2008
IP: Logged
|
Re: The BIG thread about scripting (+3)
Weapon storage and switcher! The following code can be copied and pasted into a character using Ctrl-B and Ctrl-Shift-B, respectively.
(Secreted due to length)
Click here to view the secret text ×
Imperative 14
Label Start
Wait for entity Player 8,3,8,3
Cut scene 1
Answer option "Examine weapons",Swap Weapon
Answer option "Examine shields",Swap Shield
Answer option "Examine items",Swap Accessory
Question Alter the contents of the chest:
Label Swap Weapon
If ...
Wait until var "Sword8" = 0
If ...
Wait until var "Sword7" = 0
If ...
Wait until var "Sword6" = 0
If ...
Wait until var "Sword5" = 0
If ...
Wait until var "Sword4" = 0
If ...
Wait until var "Sword3" = 0
If ...
Wait until var "Sword2" = 0
If ...
Wait until var "Sword1" = 0
If ...
Wait until var "Sword0" = 0
Speech "I have no weapons.",Normal,Player,0,.
Go to End
If End
Answer option "Put current weapon in the chest",Put current weapon in chest
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
Go to End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Pick up $SwordName4$",Swap with fourth stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Swap current weapon with $SwordName4$",Swap with fourth stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Pick up $SwordName4$",Swap with fourth stored weapon
Answer option "Pick up $SwordName5$",Swap with fifth stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Swap current weapon with $SwordName4$",Swap with fourth stored weapon
Answer option "Swap current weapon with $SwordName5$",Swap with fifth stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Pick up $SwordName4$",Swap with fourth stored weapon
Answer option "Pick up $SwordName5$",Swap with fifth stored weapon
Answer option "Pick up $SwordName6$",Swap with sixth stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Swap current weapon with $SwordName4$",Swap with fourth stored weapon
Answer option "Swap current weapon with $SwordName5$",Swap with fifth stored weapon
Answer option "Swap current weapon with $SwordName6$",Swap with sixth stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Pick up $SwordName4$",Swap with fourth stored weapon
Answer option "Pick up $SwordName5$",Swap with fifth stored weapon
Answer option "Pick up $SwordName6$",Swap with sixth stored weapon
Answer option "Pick up $SwordName7$",Swap with seventh stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Put current weapon in chest",Put current weapon in chest
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Swap current weapon with $SwordName4$",Swap with fourth stored weapon
Answer option "Swap current weapon with $SwordName5$",Swap with fifth stored weapon
Answer option "Swap current weapon with $SwordName6$",Swap with sixth stored weapon
Answer option "Swap current weapon with $SwordName7$",Swap with seventh stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
If End
If ...
Wait until var "Sword0" = 0
Answer option "Pick up $SwordName1$",Swap with first weapon
Answer option "Pick up $SwordName2$",Swap with second stored weapon
Answer option "Pick up $SwordName3$",Swap with third stored weapon
Answer option "Pick up $SwordName4$",Swap with fourth stored weapon
Answer option "Pick up $SwordName5$",Swap with fifth stored weapon
Answer option "Pick up $SwordName6$",Swap with sixth stored weapon
Answer option "Pick up $SwordName7$",Swap with seventh stored weapon
Answer option "Pick up $SwordName8$",Swap with eighth stored weapon
Answer option "Do nothing", End
Question Alter your weapons?
Else
Answer option "Swap current weapon with $SwordName1$",Swap with first weapon
Answer option "Swap current weapon with $SwordName2$",Swap with second stored weapon
Answer option "Swap current weapon with $SwordName3$",Swap with third stored weapon
Answer option "Swap current weapon with $SwordName4$",Swap with fourth stored weapon
Answer option "Swap current weapon with $SwordName5$",Swap with fifth stored weapon
Answer option "Swap current weapon with $SwordName6$",Swap with sixth stored weapon
Answer option "Swap current weapon with $SwordName7$",Swap with seventh stored weapon
Answer option "Swap current weapon with $SwordName8$",Swap with eighth stored weapon
Answer option "Keep current weapon equipped", End
Question Alter your weapons?
If End
Label Put current weapon in chest
Equipment 1,1
Set var "Sword8" = Sword7
Set var "Sword7" = Sword6
Set var "Sword6" = Sword5
Set var "Sword5" = Sword4
Set var "Sword4" = Sword3
Set var "Sword3" = Sword2
Set var "Sword2" = Sword1
Set var "Sword1" = Sword0
Set var "Sword0" = 0
Set var "SwordName8" : $SwordName7$
Set var "SwordName7" : $SwordName6$
Set var "SwordName6" : $SwordName5$
Set var "SwordName5" : $SwordName4$
Set var "SwordName4" : $SwordName3$
Set var "SwordName3" : $SwordName2$
Set var "SwordName2" : $SwordName1$
Set var "SwordName1" : $SwordName0$
Set var "SwordName0" :
Go to End
Label Swap with first weapon
Equipment 1,1
Set var "SwordTemp" = Sword1
Set var "Sword1" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName1$
Set var "SwordName1" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with second stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword2
Set var "Sword2" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName2$
Set var "SwordName2" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with third stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword3
Set var "Sword3" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName3$
Set var "SwordName3" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with fourth stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword4
Set var "Sword4" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName4$
Set var "SwordName4" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with fifth stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword5
Set var "Sword5" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName5$
Set var "SwordName5" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with sixth stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword6
Set var "Sword6" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName6$
Set var "SwordName6" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with seventh stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword7
Set var "Sword7" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName7$
Set var "SwordName7" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap with eighth stored weapon
Equipment 1,1
Set var "SwordTemp" = Sword8
Set var "Sword8" = Sword0
Set var "Sword0" = SwordTemp
Set var "SwordTemp" = 0
Set var "_Sword" = Sword0
Set var "SwordNameTemp" : $SwordName8$
Set var "SwordName8" : $SwordName0$
Set var "SwordName0" : $SwordNameTemp$
Set var "SwordNameTemp" = 0
Go to End
Label Swap Shield
Speech "This script does not yet support such functionality.",Normal,Self,0,.
Label Swap Accessory
Speech "This script does not yet support such functionality.",Normal,Self,0,.
Label End
Cut scene 0
Wait while entity is Player 8,3,8,3
Go to Start
What this script does is it allows you to store and retrieve up to eight custom weapons at a time. To use, create a character with this script:
Click here to view the secret text × Imperative 12
Wait for player to touch me
Set var "Sword0" = 20000
Set var "SwordName0" : First
Set var "_Sword" = Sword0
Create more characters with similar scripts (change 20000 to successive sword values and change the " First" to more appropriate names) to simulate having more and more swords the player can store and swap out using the weapon chest. Note that the first question allows you to do the same with custom shields and custom accessories, but those would have very similar scripts and so were not elaborated upon.
One problem with the script is that "First" can be nameless in the weapon swap. I will see if I can get a fix for this tomorrow. Way too late for me, after already bashing dozens of bugs with the script over the past five hours. EDIT: After over a week, I finally found the bug and fixed it. The error was that in the " Label Put current weapon in chest" , two of the name swaps were in the wrong order, thus giving a sword variable the wrong name. This has been fixed. Anyone looking to use the script should delete their version of the script and recopy the script in this post.
Credit me if you wish to use the script, though TFMurphy also had a hand in it, so you can decide if you want to credit him as well.
EDIT 2: I just wanted to note that with some logic and probably additional variables (or additional If... commands), you can create dynamically changing inventories, all in a single character script (i.e. without using the Build command to create additional inventory slots so that the player can step on them). I will see what I can do about getting an example script of this posted.
____________________________
It was going well until it exploded.
~Scott Manley
Check out the DROD Wikia project here!
[Last edited by 12th Archivist at 02-21-2011 11:48 PM]
|