4017jman Posted January 11, 2016 Share Posted January 11, 2016 Hello, just wondering if this would be possible as a script attached to a weapon: So I want a script that when you enter combat (or when you use a special spell power?), starts a timer for - lets say 20 seconds that tracks how many times you have hit an (any) enemy (Hitcount) since the start of that instance of combat until the 20 seconds are up. Then it takes that value and modifies the base damage of the weapon IE: set base damage (hitcount * (a float) for something like 10 seconds (alternatively if possible instead of tracking the hitcount it could track the amount of damage done and multiply that by a float value of my desire?)Once those 10 seconds are up the weapon's damage will go back to whatever it was before and a cool down timer will begin before the whole process starts again. So to reiterate i'm wondering if this would be possible and maybe get some examples of how to write out the script. I also I'm down with using SKSE (as anyone would be) if need be :) Link to comment Share on other sites More sharing options...
MichikoUnknownFox Posted January 11, 2016 Share Posted January 11, 2016 I think it's possible but likely unreliable in real game conditions. Papyrus is very slow in processing and if you have a lot of other scripts running (even the base game actually has a lot of scripts running) it could freeze up the Virtual Machine. Even worse is that it doesn't crash [in this context] so you don't know that it happened until you notice that none of your scripted effects (for example, trying to equip a hotkeyed equipment set from SkyUI) are working until you restart the game, or sometimes it fixes itself after a while but I've tried waiting like 10 minutes in game and the VM was still frozen with all the buffered script calls it hasn't processed yet. For an example of a "script heavy" (actually the script itself is simple, it just does so much on hit events) mod, look at Locational Damage. It'll be reliable in early game when it's just you fighting 1-2 bandits or draugrs in the beginning. But as more and more happens in combat and more quests start running, you'll notice that sometimes a Locational Damage "critical hit" will take effect a few minutes after combat has ended already, if at all, and everything else might also not work for a while. That's Papyrus script lag. Instead of using a script, you can try using magic effects instead. I'm doing something similar with a fake combo system for my own mod and my initial tests say it works and seems to be reliable even with multiple NPCs doing the same thing. I'll give you a simple step-by-step on what to do. 1. Make a perk for the attacker, in this case the player. 1a. Make a magic effect for when you want the combo to start if needed. You can skip this if you want it to work all the time as long as you're hitting something. 2. Make a magic effect (Fire and Forget casting type and Contact delivery) for every valid combo count. Name each magic effect accordingly, like "Hit 01" or something. This can be tedious if you plan to go anywhere above 10, so I suggest starting off with a low value initially. For this example, let's say 3 hit combo. 3. Make a spell and attach the combo magic effect to it. Give it a short duration, like 2 or 3 seconds. Meaning if nobody applies another combo hit on this same target the whole thing wears off. 4. Attach the spell to the perk under the perk entry point Apply Combat Hit Spell. This means that when the attacker hits the target, it'll apply Hit 01. 5. For each subsequent hit ("Hit 02") make give it a condition that the target has the magic effect "Hit 01" for it to apply. This means that when the attacker hits the target and they have Hit 01 already, it'll give them Hit 02 instead. *. Remember that short duration? Well that means if nobody with this perk attacks the target, the combo will wear out. If they don't have the combo hit effects on them anymore, the next hit they take will be Hit 01 again. 6. Repeat this for each valid combo you want. 7. Either in a new perk or the same one (doesn't matter really but you may want to separate them so it's easier to organize, especially if you have a lot of combo hits planned), make it so that the Perk Entry Point is Calculate Weapon Damage under the condition of the particular hit counter, then increase the damage to whatever you want. For example, if they have Hit 01, meaning you're applying Hit 02, you can increase damage against them by 10%. If they have Hit 02, and you're applying Hit 03, increase damage by 20% and so on. 8. Double check your work and test if it does anything in game. One way to test it is to pause the game via console after you hit somebody, click them to select them then see if they have your magic effect applied (either with console command HasMagicEffect <your effect's formid> or with Mfg Console). It's important to note though that if you plan to give this effect to NPCs (followers for example), everybody can contribute to the combo counter. So if for example both Lydia and I have this effect and we're attacking the same target, when Lydia attacks she might apply Hit 01, and when I attack within the time frame I'll apply Hit 02, and so on. This may or may not be something you want. Just don't give it to NPCs as well if you don't like it, or add special checks for whatever. Good luck! Link to comment Share on other sites More sharing options...
4017jman Posted January 11, 2016 Author Share Posted January 11, 2016 Dude thats actually a waaay better way of doing things, ill be sure to it out! Thanks Yo! Link to comment Share on other sites More sharing options...
Deleted2838758User Posted January 11, 2016 Share Posted January 11, 2016 On 1/11/2016 at 12:49 PM, OukaHosokawa said: I think it's possible but likely unreliable in real game conditions. Papyrus is very slow in processing and if you have a lot of other scripts running (even the base game actually has a lot of scripts running) it could freeze up the Virtual Machine. Even worse is that it doesn't crash [in this context] so you don't know that it happened until you notice that none of your scripted effects (for example, trying to equip a hotkeyed equipment set from SkyUI) are working until you restart the game, or sometimes it fixes itself after a while but I've tried waiting like 10 minutes in game and the VM was still frozen with all the buffered script calls it hasn't processed yet. For an example of a "script heavy" (actually the script itself is simple, it just does so much on hit events) mod, look at Locational Damage. It'll be reliable in early game when it's just you fighting 1-2 bandits or draugrs in the beginning. But as more and more happens in combat and more quests start running, you'll notice that sometimes a Locational Damage "critical hit" will take effect a few minutes after combat has ended already, if at all, and everything else might also not work for a while. That's Papyrus script lag. Instead of using a script, you can try using magic effects instead. I'm doing something similar with a fake combo system for my own mod and my initial tests say it works and seems to be reliable even with multiple NPCs doing the same thing. I'll give you a simple step-by-step on what to do. 1. Make a perk for the attacker, in this case the player. 1a. Make a magic effect for when you want the combo to start if needed. You can skip this if you want it to work all the time as long as you're hitting something. 2. Make a magic effect (Fire and Forget casting type and Contact delivery) for every valid combo count. Name each magic effect accordingly, like "Hit 01" or something. This can be tedious if you plan to go anywhere above 10, so I suggest starting off with a low value initially. For this example, let's say 3 hit combo. 3. Make a spell and attach the combo magic effect to it. Give it a short duration, like 2 or 3 seconds. Meaning if nobody applies another combo hit on this same target the whole thing wears off. 4. Attach the spell to the perk under the perk entry point Apply Combat Hit Spell. This means that when the attacker hits the target, it'll apply Hit 01. 5. For each subsequent hit ("Hit 02") make give it a condition that the target has the magic effect "Hit 01" for it to apply. This means that when the attacker hits the target and they have Hit 01 already, it'll give them Hit 02 instead. *. Remember that short duration? Well that means if nobody with this perk attacks the target, the combo will wear out. If they don't have the combo hit effects on them anymore, the next hit they take will be Hit 01 again. 6. Repeat this for each valid combo you want. 7. Either in a new perk or the same one (doesn't matter really but you may want to separate them so it's easier to organize, especially if you have a lot of combo hits planned), make it so that the Perk Entry Point is Calculate Weapon Damage under the condition of the particular hit counter, then increase the damage to whatever you want. For example, if they have Hit 01, meaning you're applying Hit 02, you can increase damage against them by 10%. If they have Hit 02, and you're applying Hit 03, increase damage by 20% and so on. 8. Double check your work and test if it does anything in game. One way to test it is to pause the game via console after you hit somebody, click them to select them then see if they have your magic effect applied (either with console command HasMagicEffect <your effect's formid> or with Mfg Console). It's important to note though that if you plan to give this effect to NPCs (followers for example), everybody can contribute to the combo counter. So if for example both Lydia and I have this effect and we're attacking the same target, when Lydia attacks she might apply Hit 01, and when I attack within the time frame I'll apply Hit 02, and so on. This may or may not be something you want. Just don't give it to NPCs as well if you don't like it, or add special checks for whatever. Good luck!That is acutally a bad idea for multiple reasons 1) It will not stack with other "Apply combat hit spells". For example, it will either not work if you have taken the Warmaster, Deep Wounds, Paralyzing Strike, Hack and Slash perks. I only use "Apply combat hit spells" entry points if I'm sure I'm creating a mod that will overhaul the entire perk tree anyway. 2) Conditions on spells/perks are checked every time the spell hit or every 1 second if it's a constant effect on a target, and having 20 CONDITIONS in one spell can be sure to cause some strain on the comupter (not too much, but it's actually higher than a very simple script). 3) This can actually be done by a very easy script that won't put too much pressure (if none at all) on the game.I'm still average when it comes to scripting so there is probably a better spell idea than this : Create a dummy Faction. Attach a script + the faction to each actor that is in combat ('I suggest reading about "Dynamically attaching scripts to actors"). Add an onhit event on the target When the even triggers, detect if Aksource (the thing that hit the target, is a weapon) If yes, Increase the target's faction rank by 1. When the target's factionrank reach 20, do your desired effect. Dispel the effect and remove the target from the dummy faction when he leaves combat or your mod is uninstalled.This is the best I could come up, it's very lightweight on script usage, but I'm 100% sure a better scripter could make it even lighter. Link to comment Share on other sites More sharing options...
lofgren Posted January 12, 2016 Share Posted January 12, 2016 Very clever keeping track of the stat with the faction rank. I may have to redo a mod I am working on to take advantage of that. Link to comment Share on other sites More sharing options...
Recommended Posts