Sign in to follow this  
Followers 0
DsoS

Script checkover with a question

30 posts in this topic

Okay, so I'm working on another script. I've got most of it finished but not sure how to set a part of it up.



SCN aaDSoSFNSCryptCoffin01Script


Short BeenOpened

float timer


Begin OnActivate Player


	if BeenOpened == 0 ;This will enable zombies and the MessageBox

		set timer to 5

		MessageBox "We warned you what would happen if you try to loot this place!"

		cast aaDSoSFNSCryptCoffinSpell player

		aaDSoSFNSZombieEnableREF.Enable

		set BeenOpened to 1


	Elseif BeenOpened == 1

		set timer to 5

		MessageBox "Debug: Zombies have spawned, tombs should not display old messagebox or zombies enabled a second time"

		cast aaDSoSFNSCryptCoffinSpell player

		set BeenOpened to 2


	Endif	


End


Begin GameMode

	if BeenOpened == 2

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: Timer has been reset"

			set BeenOpened to 1

		endif

	endif

End


Begin onReset

	set BeenOpened to 0

	aaDSoSFNSZombieEnableREF.Disable

End


I know that I have the OnActivate Black done properly, but I'm not sure how to setup the Timers in the GameMode Block with two separate timers.

How would I set up a dual timer like this?

What I need to happen is:

Player activates a certain item, the zombies spawn and then the timer finishes up and allows BeenOpened == 1 Block to continue.... After the initial activation I want only the second BeenOpened block to work, so players are not bombarded by MessageBoxes if they try to activate more items and the ZombieREF isn't activated/Enabled again.

0

Share this post


Link to post
Share on other sites

It looks like you've got it for the most part, but you've only got the timer counting down if BeenOpened is equal to 2. You need to have that as a separate IF statement in the GameMode block, then check both your Timer and Counter to choose an action.


SCN aaDSoSFNSCryptCoffin01Script

Short BeenOpened
float timer

Begin OnActivate Player

if BeenOpened == 0 ;This will enable zombies and the MessageBox
set timer to 5
MessageBox "We warned you what would happen if you try to loot this place!"
cast aaDSoSFNSCryptCoffinSpell player
aaDSoSFNSZombieEnableREF.Enable
set BeenOpened to 1

Elseif BeenOpened == 1
set timer to 5
MessageBox "Debug: Zombies have spawned, tombs should not display old messagebox or zombies enabled a second time"
cast aaDSoSFNSCryptCoffinSpell player
set BeenOpened to 2

Endif

End

Begin GameMode

;timer will always count down as long as its been set
if timer > 0
set timer to timer - getSecondsPassed
endif

;will only happen once the counter has been bumped to 2 and the timer has finished counting down
if timer <= 0 && BeenOpened == 2
MessageBox "Debug: Timer has been reset"
set BeenOpened to 1
endif

End

Begin onReset
set BeenOpened to 0
aaDSoSFNSZombieEnableREF.Disable
End[/code] That said I'm not sure what the point of resetting BeenOpened with a timer is. Once the Zombie has been enabled he's going to stay that way untill you disable him again with the onReset block. So there doesn't seem to be much point trying to enable him again 5 seconds later. You might want to leave resetting that variable untill the onReset block runs. By combining the Counter and Timer checks you can just leave your Counter at 1 also rather than cycling it back and forth between 1 and 2.
[code]SCN aaDSoSFNSCryptCoffin01Script

Short BeenOpened
float timer

Begin OnActivate Player

;This will enable zombies and the MessageBox on first use
if BeenOpened == 0
set timer to 5 ;Stops the activator from reacting again if the player spams the Activate key
MessageBox "We warned you what would happen if you try to loot this place!"
cast aaDSoSFNSCryptCoffinSpell player
aaDSoSFNSZombieEnableREF.Enable
set BeenOpened to 1
;This block runs after the first activation, timer check stops it from being spammed
Elseif BeenOpened == 1 && timer <= 0
set timer to 5
MessageBox "Debug: Zombies have spawned, tombs should not display old messagebox or zombies enabled a second time"
cast aaDSoSFNSCryptCoffinSpell player
Endif

End


Begin GameMode

;timer will always count down as long as its been set
if timer > 0
set timer to timer - getSecondsPassed
endif

End


Begin onReset
set BeenOpened to 0
aaDSoSFNSZombieEnableREF.Disable
End

WT

0

Share this post


Link to post
Share on other sites

this script is placed on 30+ objects in this mod which are containers, but players can not open them.

I want the spell to be casted everytime the player tries to Loot the containers.

The zombie is only spawned once, which releases a horde of zombies throughout the cell, until the cell resets.

------------------

I figured it out after I got some sleep... Thank you for helping me :)

0

Share this post


Link to post
Share on other sites

Okay, I've found another issue....

I have this script attached to multiple activators. As is it works properly however; when the player activates one of the items the script follows through properly, but when the player activates ANOTHER item the script starts over from the beginning. It tries to re-enable the zombie swarm, and everything.

how would I modify this to when/if the player activates a second, third, fourth, etc., activator, the script starts at the "Elseif BeenOpened == 2" block?

Basically, once the first Block has been triggered, I only want the second block to be activated for all the other activators.


SCN aaDSoSFNSCryptCoffin01Script


Short BeenOpened

float timer


Begin OnActivate Player


	if BeenOpened == 0

		set timer to 5

		MessageBox "We warned you what would happen if you try to loot this place!"

		cast aaDSoSFNSCryptCoffinSpell player

		aaDSoSFNSZombieEnableREF.Enable

		set BeenOpened to 1


	Elseif BeenOpened == 2

		set timer to 5

		cast aaDSoSFNSCryptCoffinSpell player

		set BeenOpened to 3


	Endif	


End


Begin GameMode

	if BeenOpened == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: First Timer Finished"

			set BeenOpened to 2

		endif


	Elseif BeenOpened == 3

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: Second Timer Finished"

			set BeenOpened to 2

		endif


	endif

End


Begin onReset

	set BeenOpened to 0

	aaDSoSFNSZombieEnableREF.Disable

End

0

Share this post


Link to post
Share on other sites

You can use a global variable that can be updated with a value and used by all scripts so they all know its been done once already.

0

Share this post


Link to post
Share on other sites

ah that's right, I remember you telling me that I need to learn to use Global Vars.

Okay in this case, would I be able to do something like...

create a global Var as "BeenOpenedGblVar" and set the value to 1 or something like that

Then the script....



Short BeenOpened

float timer

Short BeenOpenedGblVar ;<------------------------------------ Added/Modified


Begin OnActivate Player


        if BeenOpened == 0

                set timer to 5

                MessageBox "We warned you what would happen if you try to loot this place!"

                cast aaDSoSFNSCryptCoffinSpell player

                aaDSoSFNSZombieEnableREF.Enable

		set BeenOpenedGblVar to 1  ;<------------------------------------ Added/Modified

                set BeenOpened to 1


        Elseif BeenOpened == 2

                set timer to 5

                cast aaDSoSFNSCryptCoffinSpell player

                set BeenOpened to 3


        Endif   


End


Begin GameMode

        if BeenOpened == 1

                if timer > 0

                        set timer to timer - getSecondsPassed

                else

                        MessageBox "Debug: First Timer Finished"

                        set BeenOpened to 2

                endif


        Elseif BeenOpened == 3 && BeenOpenedGblVar == 1 ;<------------------------------------ Added/Modified

                if timer > 0

                        set timer to timer - getSecondsPassed

                else

                        MessageBox "Debug: Second Timer Finished"

                        set BeenOpened to 2

                endif


        endif

End


Begin onReset

        set BeenOpened to 0

	set BeenOpenedGblVar to 0 ;<------------------------------------ Added/Modified

        aaDSoSFNSZombieEnableREF.Disable

End


0

Share this post


Link to post
Share on other sites

You do not define a global variable in your script.

Short BeenOpenedGblVar ;<------------------------------------ Added/Modified

On the toolbar, >GamePlay >Globals. Then right-click in the box and select new.

0

Share this post


Link to post
Share on other sites

ah Damnit all :curse: that's right... for some reason i keep thinking I do... Thank you for reminding me of that Willie.

I've got about a dozen or more Global Vars but can't remember what they are being used for, or if they are being used.

The other additions to the script should work correctly right?

0

Share this post


Link to post
Share on other sites

If you have globals you don't know how they are used, do a >Edit >Find Text on it.

As for the script working, dunno. Give it a test run and see what happens.

0

Share this post


Link to post
Share on other sites

If you have globals you don't know how they are used, do a >Edit >Find Text on it.

I thought about that after a couple of hours after posting that, I forgot to remove that statement. :wallbash: Lots of work at work, being forgetful at home :dizzy:

As for the script working, dunno. Give it a test run and see what happens.

As for this working it does not. Now the zombies are not enabling.

I reverted back to the original script without the Global Var and still does not work :cry:

The messagebox works, the cast spell works, the other activate block works... I'm out of ideas now :unsure:

I test on clean saves, I never save the game while my mod is activated so there should be no way that my game save is causing this.

New Script:


SCN aaDSoSFNSCryptCoffin01Script


Short BeenOpened

float timer


Begin OnActivate Player


	if BeenOpened == 0

		set timer to 5

		MessageBox "We warned you what would happen if you try to loot this place!"

		cast aaDSoSFNSCryptCoffinSpell player

		aaDSoSFNSZombieEnableREF.Enable

		set aaDSoSFNSBeenOpenedGblVar to 1

		set BeenOpened to 1


	Elseif BeenOpened == 2

		set timer to 5

		cast aaDSoSFNSCryptCoffinSpell player

		set BeenOpened to 3


	Endif   


End


Begin GameMode

	if BeenOpened == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: First Timer Finished"

			set BeenOpened to 2

		endif


	Elseif BeenOpened == 3 && aaDSoSFNSBeenOpenedGblVar == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: Second Timer Finished"

			set BeenOpened to 2

		endif


	endif

End


Begin onReset

	set BeenOpened to 0

	set aaDSoSFNSBeenOpenedGblVar to 0

	aaDSoSFNSZombieEnableREF.Disable

End

0

Share this post


Link to post
Share on other sites

As for this working it does not. Now the zombies are not enabling.


aaDSoSFNSZombieEnableREF.Enable
[/code]

Are you referring to this?

Make sure that is the reference id you have on the zombie object.

0

Share this post


Link to post
Share on other sites

I checked and it is the correct Ref ID.

0

Share this post


Link to post
Share on other sites

Change the order around, things that affect the player, do last. Always set your variables first.

If that does not help, they you have something wrong with your script because when you activate the object the script is on, it MUST run that block first since 'BeenOpened' will equal 0.

                set timer to 5
set aaDSoSFNSBeenOpenedGblVar to 1
set BeenOpened to 1
aaDSoSFNSZombieEnableREF.Enable
MessageBox "We warned you what would happen if you try to loot this place!"
cast aaDSoSFNSCryptCoffinSpell player
[/code]

0

Share this post


Link to post
Share on other sites

:curse::curse::curse::curse:

Found out what it was Willie... :bagged:

The script is fine for the zombie's, the messagebox and the cast spell...

The zombies were not enabling due to me changing the leveled list for it. I set it to LVL 10+... so nothing was spawning cause my character is only lvl 7... :bagged:

:curse::curse::curse::curse:

I still have to test and see if that Global Var is working correctly!

0

Share this post


Link to post
Share on other sites

I see, I don't remember you saying the zombies were a leveled list. :lol:

0

Share this post


Link to post
Share on other sites

uhmmm. I didn't :bagged:

I didn't think about saying it was

0

Share this post


Link to post
Share on other sites

Okay, just tested it again.... The Global Var still does not work.... all activators still display the first block...

Newest Script:


SCN aaDSoSFNSCryptCoffin01Script


Short BeenOpened

float timer


Begin OnActivate Player


	if BeenOpened == 0

		set timer to 5

		set aaDSoSFNSBeenOpenedGblVar to 1

		set BeenOpened to 1

		aaDSoSFNSZombieEnableREF.Enable 

		MessageBox "We warned you what would happen if you try to loot this place!"

		cast aaDSoSFNSCryptCoffinSpell player


	Elseif BeenOpened == 2

		set timer to 5

		set BeenOpened to 3

		cast aaDSoSFNSCryptCoffinSpell player


	Endif   


End


Begin GameMode

	if BeenOpened == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: First Timer Finished"

			set BeenOpened to 2

		endif


	Elseif BeenOpened == 3 && aaDSoSFNSBeenOpenedGblVar == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: Second Timer Finished"

			set BeenOpened to 2

		endif


	endif

End


Begin onReset

	set BeenOpened to 0

	set aaDSoSFNSBeenOpenedGblVar to 0

	aaDSoSFNSZombieEnableREF.Disable

End

0

Share this post


Link to post
Share on other sites

The first block of 'what'?

If its the 'onActivate', its because you are not using the global variable in your 'IF' test. Your using a local 'BeenOpened' variable.

0

Share this post


Link to post
Share on other sites

DOH... I see it now. :bagged: I'll fix it and test it.

the first block is of the OnActivate. Sorry about that, was heading to bed.

0

Share this post


Link to post
Share on other sites

i've changed that line, re built the script from ground up, etc. I have no idea why its not working properly.

I've been at this single script for 8 or 9 days now and I'm tired of it.... I've went through so many variations of the script, I don't even know what is what anymore.

:curse: this bloody script

0

Share this post


Link to post
Share on other sites

Post your current script. With a brief description of what you 'want' it to do.

0

Share this post


Link to post
Share on other sites

This script is the latest one *I think* Like I said I'm not sure anymore.


SCN aaDSoSFNSCryptCoffin01Script


Short BeenOpened

float timer


Begin OnActivate Player


	if BeenOpened == 0

		set timer to 5

		set aaDSoSFNSBeenOpenedGblVar to 1

		set BeenOpened to 1

		aaDSoSFNSZombieEnableREF.Enable 

		MessageBox "We warned you what would happen if you try to loot this place!"

		cast aaDSoSFNSCryptCoffinSpell player


	Elseif BeenOpened == 2 && aaDSoSFNSBeenOpenedGblVar == 1

		set timer to 5

		set BeenOpened to 3

		cast aaDSoSFNSCryptCoffinSpell player


	Endif   


End


Begin GameMode

	if BeenOpened == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: First Timer Finished"

			set BeenOpened to 2

		endif


	Elseif BeenOpened == 3 && aaDSoSFNSBeenOpenedGblVar == 1

		if timer > 0

			set timer to timer - getSecondsPassed

		else

			MessageBox "Debug: Second Timer Finished"

			set BeenOpened to 2

		endif


	endif

End


Begin onReset

	set BeenOpened to 0

	set aaDSoSFNSBeenOpenedGblVar to 0

	aaDSoSFNSZombieEnableREF.Disable

End

Player activates a coffin (There are 60 total in this cell (yeah I know probably to many) --- Script needs to work with all of them, especially once the initial activation has been done)

They get the MessageBox (above)

The Zombies Spawn (Throughout the cell I have 22 Zombie Leveled Lists attached to the one listed in the script above)

The Spell is Casted

5 Seconds between each activation so players cannot keep clicking on it for something to happen.

after the initial activation:

The coffins should only cast the spell (no zombie spawns (since they already are), no MessageBox, etc.)

That's all I can think of at the moment. I think it covers it all.

0

Share this post


Link to post
Share on other sites

As I mentioned above, you need to control the script with the global variable.

And I am not sure what you want with the spawned zombies. With 'enable', they will only show up once. If you want a true 'spawn' then you need to use PlaceAtMe.


SCN aaDSoSFNSCryptCoffin01Script

float timer
short BeenOpened

Begin OnActivate Player
if aaDSoSFNSBeenOpenedGblVar == 0
set timer to 5
set aaDSoSFNSBeenOpenedGblVar to 1
set BeenOpened to 1
aaDSoSFNSZombieEnableREF.Enable
MessageBox "We warned you what would happen if you tried to loot this place!"
cast aaDSoSFNSCryptCoffinSpell player
Elseif aaDSoSFNSBeenOpenedGblVar == 2
set timer to 5
cast aaDSoSFNSCryptCoffinSpell player
Endif
End

Begin GameMode
if BeenOpened == 1
if aaDSoSFNSBeenOpenedGblVar == 1
if timer > 0
set timer to timer - getSecondsPassed
else
MessageBox "Debug: First Timer Finished"
set aaDSoSFNSBeenOpenedGblVar to 2
endif
Elseif aaDSoSFNSBeenOpenedGblVar == 3
if timer > 0
set timer to timer - getSecondsPassed
else
MessageBox "Debug: Second Timer Finished"
set aaDSoSFNSBeenOpenedGblVar to 2
endif
endif
endif
End

Begin onReset
set aaDSoSFNSBeenOpenedGblVar to 0
set BeenOpened to 0
aaDSoSFNSZombieEnableREF.Disable
End
[/code]

0

Share this post


Link to post
Share on other sites

I see what you mean now, I thought you meant to place it along with the second OnActivate Block. :bagged: I'm still learning and I learned a few things with this script.

Tested the script out and that is exactly how I wanted it to work like. Thank You again Willie :)

As for the Zombies. As you can tell, the player was "Warned" about looting. I have a 24 zombie LL's throughout this cell. If the player tries to loot the coffins all the zombies will spawn to get revenge.

They should reset back to Disabled once the cell Resets and then continue the cycle correct?

I thought about using the PlaceAtMe, but would rather not due to possible Saved Game bloating.

0

Share this post


Link to post
Share on other sites

You cannot get 'save game bloat' when you are spawning something that gets cleaned up by the game engine upon death. Such as Zombies.

And unless you are spawning several thousand seperate pieces of an inventory item, save game bloat is a mute point. There seems to be a lot of hysteria around that topic, and thats all I feel it is, hysteria.

If the zombies are killed, when enabled, they will remain dead when you disable them. After cell reset, they will still be dead if they are enabled again. You would have to resurrect them first. Or just use placeAtMe to an xmarkerheading.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0