Jump to content

Boom Headshot Script


Holty07

Recommended Posts

Basically I want to make a script that plays one of three "boom headshot" sounds I have whenever the killed targets head explodes in a mist of blood.

 

The basic layout would something like this I'm guessing?

scn BoomHeadshot

Begin 
if  [something here]
	playSound BoomHeadshot1 OR playSound BoomHeadshot2 OR BoomHeadshot3
endif
End

 

If I'm going the totally wrong way please help me!

Link to comment
Share on other sites

It'll be much more complicated than that, I'm afraid. You'll want to use a scripted explosion to add a token (an unplayable, therefore invisible, piece of armour) to all nearby living actors so that you can check on each of them if they were killed by the player shooting them in the head.

 

To do this, you'll need to make use of the IsKiller function, as well as the GetHitLocation function, which only works on the frame in which the calling actor dies when called in a GameMode block.

 

In order to randomly select a sound to play, you'll need to use the GetRandomPercent function, as well as an "int" variable to store the result and a few conditional statements to select a sound depending on the result.

 

The script on the token will end up looking something like this:

ScriptName BoomHeadshotTokenScript

ref rContainer
int iRandomPercent
int iHeadshot

Begin OnAdd

set rContainer to GetContainer

; The next two lines prevent a bug in AddItem
AddItem Pencil01 1 1
RemoveItem Pencil01 1 1

End

Begin GameMode

if rContainer.GetHitLocation == 1
	set iHeadshot to 1
elseif iHeadshot
	if rContainer.IsKiller player
		set iRandomPercent to GetRandomPercent
		if iRandomPercent > 66
			PlaySound BoomHeadshot1
		elseif iRandomPercent > 33
			PlaySound BoomHeadshot2
		else
			PlaySound BoomHeadshot3
		endif
		RemoveMe
	endif
elseif rContainer.GetDead
	RemoveMe
endif

End

If you want the sound only to play when the head is destroyed, then you'll want to use IsLimbGone as well.

 

Cipscis

Link to comment
Share on other sites

Ok thanks a lot. I've changed it to add the IsLimbGone in. Is this the right place?

 

ScriptName BoomHeadshotTokenScript

ref rContainer
int iRandomPercent
int iHeadshot

Begin OnAdd

set rContainer to GetContainer

; The next two lines prevent a bug in AddItem
AddItem Pencil01 1 1
RemoveItem Pencil01 1 1

End

Begin GameMode

if rContainer.GetHitLocation == 1 && rContainer.IsLimbGone == 1
	set iHeadshot to 1
elseif iHeadshot
	if rContainer.IsKiller player
		set iRandomPercent to GetRandomPercent
		if iRandomPercent > 66
			PlaySound BoomHeadshot1
		elseif iRandomPercent > 33
			PlaySound BoomHeadshot2
		else
			PlaySound BoomHeadshot3
		endif
		RemoveMe
	endif
elseif rContainer.GetDead
	RemoveMe
endif

End

 

I make a script in GECK with that in it right?

 

Also something I have no idea about is do I attach this to something in GECK? If so what?

 

Thanks again. Helps to learn this way. I have a bit of experience with Java so it helps a little here.

Link to comment
Share on other sites

I'm not sure if IsLimbGone will work in the same frame as GetHitLocation, so just to be safe I'd put it in the condition that checks "rContainer.IsKiller player" instead.

 

You'll want to use "rContainer.IsLimbGone 1" instead of rContainer.IsLimbGone == 1" - the latter won't even compile. Here's what the GECK Wiki has to say about it - IsLimbGone

 

You'll need to create a "token" to attach this to. A token is a piece of armour with the "Playable" checkbox unticked, which means that it will be invisible if the player tries to view the inventory that it is in. To attach the script to it, you'll need to first make sure that your script is an "Object" script (select this in the "Script Type" drop-down menu in the "Script Edit" window), then select it in the "Script" drop-down menu in the "Armor" window.

 

Just creating the token isn't going to be enough - in order for it to work you're going to have to also created a scripted explosion in order to add the token to all nearby actors. This is a fairly complicated thing to do, so it might be difficult the first time. There is a thread on the official GECK forum that has a good guide to creating a scripted explosion - Global script for essential tagging. For a good example, you might look at Reneer's Shoot Em In The Head Mod.

 

Good luck!

 

Cipscis

Link to comment
Share on other sites

Quick question. If I attached this script to the underwear armor, would that attach it to everyone as they are all always wearing it? Or is the underwear only added after death?

 

EDIT: Couple of other things. Whats the difference between Head 1 and Head 2? Do we just use Head 1 only? Worked out some of this. However I am having trouble with the enchantment of the explosion. The explosion is enchanted with an enchantment call BoomCreateToken, how do I change the script effect of this enchantment? How do I select what script for it to run?

Link to comment
Share on other sites

The "underwear" that you see on NPCs isn't an item, it's actually part of their body, so you can't attach scripts to it.

 

Most BodyPartDatas only use Head1, I think only the Brahmin BodyPartData actually uses Head2. If you want to check for Head2 as well, then you'll probably want to have another variable to store the value of which head was hit in the killing blow, so that you can check if that head specifically was destroyed.

 

The explosion uses an object effect, which uses a base effect. The base effect should have "Script" set as its "Effect Archetype", which will allow you to select a script for it to use in the "Assoc. Item" drop-down menu.

 

Cipscis

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...