Jump to content

If you store a Faction as a ref can you then kill a member of that faction by scripting kill rFactionMember in a script?


PlatinumShad0w

Recommended Posts

As part of a mod I'm working on, I'm attempting to make functional working bomb collars that you can reverse pickpocket onto a target, forcing them to equip it and adding them to a custom Bomb Collar faction. That part is scripted in an object script attached to the collar item and is working.

 

I have written the following Object script attached to a custom "Control Detonator". I was hoping by using a custom faction as a reference, I could attach bomb collars to multiple NPCs in a cell and then, by firing the detonator, start a timer ending with them all blowing up. I set the parameters for the kill function to blame the player, pop their head and assign their cause of death to explosion. The trouble is that it's placing the explosion on the player instead of the stored reference faction member and I'm not sure why. Is there some limitation preventing what I'm trying to do? Some way I could write my script better or smoother way to implement this concept at all? Any help would be hugely appreciated.

scn PSBombCollarRemoteDetonationScript

short bEquipped
ref rVictim
float fCountdown
short bArmed

begin OnUnequip player

	set bEquipped to 0

end

begin OnEquip player

	set bEquipped to 1

end

begin OnFire player
	set rVictim to PSCollaredLackeyFaction
	set bArmed to 1
	rVictim.PlaySound NVDLC01CollarTestBeep
	set fCountdown to 5
end

begin Gamemode

	if fCountdown > 0  && bArmed == 1
		set fCountdown to fCountdown - GetSecondsPassed
	endif

	if fCountdown <= 0 && bArmed == 1
		rVictim.PlaySound NVDLC01BombCollarDeathBeep
		rVictim.Placeatme NVDLC01BombCollarExplosion
		rVictim.killactor player 1 0
		set bArmed to 0
	endif

end

Link to comment
Share on other sites

 

You can't Playsound. PlaceAtMe, or do a Killactor on a faction. You would need to do those on a persistent ref (like a persistent NPC) in the world.

 

Damn. Got it. I don't think that was mentioned on the GECK wiki but it's been my experience so far. I experimented with another idea though where, OnEquip, the collar SetPlayerTeammate to 1 and then the Detonator stores GetPlayerTeammate as a ref to then Playsound, Placeatme, SetPlayerTeammate 0 and Kill. But that hasn't been working either so far (though it may be my script). Is that not possible either?

 

 

 

scn PSBombCollarRemoteDetonationScript

short bEquipped
ref rVictim
float fCountdown
int bArmed

begin OnUnequip player

	set bEquipped to 0

end

begin OnEquip player

	set bEquipped to 1

end

begin OnFire player
	if	bArmed == 0
		set rVictim to GetPlayerTeammate
		rVictim.PlaySound NVDLC01CollarTestBeep
		set fCountdown to 5
		set bArmed to 1
	endif
end

begin GameMode

	if fCountdown > 1 && bArmed == 1 && rVictim.GetEquipped PSArmorExplosiveCollar == 1
		set fCountdown to fCountdown - GetSecondsPassed
	endif

	if rVictim.GetIsCreature == 0
	elseif rVictim.GetEquipped AnimationRestrictedArmors
			rVictim.PlayIdle PanicGrenadePlantPA
		else
			rVictim.PlayIdle PanicGrenadePlant
	endif

	if fCountdown <= 0 && bArmed == 1
	
		rVictim.PlaySound NVDLC01BombCollarDeathBeep
		rVictim.SetPlayerTeammate 0
		rVictim.Placeatme NVDLC01BombCollarExplosion
		rVictim.kill player 1 0
		set bArmed to 2
	endif

end

 

 

 

Any other ideas for how to implement such a thing? I can't use specific Persistent REFs because it could be any NPC that the player collars. Or is there a way to dynamically get the REF of an NPC who is wearing the collar and then call that REF to implement the effects?

Link to comment
Share on other sites

Step 1 - explain in explicit detail what you are trying to do here. Then we can determine how to solve it.

 

  1. You want the player to be able to reverse pickpocket the collar on any NPC? Certain quest or faction related NPCs? Can we add a script to those NPCs in the GECK, or must we possibley give them a script at runtime, or you may need a quest script to better coordinate the sequence of events. Object scripts can set variables in quest scripts to trigger things.
  2. The NPC will then equip the collar. What is controlling this? Show that script.
  3. You fire some detonator at the NPC, and it causes the NPC to play certain idles, and then after 5 seconds blow up and kill the NPC. Implies we need a script on that weapon too.
Edited by GamerRick
Link to comment
Share on other sites

 

  1. You want the player to be able to reverse pickpocket the collar on any NPC? Certain quest or faction related NPCs? Can we add a script to those NPCs in the GECK, or must we possibley give them a script at runtime, or you may need a quest script to better coordinate the sequence of events. Object scripts can set variables in quest scripts to trigger things.
  2. The NPC will then equip the collar. What is controlling this? Show that script.
  3. You fire some detonator at the NPC, and it causes the NPC to play certain idles, and then after 5 seconds blow up and kill the NPC. Implies we need a script on that weapon too.

 

Of course. All reasonable. Thank you for taking the time to help me. Explicitly, what I am trying to do is

1) enable to the player to take a crafted bomb collar, reverse pickpocket it on to an NPC, have the NPC equip the collar and thus be added to PlayerTeammate status

2) be able to use a custom Detonator to trigger a beep, possibly followed by an idle Panic animation (I intend for the NPC to possibly go hostile after this using SendAssaultAlarm)

3) a timer countdown follows culminating in one last death beep, at which point the NPC is removed from PlayerTeammateStatus and placeatme puts a Dead Money collar explosion on their location, followed by killactor where the head explodes, set to the player's responsibility with cause of death set to explosion.

 

1. Yes any NPC. They can attack and kill any NPC after all.

 

2. I have an Object script attached to the collar which currently works like this:

 

 

scn ExplosiveCollarEquipScript

Ref rVictim			;the target stored as a reference

Begin OnAdd

		set rVictim to GetContainer

		If (rVictim.IsActor == 1) && (rVictim.GetIsCreature == 0) && (rVictim.GetIsReference Player == 0)
			rVictim.EquipItem PSArmorExplosiveCollar
		endif

End

Begin Gamemode

	If (rVictim.GetEquipped PSArmorExplosiveCollar == 1) && (rVictim.GetIsReference Player == 0)
		rVictim.SetPlayerTeammate 1
	Endif

End

Begin OnDrop

	If (rVictim.GetItemCount PSArmorExplosiveCollar <= 0)
		rVictim.SetPlayerTeammate 0
	Endif

End

 

 

 

3. The script I posted to this thread is, in fact, an Object script which is already attached to the custom Detonator weapon. It successfully plays the beep but then causes me to explode rather than the rVictim ref player teammate. There may be something wrong with my timer as well. I have found trying to successfully implement timers to be extremely confusing despite repeated references to tutorials and example scripts on the Geck wiki.

Link to comment
Share on other sites

Alright this one is a mess but I did more research and found out only a handful of functions are compatible with reference variables. The most useful one I could think of to test for my purposes was GetCombatTarget. So I changed the script to an Effect Script and linked it to a base effect with an object effect parent on the Detonator. I commented out most of the stuff in my script regarding the timer and setting/removing player teammate status just to see if I could get the explosion and kill to function AND IT WORKED.

 

Now if some kind soul could just give me some pointers for how to use an array_var for this so I can use GetCombatTargets and detonate all the collar-wearing NPCs simultaneously, that would be awesome.

 

 

 

scn PSBombCollarRemoteDetonationScript

;finally working--don't f*** it up!

short bEquipped
ref rVictim
float fCountdown
int bArmed

;begin OnEquip player

	;set bEquipped to 1
;end


;begin OnUnequip player

	;set bEquipped to 0
;end

begin OnFire player

PlaySound NVDLC01CollarTestBeep
	if	bArmed == 0
		set rVictim to Player.GetCombatTarget
		;rVictim.SetPlayerTeammate 0
			if rVictim.GetEquipped PSArmorExplosiveCollar == 1
				player.SendAssaultAlarm rVictim
				;rVictim.PlaySound NVDLC01CollarTestBeep
				;set fCountdown to 5
				set bArmed to 1
			endif
	endif
;end

;begin ScriptEffectStart

if rVictim.GetEquipped PSArmorExplosiveCollar == 1
	;if fCountdown > 1 && bArmed == 1 && rVictim.GetEquipped PSArmorExplosiveCollar == 1
		;set fCountdown to fCountdown - GetSecondsPassed
	;endif

	if rVictim.GetIsCreature == 0
	elseif rVictim.GetEquipped AnimationRestrictedArmors
			rVictim.PlayIdle PanicGrenadePlantPA
		else
			rVictim.PlayIdle PanicGrenadePlant
	endif

	;if fCountdown <= 0 && bArmed == 1
	if bArmed == 1
	
		rVictim.PlaySound NVDLC01BombCollarDeathBeep
		rVictim.Placeatme NVDLC01BombCollarExplosion
		rVictim.kill player 1 0
		set bArmed to 2
	endif
endif

end

 

 

Link to comment
Share on other sites

I want to help. I am just busy with other things at the moment.

 

For starters: OnFire is a block-type for a script put on a weapon.

 

  • My general thinking is that the weapon uses its OnFire block to trigger the action. It will set a flag in a quest script..
  • The collar will tell the quest script the ref of the NPC that is equipping it. If you want this to apply to all NPCs that have a collar on at that time, or just one of them. you need to figure out how to do that.
  • The quest script will have a GameMode that waits for the flag to be set that the weapon was fired, and will then do the idle/sound/kill thing.

Meanwhile, you should study more tutorials on scripting, and read the description for the various blocktypes and functions available.

 

Rick

Edited by GamerRick
Link to comment
Share on other sites

  • Recently Browsing   0 members

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