Scripts: Hitting Object via ArrowBolt

Post » Wed May 02, 2012 11:14 pm

My question is quite simple - is there any possibility to return true when arrow, bolt or anything other related to marksman skill hits specific object? For example, player aim (can be bow in that case) at a bell, fire and the bell rings. I've tried to pin a script with GetDistance for specific type of arrows but it doesn't work. Any ideas, mates?
User avatar
Thomas LEON
 
Posts: 3420
Joined: Mon Nov 26, 2007 8:01 am

Post » Wed May 02, 2012 2:00 pm

You could make the object you want to make "hittable" into a creature, or just place an invisible creature/NPC in front or on top of it. Then you can detect hits on the actor by using the variable OnPCHitMe.

If you'd like the hits to only perform a certain function when performed by a marksman weapon, you can combine the above technique with GetWeaponType which can determine what weapon type the player has equipped at any given time.
User avatar
Invasion's
 
Posts: 3546
Joined: Fri Aug 18, 2006 6:09 pm

Post » Wed May 02, 2012 8:54 pm

Yeah, I was thinking about this method, however, is there any way to get it around without making hittable creature?
User avatar
Myles
 
Posts: 3341
Joined: Sun Oct 21, 2007 12:52 pm

Post » Wed May 02, 2012 2:05 pm

Yeah, I was thinking about this method, however, is there any way to get it around without making hittable creature?

Hmm, maybe. It would most likely require some testing an tinkering though.

You could perhaps try using player->GetSoundPlaying with certain sounds to see when the player performs a weapon swish, a bow fire, or a crossbow fire sound. I think I did something similar at some point in the past and actually got it to work.

The harder part would be determining whether the player has the object in his crosshair or not. GetTarget should work for this purpose, but only as long as the object is actually in activation reach. But maybe, just maybe you could add a high magnitude one frame telekinesis effect (spell ability) to the player. If you make the object an item (e.g. a misc item instead of an activator), the telekinesis should make the object's name appear on screen for a frame even if it's far away, as long as you're looking in its way. At this point it should be possible to check whether or not the player was looking at the object using GetTarget.

There are a lot of ifs and maybes in this method, but if you manage to get it working that would be pretty cool.

Edit: Nevermind about GetTarget, it only works with actors. You can use the MWSE function xGetPCTarget instead.
User avatar
R.I.P
 
Posts: 3370
Joined: Sat Dec 01, 2007 8:11 pm

Post » Thu May 03, 2012 4:46 am

Desired object dont return true on gettarget for me, unfortunately. Now, I'm trying to make full-transparent creature (I've picked lorkhan's heart because of static model), but I don't have any idea how to hide it completely...
User avatar
Mackenzie
 
Posts: 3404
Joined: Tue Jan 23, 2007 9:18 pm

Post » Thu May 03, 2012 3:40 am

What about a paralyzed NPC of a race with no mesh assigned? They are usually used as collision "sonar" detectors, but should do for your needs too.
User avatar
Miguel
 
Posts: 3364
Joined: Sat Jul 14, 2007 9:32 am

Post » Wed May 02, 2012 3:39 pm

Desired object dont return true on gettarget for me, unfortunately. Now, I'm trying to make full-transparent creature (I've picked lorkhan's heart because of static model), but I don't have any idea how to hide it completely...
Yeah, sorry. Shortly after I wrote my post I've realized GetTarget only works between two actors for some reason. It cannot be used to check for the player targeting an item or container.

That said, I've since tried making something similar to my suggestion above using xGetPCTarget instead of GetTarget. It requires MWSE but it works. And there's no invisible creature or NPC involved.

What I did was add a barrel (container) to the Balmora Guild of Mages, and add this script to it:

Begin adul_test_lookatme_b_scrshort doOnceif ( MenuMode == 1 )	Returnendifif ( "player"->GetSoundPlaying, "Weapon Swish" == 1 )	if ( doOnce == 0 )		StartScript, "adul_test_lookatme_scr"		set doOnce to 1	endifelseif ( doOnce == 1 )	set doOnce to 0endifEnd
This script checks every frame whether the player is swishing his weapon, and if he does, it runs the global script "adul_test_lookatme_scr". Right now it does not work with bows or crossbows but making changes to it to allow that wouldn't be too hard. The adul_test_lookatme_scr script is as follows:

Begin adul_test_lookatme_scrshort doOnceshort stemplong pcreflong tempif ( MenuMode == 1 )	Returnendifif ( doOnce == 0 )	"player"->AddSpell, "adul_test_lookatme_sp"	set doOnce to 1	Returnendifsetx pcref to xGetRef, "player"xSetRef, pcrefset stemp to GetSpellEffects, "adul_test_lookatme_sp"if ( stemp == 0 )	Returnendifsetx temp to xGetPCTarget"player"->RemoveSpell, "adul_test_lookatme_sp"set doOnce to 0StopScript, "adul_test_lookatme_scr"if ( temp == 0 )	Returnendifsetx temp to temp->xGetBaseIDsetx temp to xStringCompare, temp, "adul_test_lookatme"if ( temp != 0 )	ReturnendifMessageBox, "Ouch!"End
The spell "adul_test_lookatme_sp" is a 1000 point telekinesis spell that has the ability checkbox checked. Every time you swing your weapon, the spell gets added to you for 1 frame, and if you're looking in the direction of the barrel, the barrel will say "Ouch!"
User avatar
emily grieve
 
Posts: 3408
Joined: Thu Jun 22, 2006 11:55 pm

Post » Wed May 02, 2012 6:35 pm

I work without external software, but I'll save that and test later. On the other hand I made a progress. I made creture, added invisible/paralyze ability and placed on invisio wall next to the bell. Now we can 'hit the bell', what is more, we have to look very deeply to discover mentioned creature. Due to limited distance to the bell (it's just beneath ceiling) it works fine.
User avatar
Rodney C
 
Posts: 3520
Joined: Sat Aug 18, 2007 12:54 am


Return to III - Morrowind