Killing A Target

Post » Wed Oct 13, 2010 3:54 pm

I want to make an Effect Script for a weapon so whenever a critical hit is landed, the target will die. I tried using KillActor, but I don't know what to pu in the ActorID to make it that the target will die. Help please?
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Wed Oct 13, 2010 4:13 pm

Why not just up the criticle damage to 2000. That will kill any actor in the game short of liberty prime on a criticle hit.
User avatar
Philip Lyon
 
Posts: 3297
Joined: Tue Aug 14, 2007 6:08 am

Post » Wed Oct 13, 2010 10:23 am

I want to make an Effect Script for a weapon so whenever a critical hit is landed, the target will die. I tried using KillActor, but I don't know what to pu in the ActorID to make it that the target will die. Help please?


This should be easy. Examine the Behemoth fire hydrant effect script for an example of how to pull your target's ref and perform conditional actions upon it.
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Wed Oct 13, 2010 8:16 am

That script uses http://geck.gamesas.com/index.php/GetSelf, which is only ever useful when passing the scripted reference's refID as a parameter to a function, or passing this information to another script. When you take into account the fact that http://geck.gamesas.com/index.php/GetSelf will return 0 if called on a reference that exists within the save (i.e. has a formID starting with "FF") http://geck.gamesas.com/index.php/GetSelf will return 0, it should be avoided wherever possible.

In this case, because the critical effect script will run directly on the target, you can simply call http://geck.gamesas.com/index.php/KillActor implicitly:
Begin ScriptEffectStart	KillActorEnd

Cipscis
User avatar
GEo LIme
 
Posts: 3304
Joined: Wed Oct 03, 2007 7:18 pm

Post » Wed Oct 13, 2010 11:30 am

That script uses GetSelf, which is only ever useful when passing the scripted reference's refID as a parameter to a function, or passing this information to another script. When you take into account the fact that GetSelf will return 0 if called on a reference that exists within the save (i.e. has a formID starting with "FF") GetSelf will return 0, it should be avoided wherever possible.

In this case, because the critical effect script will run directly on the target, you can simply call KillActor implicitly:
Begin ScriptEffectStart	KillActorEnd

Cipscis

That simple? Thanks!
User avatar
Annika Marziniak
 
Posts: 3416
Joined: Wed Apr 18, 2007 6:22 am

Post » Wed Oct 13, 2010 1:16 pm

One thing that you should be aware of with this approach, however, is that kills won't register as the player's. If you want to specify a killer, then you can use one of several (flawed) methods of finding the killer, but to be honest it'd be easier just to use pkleiss' approach, which would work without this limitation.

The easiest way to "find" the killer would be to hard-code it as the player, but this would only work properly if only the player can use the weapon:
Begin ScriptEffectStart	KillActor playerEnd

Another method is to use FOSE's reference walking and looping functions to find a likely killer, but it's a lot of hassle compared to pkeliss' method so I won't go into details here unless you'd really like me to.

Cipscis
User avatar
Dean Ashcroft
 
Posts: 3566
Joined: Wed Jul 25, 2007 1:20 am

Post » Wed Oct 13, 2010 3:05 pm

I now realize that I have to use pkeliss' way, because I want to also knock the target away, and for some reason pushactoraway and KillActor conflict with each other (it's one or the other). Thanks anyway!
User avatar
Len swann
 
Posts: 3466
Joined: Mon Jun 18, 2007 5:02 pm

Post » Wed Oct 13, 2010 10:15 am

That script uses http://geck.gamesas.com/index.php/GetSelf, which is only ever useful when passing the scripted reference's refID as a parameter to a function, or passing this information to another script. When you take into account the fact that http://geck.gamesas.com/index.php/GetSelf will return 0 if called on a reference that exists within the save (i.e. has a formID starting with "FF") http://geck.gamesas.com/index.php/GetSelf will return 0, it should be avoided wherever possible.

In this case, because the critical effect script will run directly on the target, you can simply call http://geck.gamesas.com/index.php/KillActor implicitly:
Begin ScriptEffectStart	KillActorEnd

Cipscis



Hey Cipscis,

This is code I have in Foes Reworked NG right now. It seems to work as you would expect but, after what you wrote above, I'm not sure now. Do you see anything here that seems off in terms of the getself usage? Do you think the process is failing if the mutant hits a spawner-generated npc/creature? I never noticed anything like that, but maybe...



scn PhalanxFoesSMBerserkerUnarmedSCRIPTref	TargetBEGIN ScriptEffectStartset PhalanxFoesReworkedMisc.BerserkerHitCount to PhalanxFoesReworkedMisc.BerserkerHitCount + 1if PhalanxFoesReworkedMisc.BerserkerHitCount > 2	set PhalanxFoesReworkedMisc.BerserkerHitCount to 0	set Target to GetSelf	if target == player		target.addscriptpackage PhalanxFoesReworkedPlayerFallDown		set PhalanxFoesReworkedMisc.PlayerFallDown to 1		imod PhalanxFoesReworkedMQ08FadeInFromWhiteISFX		playsound AMBRDunwichVoice	elseif target.getiscreaturetype 4 != 1		target.pushactoraway target -1		Target.scaonactor		target.stopcombat	endifendifEND

User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am

Post » Wed Oct 13, 2010 4:59 pm

In the testing that I did with HugePinball while he was working on http://www.fallout3nexus.com/downloads/file.php?id=11532, we found the http://geck.gamesas.com/index.php/GetSelf seems to always return 0 when called on a reference saved in the save game, such as one created via http://geck.gamesas.com/index.php/PlaceAtMe.

Taking this into account, I recognise surrounding code using the return value of http://geck.gamesas.com/index.php/GetSelf in a conditional block checking that it has returned a value, and (this is important) only using it when absolutely necessary. This includes always calling functions implicitly (i.e. "Function" instead of "ref.Function") when possible.

The code that you've used only needs to use the return value of http://geck.gamesas.com/index.php/GetSelf when calling http://geck.gamesas.com/index.php/PushActorAway, and you could probably achieve the same effect by damaging the actor's fatigue. Here's some code that uses http://geck.gamesas.com/index.php/PushActorAway if http://geck.gamesas.com/index.php/GetSelf works, and damages the actor's fatigue otherwise.:
ScriptName PhalanxFoesSMBerserkerUnarmedSCRIPTref rSelffloat fFatigueBegin ScriptEffectStart	set PhalanxFoesReworkedMisc.BerserkerHitCount to PhalanxFoesReworkedMisc.BerserkerHitCount + 1	if PhalanxFoesReworkedMisc.BerserkerHitCount > 2		set PhalanxFoesReworkedMisc.BerserkerHitCount to 0		if GetIsReference player ; This is more reliable than using "if GetSelf == player", and doesn't require use of GetSelf			AddScriptPackage PhalanxFoesReworkedPlayerFallDown			set PhalanxFoesReworkedMisc.PlayerFallDown to 1			ApplyImageSpaceModifier PhalanxFoesReworkedMQ08FadeInFromWhiteISFX			PlaySound AMBRDunwichVoice		elseif GetIsCreatureType 4 == 0			set rSelf to GetSelf			if rSelf				PushActorAway rSelf -1			else ; if rSelf == 0				set fFatigue to GetActorValue Fatigue				DamageActorValue Fatigue fFatigue			endif			StopCombatAlarmOnActor			StopCombat		endif	endifEnd

Cipscis
User avatar
Kieren Thomson
 
Posts: 3454
Joined: Sat Jul 21, 2007 3:28 am


Return to Fallout 3

cron