Jump to content

Assign all the hurt from an explosion as the players fault


mindboggles

Recommended Posts

I've got to the stage where one of my mods is nearly finished but I've got a little problem in that the explosions placed via script need to attribute the damage, kill, hate, xp, etc. to the player. I'm assuming I need an effect for the explosion but I'm drawing a mental blank on how to achieve this.

 

 

Edit...Just wondering if I spawn my own version of a mine set to explode straight away and assign ownership of it to the player would that work?

Edited by mindboggles
Link to comment
Share on other sites

I've still got problems with this, the assigning ownership of the spawned mine didn't work so I've gone with a dummy object spawned from the explosion to do a Ref Walk. I can award XP and Karma but trying to get the NPC's to hate on the player is proving difficult.

 


Scn FMBBlamePlayerScript

Ref rActor
Int MyLevel
Int MyIndexSize
array_var MyFactions
Int MyIndex
Ref rAFaction
Ref rMe

Begin OnLoad

		Set rMe to GetSelf
		If rMe.IsInInterior == 1
			Set rActor to GetFirstRef 200 
		Else
			Set rActor to GetFirstRef 200 1
		EndIf

		While rActor != 0

			If rActor.GetBaseForm != CrFlyingMineRobot
				If rActor.GetDead && rActor.GetCauseofDeath == 0 && rActor.IsKiller Player != 1

					; Do all the checking on the actor for the effect get xp blame player etc

					Set MyLevel to rActor.GetLevel
					Let MyFactions := Ar_Construct "array"
					Let MyFactions := rActor.GetActiveFactions
					Let MyIndexSize := ar_Size MyFactions
;					Ar_Dump MyFactions
					Let MyIndex := -1
					While (MyIndex += 1) < MyIndexSize
						Let rAFaction := MyFactions[MyIndex]
;						Print "Faction - " + $rAFaction
						SendAssaultAlarm rAFaction

						If rAFaction == BoomerFaction
							AddReputation repnvboomer 0 12
						ElseIf rAFaction == BrotherhoodSteelFaction
							AddReputation RepNVBrotherhood 0 12
						ElseIf rAFaction == VCaesarsLegionFaction
							AddReputation RepNVCaesarsLegion 0 12
						ElseIf rAFaction == FollowersoftheApocalypseFaction
							AddReputation RepNVFollowers 0 12
						ElseIf rAFaction == FreesideLocalFaction || KingsFaction
							AddReputation RepNVFreeside 0 12
						ElseIf rAFaction == GoodspringsFaction
							AddReputation RepNVGoodsprings 0 12 
						ElseIf rAFaction == GreatKhansFactionNV
							AddReputation RepNVGreatKhans 0 12
						ElseIf rAFaction == NCRFactionNV
							AddReputation RepNVNCR 0 12
						ElseIf rAFaction == NovacGenericTownie
							AddReputation RepNVNovac 0 12
						ElseIf rAFaction == PowderGangerFactionNV
							AddReputation RepNVPowderGanger 0 12
						ElseIf rAFaction == PrimmResidentsFaction
							AddReputation RepNVPrimm 0 12
;						ElseIf rAFaction == 
;							AddReputation RepNVTheStrip 0 12
						ElseIf rAFaction == VWhiteGloveSocietyFaction
							AddReputation RepNVWhiteGloveSociety 0 12
						EndIf

					Loop

					If rActor.GetIsCreature != 1
						If MyLevel == 0
							;
						ElseIf MyLevel >= 1 && MyLevel < 7
							RewardXP 10
						ElseIf MyLevel >= 7 && MyLevel < 10
							RewardXP 20
						ElseIf MyLevel >= 10 && MyLevel < 13
							RewardXP 30
						ElseIf MyLevel >= 13
							RewardXP 50
						EndIf

					Else

						If rActor.IsActorEvil == 1
							RewardKarma 25
						Else
							RewardKarma -25
						EndIf

						If MyLevel < 3
							RewardXP 1
						ElseIf MyLevel >= 3 && MyLevel < 6
							RewardXP 5
						ElseIf MyLevel >= 6 && MyLevel < 9
							RewardXP 10
						ElseIf MyLevel >= 9 && MyLevel < 12
							RewardXP 25
						ElseIf MyLevel >= 12
							RewardXP 50
						EndIf

					EndIf

				rActor.Kill Player
				EndIf
			EndIf
			Set rActor to GetNextRef
		Loop

	Disable
	MarkForDelete

Is there a simpler way to go about this?
Link to comment
Share on other sites

In my Enclave commander mod I put an object effect of type 'script' on the explosions to give blame to the player. The script runs on every actor in range of the explosion so you don't need a ref walk or looping. Just put what you need in a ScriptEffectStart block. The block runs exactly one frame. You may want to try to avoid using GetSelf unless you know the actor is placed in the world by the Geck. Actors placed in the world by leveled lists or placeatme return 0 always with that function. But since the script is running on the actor, the functions are implicit to the actor and you don't need their REF.

Link to comment
Share on other sites

Thanks I'll give that a try, you don't be any chance happen to know if I'm going the right way with the AddReputation? I'm not sure what the amount of rep would be equivalent to for killing someone.

Afraid I don't know much about reputation mechanics - never used them. I think the value you would have to use depends on the value given to the reputation object for that faction. For example the value for NCR is 80 and the value for Novac is 20. I *think* that means Novac reputation is four times easier to sway one way or the other than the NCR reputation.

Link to comment
Share on other sites

Interesting removing that extra step has made the NPC's react to the player even though the explosion is deliver via a third party, I'm still not getting the vilified response to come up but I'll look into how the faction armour works and see if that helps. Reputation mechanics is sorely under documented.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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