Jump to content

Armor Switching Script


Trandoshan

Recommended Posts

Hey, probably the wrong forum, but I was recently searching for a mod that automatically switched to a new piece of clothing or armor after a certain amount of strikes on a character.

 

I looked and found nothing, so I come to the forums with limited scripting ability to ask for a script that might achieve the above result.

 

The reasoning? I was originally planning on creating a realism mod that showed damage to armor and clothing after being hit with certain types of spells and weapons. There are other reasons that the prude would look down upon... anyways...

 

I have played around with many Vanilla clothing meshes to make them look damaged (Such as removing vertices, or creating burn marks on textures). The only real thing left to do is create a script for the clothing that replaces them with the damaged mesh/texture after being damaged in-game with weapons. The concept has probably been explored, and if it has I want to look at those mods and reference their scripts. If not, post some Ideas and examples. If such a script is impossible, or too complex just go ahead and light it on fire. I'm used to disappointment when it comes to modding :P .

Link to comment
Share on other sites

Hey, probably the wrong forum, but I was recently searching for a mod that automatically switched to a new piece of clothing or armor after a certain amount of strikes on a character.

 

I looked and found nothing, so I come to the forums with limited scripting ability to ask for a script that might achieve the above result.

 

The reasoning? I was originally planning on creating a realism mod that showed damage to armor and clothing after being hit with certain types of spells and weapons. There are other reasons that the prude would look down upon... anyways...

 

I have played around with many Vanilla clothing meshes to make them look damaged (Such as removing vertices, or creating burn marks on textures). The only real thing left to do is create a script for the clothing that replaces them with the damaged mesh/texture after being damaged in-game with weapons. The concept has probably been explored, and if it has I want to look at those mods and reference their scripts. If not, post some Ideas and examples. If such a script is impossible, or too complex just go ahead and light it on fire. I'm used to disappointment when it comes to modding :P .

 

I made a mod for auto weapon switching when sheathed: http://www.tesnexus.com/downloads/file.php?id=27430

 

download and alter the code anyway you like.

 

I know it's easy to just ask for code, but i would recommend that you try to understand it and make your own.

 

Anyway, my code changes weapons when you sheath and unsheathe them. So, you would need to alter the code to change armor pieces when health drop below or to a certain level.

 

Here's the list of functions: http://cs.elderscrolls.com/constwiki/index...st_of_Functions

 

that site also has tutorials in case you need them.

 

///

 

If you don't mind giving me credit in your mod, i'll be happy to write the code.

Link to comment
Share on other sites

Three blessings to you, Ragna. I will check these scripts out and see what I can do with them. Based on the purpose of your weapon switching, I will probably need to alter the script slightly. If I ever release this though, I will indeed credit your mod. If all fails, I will ask for your help in detail.

 

Though your right about one thing...

 

I know it's easy to just ask for code, but i would recommend that you try to understand it and make your own.

 

How will I ever learn unless I do it myself!

 

Also thanks for the links, I will definitely use them.

Link to comment
Share on other sites

This Isn't meant to be a bump, but an update.

 

I have looked at the website that I was given, and it really helped me formulate a plan. Not only that, but the weapon shifting script gave me a general Idea about what I'm up against. I have created a basic script to show wear on clothing over time that will jump start my plan. My only qualm now is....

 

There doesn't seem to be any commands that will activate the effects of a script based on the condition of the armor. I suppose the Command "GetArmorRating" might work due to the fact that when a piece of armor reaches a condition of 0 it's armor rating also becomes 0, but that's useless due to the fact that Armor rating includes the totals of all other equipped armor. I would have to create custom armors, or fuse meshes together in CS (Not a really big deal). Can't find any OBSE scripts that suit my mood, but I haven't installed the source files anyways.

 

So, does anyone have any ideas on how we could include damage to armor as a Administrative Command (or Variable Function. Too much terminology...)

Link to comment
Share on other sites

As an alternative to creating completely new armor for everything I had a thought (but not the ambition to test it yet, though after typing a paragraph I might get myself excited who knows).

 

Instead of creating a new piece of armor to be equipped which would be a pain since you don't want it to be in the inventory initially... Here's an example of how I'd imagine that process going:

 

Player has X chest piece equipped.

Player fights a particularly nasty goblin and forgets to block a few times, thus we want to give his armor a battle worn look.

After a predetermined amount of damage (or perhaps a percentage of the items maximum health which I believe is doable) the item would have to be:

1. Unequipped

2. Removed from the inventory (after all the new chestpiece would ideally replace the old one)

3. The new damaged chestpiece Y (which if you wanted to implement it would have a lower armor rating due to the damage) would be added to the inventory and then equipped.

 

This in and of itself isn't terribly hard but it leaves a lot of bases uncovered. For instance what happens when you repair an item? You'd have to make a seperate script that would constantly checked and if repaired to a certain level would repeat the above process in reverse. Also the new item would start initially with full health (unless you explicitly scripted otherwise), if you wanted more than a damage and nondamaged version it would become quite tedious to script each piece.

 

Instead of all that, you could simply crate a texture to represent damage and use the OBSE function SetIconPath which would (if I understand it correctly) apply a new texture to the same item, it would also be easy at that point to implement a simply script that scaled the armor rating with the durability.

 

I might be wrong about that specific command, but here's the OBSE documentation: http://obse.silverlock.org/obse_command_doc.html

 

Scour through it, Especially under The heading Simple and Wearable the command you want is probably similar to the one I mentioned only somewhere in there.

 

Also RagnaHighArc is correct to the best of my knowledge that is the way to track the equipments durability.

 

Like I said untested, but from my general understanding of scripting should be what you're looking for.

 

As for the "other reasons" it would be entirely possible to entirely destroy an item once it's taken too much damage (simply by unequipping it and removing it from that particular actors inventory), or if you rather simply by unequipping it and leaving it in an unwearable state until repaired.

 

Just my thought. Hope they help.

Link to comment
Share on other sites

Well, my code adds the item, then equips it. So, it doesn't force the player to carry all the item variations.

 

So, the process you mentioned is somewhat close to what my code does.

 

I think implementing the "setIconPath" lines to his scripts would work for showing minor damage to the armors(like dents, burns, frost), then having my code work to show extreme damage, like cracked and/or broken parts.

 

///

 

BTW Isn't "setIconPath" just made to change the icon in the hud?

Link to comment
Share on other sites

  • 3 weeks later...

Sorry to press ~, click on this thread, type resurrect, and press enter, but after a few weeks of balancing school with :wallbash: with scripting I have come up with a script that works.... for the first level of damage.

 

scn AAAarmorremovalscript

;OBSE was here!

float armorHealthUpper

ref armorUpperOLD

ref armorUpperNEW

begin GameMode

set armorHealthUpper to player.getEquippedCurrentHealth 2
set armorUpperNEW to armorUpperOLD
set armorUpperNEW to player.getEquippedObject 2

		if ( armorHealthUpper <= 1 ) && ( player.GetObjectType armorUpperNEW == 20 )
			player.additem AAAScriptTesterArmor1 1
			player.equipitem AAAScriptTesterArmor1
			player.removeitem AAAScriptTesterArmor0 1
			if ( armorUpperNEW != armorUpperOLD )
				Message "Test Message"
			endif		
		endif

end

 

This is the first part of the script for the first piece of armor. For the second transition I alter the script very little.

 

scn AAAarmorremovalscript1

;OBSE was here!

float armorHealthUpper

ref armorUpperOLD

ref armorUpperNEW

begin GameMode

set armorHealthUpper to player.getEquippedCurrentHealth 2
set armorUpperNEW to armorUpperOLD
set armorUpperNEW to player.getEquippedObject 2

		if ( armorHealthUpper <= 1 ) && ( player.GetObjectType armorUpperNEW == 20 )
			player.additem AAAScriptTesterArmor2 1
			player.equipitem AAAScriptTesterArmor2
			player.removeitem AAAScriptTesterArmor1 1
			if ( armorUpperNEW != armorUpperOLD )
				Message "Test Message"
			endif		
		endif

end

 

The script is simple gold. It should work perfectly. However, it seems that object scripts function when an object is not in your inventory. In fact, all of the scripts for all of the clothing (For that body slot) activate at the same time. So the first script works well, but the other five activate too. This leaving all of the broken armors in my inventory. Any work arounds to this problem?

 

I have a few Ideas that I will attempt (Switching around the player.removeitem with the player.additem and player.equipitem may solve it. Though that remains to be seen.

 

BTW RagnaHighArc. Thanks a million. I may have not used your scripts very much at all, but if I do release this, I will put you at the top of the credits for jumpstarting my mind. Kudos.

 

Also on the note of SetIconPaths...

I tried to use this to show the texture damage, but I was unable to make it work properly.

 

Edit: Switched the script around like I mentioned above... It crashed :wallbash:

Link to comment
Share on other sites

Trying to equip items within the same block that adds them can make the script malfunction.

 

You need at least a frame before you can equip added items.

 

Creating another gamemode block and adding a return and check to the first gamemode block should help.

 

Something like this:

 

if (doOnce == 0)
return

 

and this on the 2nd block

 

if (doOnce == 1)

 

And the first line of this code is useless:

 

set armorUpperNEW to armorUpperOLD
set armorUpperNEW to player.getEquippedObject 2

 

you're setting armorUpperNEW to a ref and then to an object. So, "set armorUpperNEW to armorUpperOLD" doesn't do anything.

 

Here's how i would write the code

 

scn RagnaArmor

short doOnce
long ArmorHealth

begin gameMode

set ArmorHealth to player.GetEquippedCurrentHealth 2

if (doOnce == 0) && (player.getEquipped MyTestArmor) && (ArmorHealth < MyNumber)
player.additem DamagedArmor 1
set doOnce to 1
return
endif
end

begin gamemode

if (doOnce == 1)
player.equipitem DamagedArmor
player.removeItem MyTestArmor 1
endif
end

 

That code is best suited for quest scripts. I recommend that you use one large quest script instead of attaching a lot of little scripts to every item the needs them.

Link to comment
Share on other sites

After happily including your script into the mod, and creating the necessary reqs (Quest) all is well. I have successfully created a script that will show twenty different levels of damage one after the other. I feel crappy that I had to create my script nearly identical to yours, but at least it finally works.

 

Edit:

 

scn AAAMoonArmorDegredationScript

;Requires OBSE

short doOnce
short ArmorHealth
float fQuestDelayTime .01



begin gameMode

set ArmorHealth to player.GetEquippedCurrentHealth 18

if ( ArmorHealth == 0 ) && (player.getEquipped Moon0 == 1) && (doOnce == 0)
player.additem Moon1 1
set doOnce to 1
return
endif
end

begin gamemode

if (doOnce == 1)
player.equipitem Moon1
player.removeItem Moon0 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon1 == 1) && (doOnce == 1)
player.additem Moon2 1
set doOnce to 2
return
endif
end

begin gamemode

if (doOnce == 2)
player.equipitem Moon2
player.removeItem Moon1 1
endif
end

begin gameMode

if ( ArmorHealth == 0 ) && (player.getEquipped Moon2 == 1) && (doOnce == 2)
player.additem Moon3 1
set doOnce to 3
return
endif
end

begin gamemode

if (doOnce == 3)
player.equipitem Moon3
player.removeItem Moon2 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon3 == 1) && (doOnce == 3)
player.additem Moon4 1
set doOnce to 4
return
endif
end

begin gamemode

if (doOnce == 4)
player.equipitem Moon4
player.removeItem Moon3 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon4 == 1) && (doOnce == 4)
player.additem Moon5 1
set doOnce to 5
return
endif
end

begin gamemode

if (doOnce == 5)
player.equipitem Moon5
player.removeItem Moon4 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon5 == 1) && (doOnce == 5)
player.additem Moon6 1
set doOnce to 6
return
endif
end

begin gamemode

if (doOnce == 6)
player.equipitem Moon6
player.removeItem Moon5 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon6 == 1) && (doOnce == 6)
player.additem Moon7 1
set doOnce to 7
return
endif
end

begin gamemode

if (doOnce == 7)
player.equipitem Moon7
player.removeItem Moon6 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon7 == 1) && (doOnce == 7)
player.additem Moon8 1
set doOnce to 8
return
endif
end

begin gamemode

if (doOnce == 8)
player.equipitem Moon8
player.removeItem Moon7 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon8 == 1) && (doOnce == 8)
player.additem Moon9 1
set doOnce to 9
return
endif
end

begin gamemode

if (doOnce == 9)
player.equipitem Moon9
player.removeItem Moon8 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon9 == 1) && (doOnce == 9)
player.additem Moon10 1
set doOnce to 10
return
endif
end

begin gamemode

if (doOnce == 10)
player.equipitem Moon10
player.removeItem Moon9 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon10 == 1) && (doOnce == 10)
player.additem Moon11 1
set doOnce to 11
return
endif
end

begin gamemode

if (doOnce == 11)
player.equipitem Moon11
player.removeItem Moon10 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon11 == 1) && (doOnce == 11)
player.additem Moon12 1
set doOnce to 12
return
endif
end

begin gamemode

if (doOnce == 12)
player.equipitem Moon12
player.removeItem Moon11 1
endif
end

begin gameMode


if ( ArmorHealth == 0 ) && (player.getEquipped Moon12 == 1) && (doOnce == 12)
player.additem Moon13 1
set doOnce to 13
return
endif
end

begin gamemode

if (doOnce == 13)
message "your armor is completely useless."
player.equipitem Moon13
player.removeItem Moon12 1
set doOnce to 0
; Set doOnce to 0 creates a path to rebreak armor in case of a new equipment. Unable to set it back to 0 if the other stages are unequipped. Possible but complex as hell!
endif
end

 

Now there is a final problem to which you may have the solution to. I want the script to replay as a whole, but the return functions stop it from occurring. Is there anyway to reset the return function in a single sentence? I'll be looking on my end as always. Thank you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...