Harmlezz Posted September 14, 2012 Share Posted September 14, 2012 (edited) I need to track when the player receives damage. I have found the script block type: Begin OnHit; script goes hereEnd But how do I attach this script to the player? And does OnHit work for the player? If someone knows how to intercept / get a callback when the player is hit please let me know. Thanks in advance, Harmlezz Edited September 14, 2012 by Harmlezz Link to comment Share on other sites More sharing options...
GrindedStone Posted September 23, 2012 Share Posted September 23, 2012 OnHit isn't going to work well if it even works at all. What is it in the game that you want to do? Link to comment Share on other sites More sharing options...
Gribbleshnibit8 Posted September 24, 2012 Share Posted September 24, 2012 OnHit would probably work, since I think Arewn's uses an OnHit script. However, it's a very very bad idea to attach a script to the player. For one, only one mod can do it, and the last loaded mod would override all the other mods that do, breaking them. Secondly, as Arwen's shows, it can have adverse effects in interacting with other mods, and even the base game, overriding variables and other things and generally breaking the game. Your best bet is either a quest with a very very small quest delay. About 0.01 would work, though scripts only run each frame, so you're limited to frame rate. A number lower than 1/60th of a second will pretty much guarantee that it'll run every frame. The other option is an actor effect with a script base effect on it that runs a ScriptEffectUpdate block. I'm going to guess that your use is in some method of trying to keep the player from being killed. There are a couple of mods that have set up an 'energy shield' system. They handle it pretty well, so you might go have a look at their scripts to see how they pulled it off. Link to comment Share on other sites More sharing options...
GrindedStone Posted September 24, 2012 Share Posted September 24, 2012 Is it just me or did you just say that it will probably work except for generally breaking the game? Ha hah Don't look at me, you're the one that said it. You can't say for sure if it needs a quest, object, or effect script until you know what it is they are trying to do. Anything we say until then is speculation. So why bother. Focus on the problem. They want to do something but don't know how. We want to help them, but don't know what they want to do. Arwen's is clearly a lopsided development at best so it wouldn't serve as a good example for anything even if we had the time to fully understand it. I get it, totally. You attach a script to the player. Some other mod does the same thing. That's two different things. On one hand you have the desire to create something so bad you're willing to construct an overly complex behemoth. Then on the other you have a design flaw because you ignored the fact that indeed there are other mods out there. Randy P. used to demonstrate this by beating a VCR into pieces with a hammer in front of the new computer students. Then saying you never want to build something that causes people to do that. Idk if it's helpful here, but it's funny at least. Link to comment Share on other sites More sharing options...
Harmlezz Posted September 27, 2012 Author Share Posted September 27, 2012 (edited) Hi GrindedStone and Gribbleshnibit8! I would like to thank you both sharing your opinions about this topic with me. I played a little bit around and came to the conclusion that there is no real support to detect who did hit the player using which source of damage. Now my approach is to run a quest script every 5 seconds and if this script detects the player is in combat I change it to 1 second. I don't want to burden the game engine too much with my mod (what I expect from other mods as well, but the fewest do). In combat I do a fuzzy calculation: when I detect the player received damage I inspect enemies in combat targeting the player. For all of them I obtain the weapon used (more precisely the weapon damage type) and track the damage as a weighted fraction of each. That is fine for me even so it is far away from being exact. Do you have any comments about my approach? Bye and thanks for you participation, Harmlezz Edited September 27, 2012 by Harmlezz Link to comment Share on other sites More sharing options...
DizzasterJuice Posted September 27, 2012 Share Posted September 27, 2012 ...and came to the conclusion that there is no real support to detect who did hit the player using which source of damage...Someone once told me that GetCauseofDeath works to detemine the highest damage type (or maybe it was the last damage dealt?) even if the actor isn't dead but I never confirmed that.Cause of Death values: NONE = -1 EXPLOSION = 0 GUN = 2 BLUNT_WEAPON = 3 HAND_TO_HAND = 4 OBJECT_IMPACT = 5 POISON = 6 RADIATION = 7 Link to comment Share on other sites More sharing options...
rickerhk Posted September 28, 2012 Share Posted September 28, 2012 You could just monitor player health from one frame to the next, on a token or fast quest script, to catch when it drops. I've done it this way before. You could also narrow it a bit with the condition player.IsInCombat Link to comment Share on other sites More sharing options...
Recommended Posts