Jump to content

Activator script won't activate twice?


Sweet6Shooter

Recommended Posts

This script is attached to an activator, and set to object. It's attached to a T Virus sample case, and it's supposed to play a slow animation of the dials turning, play a sound that matches the length of the animation, and spawn a pseudo-randomized set of enemies to attack the player. When it's activated the second time, it's supposed to add a misc item to the player's inventory, play the reverse animation, and the accompanying sound.

However, it just abjectly fails to do anything after the first activation.

 

Script:

scn sDMSCPTTVirusCase

short state
short sRandCr
short sRandVar
ref sPlacedObj
ref sPlacedObj2
ref sPlacedObj3
int sVar

short sCreaType ;1 scorpion, 2 cazador, 3 ant, 4 stalker, 5 centaur, 6 yao, 7 Dclaw, 8 Gecko


begin onActivate
printc "activated"
	if (IsActionRef player)
	activate
		if state == 1
		printc "state:%g" state
			if (isSoundPlaying sDMSNDTVirusCaseOp) == 0
				printc "state 1, sound playing, no update"
				set state to 0
				printc "state set to 0"
				playgroup backward 0
				playsound sDMSNDTVirusCaseCl
				printc "sound played"
				player.additem sDMMiscBioCatalyst 1
				printc "bio c added"
			endif
		endif
		if state == 0
		printc "state:%g" state
			if (isSoundPlaying sDMSNDTVirusCaseCl) == 0
				printc "state 0, sound playing, no update"
				playgroup forward 1
				playsound sDMSNDTVirusCaseOp
				printc "sound played"
				player.damageAV RadiationRads 20
				playsound UIPipBoyRadiationB
				printc "effects done"
				set sCreaType to 0
				set sVar to 0
				set sRandCr to GetRandomPercent
				set sRandVar to GetRandomPercent


				if sRandCr < 25
					set sCreaType to 1    ;radscorpion
				elseif sRandCr > 24 && sRandCr < 51
					set sCreaType to 2    ;yao
				elseif sRandCr > 50 && sRandCr < 75
					set sCreaType to 3    ;Dclaw
				elseif sRandCr > 74 && sRandCr < 100
					set sCreaType to 4   ;gecko
				endif

				if sRandVar < 50
					set sVar to 1
				elseif sRandVar < 100 && sRandVar > 49
					set sVar to 2
				endif

				if sCreaType == 1
					if sVar == 1
						set sPlacedObj to CrRadscorpion1Small
						set sPlacedObj2 to CrRadscorpion2Large
						set sPlacedObj3 to CrBarkScorpion
						sDMRefBioAmbClose.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb3.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar2.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					elseif sVar == 2
						set sPlacedObj to CrRadscorpion1Small
						set sPlacedObj2 to CrRadscorpion2Large
						set sPlacedObj3 to CrRadscorpion2Large
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb4.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					endif
				elseif sCreaType == 2
					if sVar == 1
						set sPlacedObj to NVDLC02CrTier5YaoGuaiLarge
						set sPlacedObj2 to NVDLC02CrTier4YaoGuaiMed
						set sPlacedObj3 to NVDLC02CrTier3YaoGuaiSmall
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb4.placeatme sPlacedObj3
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					elseif sVar == 2
						set sPlacedObj to NVDLC02CrTier4YaoGuaiMed
						set sPlacedObj2 to NVDLC02CrTier5YaoGuaiLarge
						set sPlacedObj3 to NVDLC02CrTier5YaoGuaiLarge
						sDMRefBioAmbClose.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb2.placeatme sPlacedObj2
						sPlacedObj3.MarkForDelete
						sDMRefBioAmbFar3.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					endif
				elseif sCreaType == 3
					if sVar == 1
						set sPlacedObj to CrDeathClawBaby
						set sPlacedObj2 to VSpawnSpecialTier4DeathclawMedWB
						set sPlacedObj3 to CrDeathClaw
						sDMRefBioAmbClose2.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb4.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar2.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					elseif sVar == 2
						set sPlacedObj to CrDeathClawBaby
						set sPlacedObj2 to CrDeathClaw
						set sPlacedObj3 to VSpawnSpecialTier4DeathclawMedWB
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb4.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					endif
				elseif sCreaType == 4
					if sVar == 1
						set sPlacedObj to NvCrFireGecko
						set sPlacedObj2 to NVCrGecko
						set sPlacedObj3 to NvCrFireGecko
						sDMRefBioAmbClose.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					elseif sVar == 2
						set sPlacedObj to NVCrGoldenGecko
						set sPlacedObj2 to NvCrFireGecko
						set sPlacedObj3 to NVCrGoldenGecko
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sPlacedObj.MarkForDelete
						sDMRefBioAmb4.placeatme sPlacedObj2
						sPlacedObj2.MarkForDelete
						sDMRefBioAmbFar2.placeatme sPlacedObj3
						sPlacedObj3.MarkForDelete
					endif
				endif
				printc "creatures placed"
				set state to 1
				printc "state set to 1"
			endif
		endif
	endif
end

The debug prints all fire off perfectly the first time:

activated

state:0

state 0, sound playing, no update

sound played

effects done

creatures placed

state set to 1

 

The animation and sounds play correctly, and the creatures are placed.

 

But then after the first activation, it doesn't even print the "activate" line, which means that the activation is just completely failing wholesale?

 

If anyone knows what the issue might be, please let me know. This script has given me a headache off and on this whole project, and before I tested it again this round, I had it working, so I don't know why it broke.

Link to comment
Share on other sites

if state == 1
  printc "state:%g" state
   if (isSoundPlaying sDMSNDTVirusCaseOp) == 0

The player has to activate it again, but not until after the sound stops, or it never happens...

 

I don't think that's a good idea unless you know for a fact that the player will do this (because they have to) even though they just got blasted by radiation and had a creature spawn near them. Theoretically, the player would need to kill the creature and then activate it again?

Edited by GamerRick
Link to comment
Share on other sites

It doesn't even print the first "activated" console line when the player activates it the second+ time, regardless of whether the sound/animation are playing or not.

The intended use is that the player opens the case, enemies spawn and they deal with them, then they can get the item that the case rewards them with when they close it, and they can reopen and close it and fight off enemies to get the reward item as many times as they want.

 

Now that I think about it, the MarkForDelete command might be causing weird behaviors when it's done to references that are alive. I'll try removing those lines later tonight and see what happens.

Link to comment
Share on other sites

The way you are using the MFD command is wrong. You only want to use it on a scripted object/npc, after you disable it, to stop the game from running its attached script PERMANENTLY. You are doing the MFD on base objects. You can't do that.

 

I don't see your script doing this (MFD) on itself. So, I don't know why the second activation won't run. Having it depend on the sound not playing might be the problem (IDK). But maybe code for that situation, so you and those that play the mod have a clue why it doesn't respond when you/they activate it again.

 

I cleaned it up and fixed some things. Try this:

scn sDMSCPTTVirusCase
short state
short sRandCr
short sRandVar
ref sPlacedObj
ref sPlacedObj2
ref sPlacedObj3
int sVar
short sCreaType ;1 scorpion, 2 cazador, 3 ant, 4 stalker, 5 centaur, 6 yao, 7 Dclaw, 8 Gecko

begin onActivate
printc "activated"
if (IsActionRef player)
  activate
    if state == 1
     printc "state:%g" state
      if (isSoundPlaying sDMSNDTVirusCaseCl) == 1
    ShowMessage "Your new message that the sound is playing"
    return
   else
       printc "state 1, sound NOT playing, no update"
       set state to 0
       printc "state set to 0"
       playgroup backward 0
       playsound sDMSNDTVirusCaseCl
       printc "sound played"
       player.additem sDMMiscBioCatalyst 1
       printc "bio c added"
      endif
    endif

    if state == 0
     printc "state:%g" state
      if (isSoundPlaying sDMSNDTVirusCaseCl) == 1
    ShowMessage "Your new message that the sound is playing"
    return
   else
       printc "state 0, sound NOT playing, no update"
      playgroup forward 1
       playsound sDMSNDTVirusCaseOp
       printc "sound played"
       player.damageAV RadiationRads 20
        playsound UIPipBoyRadiationB
      printc "effects done"
        set sCreaType to 0
       set sVar to 0
       set sRandCr to GetRandomPercent
       set sRandVar to GetRandomPercent

       if sRandCr < 25
         set sCreaType to 1    ;radscorpion
       elseif sRandCr < 51
         set sCreaType to 2    ;yao
       elseif sRandCr < 75
         set sCreaType to 3    ;Dclaw
       else
         set sCreaType to 4   ;gecko
       endif

       if sRandVar < 50
         set sVar to 1
       else
         set sVar to 2
       endif

       if sCreaType == 1
         if sVar == 1
          set sPlacedObj to CrRadscorpion1Small
           set sPlacedObj2 to CrRadscorpion2Large
           set sPlacedObj3 to CrBarkScorpion
         else
           set sPlacedObj to CrRadscorpion1Small
           set sPlacedObj2 to CrRadscorpion2Large
           set sPlacedObj3 to CrRadscorpion2Large
          endif

       elseif sCreaType == 2
          if sVar == 1
           set sPlacedObj to NVDLC02CrTier5YaoGuaiLarge
           set sPlacedObj2 to NVDLC02CrTier4YaoGuaiMed
           set sPlacedObj3 to NVDLC02CrTier3YaoGuaiSmall
        else
           set sPlacedObj to NVDLC02CrTier4YaoGuaiMed
           set sPlacedObj2 to NVDLC02CrTier5YaoGuaiLarge
           set sPlacedObj3 to NVDLC02CrTier5YaoGuaiLarge
         endif

       elseif sCreaType == 3
         if sVar == 1
           set sPlacedObj to CrDeathClawBaby
           set sPlacedObj2 to VSpawnSpecialTier4DeathclawMedWB
           set sPlacedObj3 to CrDeathClaw
           else
           set sPlacedObj to CrDeathClawBaby
           set sPlacedObj2 to CrDeathClaw
           set sPlacedObj3 to VSpawnSpecialTier4DeathclawMedWB
              endif
       else
         if sVar == 1
           set sPlacedObj to NvCrFireGecko
           set sPlacedObj2 to NVCrGecko
           set sPlacedObj3 to NvCrFireGecko
     else
           set sPlacedObj to NVCrGoldenGecko
          set sPlacedObj2 to NvCrFireGecko
           set sPlacedObj3 to NVCrGoldenGecko
         endif
       endif

    sDMRefBioAmbClose3.placeatme sPlacedObj
         sDMRefBioAmb4.placeatme sPlacedObj2
         sDMRefBioAmbFar2.placeatme sPlacedObj3
            printc "creatures placed"

        set state to 1
       printc "state set to 1"
      endif
    endif
endif
end
Edited by GamerRick
Link to comment
Share on other sites

Yeah, I'm not too surprised I was using MFD incorrectly.

 

The problem is that it doesn't even print "activated" when activated the second time, which is the very first line, before any sound checks.

Also, each of those placeatme's is hand chosen relative to the creature choices, they're not all the same set of marker placements. They can't be genericized and put below the creature choices. Each state change is also checking for a different sound, not the same one. In addition, each internal creature Var check decides between two marker placement configurations.

 

Removing the mfd lines didn't change the situation at all :/

Link to comment
Share on other sites

Looks like I got it working!

I think my issue was that I didn't set up a placement originally for the radscorpion second configuration, I accidentally copy pasted some mfd lines, so when I removed the mfd lines it didn't fix it right away. Here's the working version:

scn sDMSCPTTVirusCase

short state
short sRandCr
short sRandVar
ref sPlacedObj
ref sPlacedObj2
ref sPlacedObj3
int sVar

short sCreaType ;1 scorpion, 2 cazador, 3 ant, 4 stalker, 5 centaur, 6 yao, 7 Dclaw, 8 Gecko


begin onActivate
printc "activated"
	if (IsActionRef player)
		if state == 1
		printc "state:%g" state
			if (isSoundPlaying sDMSNDTVirusCaseOp == 0) && (isSoundPlaying sDMSNDTVirusCaseOp == 0)
				set state to 0
				printc "state set to 0"
				playgroup backward 0
				playsound sDMSNDTVirusCaseCl
				printc "sound played"
				player.additem sDMMiscBioCatalyst 1
				printc "bio c added"
			endif
		elseif state == 0
		printc "state:%g" state
			if (isSoundPlaying sDMSNDTVirusCaseCl == 0) && (isSoundPlaying sDMSNDTVirusCaseOp == 0)
				playgroup forward 1
				playsound sDMSNDTVirusCaseOp
				printc "sound played"
				player.damageAV RadiationRads 20
				playsound UIPipBoyRadiationB
				printc "effects done"
				set sCreaType to 0
				set sVar to 0
				set sRandCr to GetRandomPercent
				set sRandVar to GetRandomPercent


				if sRandCr < 25
					set sCreaType to 1    ;radscorpion
				elseif sRandCr > 24 && sRandCr < 51
					set sCreaType to 2    ;yao
				elseif sRandCr > 50 && sRandCr < 75
					set sCreaType to 3    ;Dclaw
				elseif sRandCr > 74 && sRandCr < 100
					set sCreaType to 4   ;gecko
				endif

				if sRandVar < 50
					set sVar to 1
				elseif sRandVar < 100 && sRandVar > 49
					set sVar to 2
				endif

				if sCreaType == 1
					if sVar == 1
						set sPlacedObj to CrRadscorpion1Small
						set sPlacedObj2 to CrRadscorpion2Large
						set sPlacedObj3 to CrBarkScorpion
						sDMRefBioAmbClose.placeatme sPlacedObj
						sDMRefBioAmb3.placeatme sPlacedObj2
						sDMRefBioAmbFar2.placeatme sPlacedObj3
					elseif sVar == 2
						set sPlacedObj to CrRadscorpion1Small
						set sPlacedObj2 to CrRadscorpion2Large
						set sPlacedObj3 to CrRadscorpion2Large
						sDMRefBioAmbClose2.placeatme sPlacedObj
						sDMRefBioAmb.placeatme sPlacedObj2
						sDMRefBioAmbFar2.placeatme sPlacedObj3
					endif
				elseif sCreaType == 2
					if sVar == 1
						set sPlacedObj to NVDLC02CrTier5YaoGuaiLarge
						set sPlacedObj2 to NVDLC02CrTier4YaoGuaiMed
						set sPlacedObj3 to NVDLC02CrTier3YaoGuaiSmall
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sDMRefBioAmb4.placeatme sPlacedObj3
						sDMRefBioAmbFar.placeatme sPlacedObj3
					elseif sVar == 2
						set sPlacedObj to NVDLC02CrTier4YaoGuaiMed
						set sPlacedObj2 to NVDLC02CrTier5YaoGuaiLarge
						set sPlacedObj3 to NVDLC02CrTier5YaoGuaiLarge
						sDMRefBioAmbClose.placeatme sPlacedObj
						sDMRefBioAmb2.placeatme sPlacedObj2
						sDMRefBioAmbFar3.placeatme sPlacedObj3
					endif
				elseif sCreaType == 3
					if sVar == 1
						set sPlacedObj to CrDeathClawBaby
						set sPlacedObj2 to VSpawnSpecialTier4DeathclawMedWB
						set sPlacedObj3 to CrDeathClaw
						sDMRefBioAmbClose2.placeatme sPlacedObj
						sDMRefBioAmb4.placeatme sPlacedObj2
						sDMRefBioAmbFar2.placeatme sPlacedObj3
					elseif sVar == 2
						set sPlacedObj to CrDeathClawBaby
						set sPlacedObj2 to CrDeathClaw
						set sPlacedObj3 to VSpawnSpecialTier4DeathclawMedWB
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sDMRefBioAmb4.placeatme sPlacedObj2
						sDMRefBioAmbFar.placeatme sPlacedObj3
					endif
				elseif sCreaType == 4
					if sVar == 1
						set sPlacedObj to NvCrFireGecko
						set sPlacedObj2 to NVCrGecko
						set sPlacedObj3 to NvCrFireGecko
						sDMRefBioAmbClose.placeatme sPlacedObj
						sDMRefBioAmb.placeatme sPlacedObj2
						sDMRefBioAmbFar.placeatme sPlacedObj3
					elseif sVar == 2
						set sPlacedObj to NVCrGoldenGecko
						set sPlacedObj2 to NvCrFireGecko
						set sPlacedObj3 to NVCrGoldenGecko
						sDMRefBioAmbClose3.placeatme sPlacedObj
						sDMRefBioAmb4.placeatme sPlacedObj2
						sDMRefBioAmbFar2.placeatme sPlacedObj3
					endif
				endif


				printc "creatures placed"
				set state to 1
				printc "state set to 1"
			endif
		endif
	endif
end 
Link to comment
Share on other sites

  • Recently Browsing   0 members

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