On Player Damaged?

Post » Mon Jun 18, 2012 2:03 am

Is there a method tracking when the player gets hit by any source of damage as an event? I want to be able to modify damage to the player based on its source. I know there is the Event OnHit, but I'm not sure how to apply it on a global scale.

Thanks!
User avatar
Steve Bates
 
Posts: 3447
Joined: Sun Aug 26, 2007 2:51 pm

Post » Mon Jun 18, 2012 12:30 pm

Any suggestions?
User avatar
Cash n Class
 
Posts: 3430
Joined: Wed Jun 28, 2006 10:01 am

Post » Mon Jun 18, 2012 12:21 am

Have a variable that you set to = player's health. Before setting it each time, check if player's current health is less than the last time you set the variable.
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Mon Jun 18, 2012 11:26 am

There is no need to set it globally if it is already attached to the player. Create a spell ability with a custom spell effect containing a script with a check for the OnHit event, and add that spell ability to the player. For an example of how this works, see the "AvoidDeath" perk and its dependencies. If you want to modify the player's damage, use damage modifiers. The only reason to make it global is if you want NPCs to use it on eachother.
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Post » Mon Jun 18, 2012 4:16 am

Thanks you guys.

Omnia, how would I go about adding the ability to the player as a default perk or spell?
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Mon Jun 18, 2012 1:01 pm

When I had to add spells/perks to players, I modified the script "MQ101QuestScript". This is the script that assigns the racial spells to the various races (such as Bretons get Conjure Familiar upon creation).

The function is towards the end of the script, and called "function AddRaceSpells()".

There are, of course, other ways to do it (as my way will only work for newly created characters). I believe I've read something about creating an invisible quest, and attaching scripts to it with a global "switch" variable. This would allow you to use the OnInit event to essentially make a script run on game load. I think that would be a better option, if you're wanting to make it retroactive.
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Mon Jun 18, 2012 1:06 pm

I would have never found that. Thanks for the tip!
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Mon Jun 18, 2012 2:10 pm

There is a Start Game Enabled checkbox when creating a quest. Do you think this could have any relevance to what I'm trying to do?
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am


Return to V - Skyrim