Getting the Actor that the Player Hits

Involved development of the OpenMW construction set.
Post Reply
Holo74
Posts: 2
Joined: 08 Jul 2018, 09:18

Getting the Actor that the Player Hits

Post by Holo74 » 08 Jul 2018, 09:23

I was wondering if there is a way to detect when the player hits another npc? I am trying to cast a spell on the target when the player strikes them with a weapon while wearing an item. Does anyone know how to do it or a work around that can work as well? The effect can not be on the weapon because I want it to apply to every weapon as long as the player is wearing the item. I am quite new to scripting in this editor so I don't know much, though I did do some research prior to this.

User avatar
kuyondo
Posts: 221
Joined: 29 Mar 2016, 17:45

Re: Getting the Actor that the Player Hits

Post by kuyondo » 09 Jul 2018, 11:00

Trying asking help in the content development section, you might get some players there.

Loriel
Posts: 142
Joined: 28 May 2015, 00:44

Re: Getting the Actor that the Player Hits

Post by Loriel » 09 Jul 2018, 13:10

I think you might find an option for part of the solution in the skill-development code in Emma's more recent companions. As I recall, they monitor the sounds generated for weapon-hits, and adjust skills accordingly.

You will need to identify the target - looks like gettarget may be what you need for that. Unfortunately it doesn't return the ref for the target, effectively it returns "yes" or "no". so I think you would need to loop through all the ids of potential targets until you get a positive response.

No doubt all this will be easier post 1.0.

Loriel

silentthief
Posts: 309
Joined: 18 Apr 2013, 01:20
Location: Currently traversing the Ascadian Isles

Re: Getting the Actor that the Player Hits

Post by silentthief » 10 Jul 2018, 14:58

I have a solution using the vanilla CS: http://en.uesp.net/morrow/editor/mw_csc ... #onpchitme

This may help. However, I have not tried to use the new CS yet.

ST
"Hurry, hurry! Last boat to Solstheim! Until the next one. Hah-ha-hah."

User avatar
kuyondo
Posts: 221
Joined: 29 Mar 2016, 17:45

Re: Getting the Actor that the Player Hits

Post by kuyondo » 10 Jul 2018, 17:35

Holo74 wrote:
08 Jul 2018, 09:23
I was wondering if there is a way to detect when the player hits another npc? I am trying to cast a spell on the target when the player strikes them with a weapon while wearing an item. Does anyone know how to do it or a work around that can work as well? The effect can not be on the weapon because I want it to apply to every weapon as long as the player is wearing the item. I am quite new to scripting in this editor so I don't know much, though I did do some research prior to this.
This actually requires advanced scripting to be implemented. I dont think its currently possible to implement this in the CS. I remember a mod that has a similar idea but that one uses the Morrowind Script Extender to be able to function. The catch is that, its impossible to detect an attack(or hit) on ANY npc(not just 1), TESCS lacks the appropriate command. Right now, we can only detect an attack(or hit) on a declared entity.

I can provide you with some related commands.
OnPCHitMe, http://en.uesp.net/morrow/editor/mw_csc ... #onpchitme
HasItemEquipped, http://en.uesp.net/morrow/editor/mw_csc ... emequipped
Cast, http://en.uesp.net/morrow/editor/mw_csc ... shtml#cast
GetTarget, http://en.uesp.net/morrow/editor/mw_csc ... #gettarget

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests