Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

General Script Questions #1


WillieSea
 Share

Recommended Posts

The complexities you want in your mod will require OBSE for sure. To get your target once the action key is pressed, you will have to get the reference of whats in the crosshair, then get its distance to the player, and then calculate your penalty/bonus values. And lastly, play a hit or miss animation along with the the results of either.

Some of that can be done with vanilla, but most will require OBSE. Good Luck!

Link to comment
Share on other sites

I do not think what you want can be accomplished with just placing a leveled monster marker. They are hard-coded in the game to work one way, and only that one way.

I do have a question. How are you 'disabling' the unwanted NPC's? For a leveled marker to work, I would think you need to perform a 'kill' on the NPC before disabling it. That way the marker knows it can later respawn if necessary. If you just disable NPC's your game will soon bloat in size with all those disabled NPC's.

My suggestion is to get rid of the leveled markers and create your own markers that use script to control when it creates another NPC. But, I can not think of any good way (other than making unique NPC's for each and every marker) to have the spawned NPC let the scripted marker know its now gone.

So, let me know more about what you want and what you think about what I have said.

Thank you for the answer, Willie Sea.

You see, I was trying to mimic Morrowind Comes Alive's script used on its random NPCs spawned on Leveled Markers. By reading your post and checking MCA's script, I noticed that only one function was different between Oblivion and Morrowind's scripting engine: "SetDelete". This function removes the associated reference and, in the case of leveled NPC Marker, it will spawn a new NPC from that marker. And that seems to be how Morrowind's markers work. As soon as the spawned creature/NPC is purged from a cell reset, gets removed by the player (Dispose of Corpse), or has the "SetDelete" command on it, the Marker automatically spawns a new NPC/Creature when the player returns to the cell.

So, this being said,are you suggesting a Quest Script that would control this? With X Markers replacing the Leveled Ones? And, finally, dummy cells in which the NPCs would be located, with unique ID names to control the respawn via the Quest Script?

Link to comment
Share on other sites

  • 3 weeks later...

I've run into a bit of a problem. I have a room set up with multiple activators and chests. I want to script one switch (a renamed ARSwitch01) to:

1. Play it's own animation.

2. Cause multiple persistent ref activators to cast spells at specific chests.

But, whenever I try to save the current script, I get the this message:

Script 'MCastSwitchScript', line 16:

Script command "LABWRef1" not found.

The current script I'm trying to save is:


scn MCastSwitchSCRIPT


short busy

ref target

ref mySelf


begin onActivate


	if busy == 0

		set target to getParentRef

		set mySelf to getSelf

		target.activate mySelf 1

		playgroup forward 0

		set busy to 1         

     endif

LABWRef1 cast LABWASpell LABWC1 ;LABWref1 is the activator LABWC1 is the target chest

LABWRef2 cast LABWASpell LABWC2 ;LABWref2 is the activator LABWC2 is the target chest etc.

LABWRef3 cast LABWASpell LABWC3

LABWRef4 cast LABWASpell LABWC4

LABVRef1 cast LABVASpell LABVC1

LABVRef2 cast LABVASpell LABVC2

LABVRef3 cast LABVASpell LABVC3


end


begin gameMode


	if isAnimPlaying == 0 && busy == 1

		set busy to 0


	endif


end

LABWASpell and LABVASpell are generic script effect spells that add certain items and should (in theory) work on any container.

What do I need to change to get this to work?

Or would it be better to have one activator cast all of these spells at all the target chests at the same time, using a Begin OnActivate block?

Link to comment
Share on other sites

You are not using the 'cast' function correctly.

Cast

But first, some questions.

1. What is 'LABWRef1' EXACTLY? If its the 'object' name then it will not work the way you have it. The cast command requires a 'Reference' name, not an 'Object' name.

gallery_85_79_8484.jpg

2. With the proper reference name to the left of the 'cast' command, you must put a '.' period between them. For example:

LABWRef1.cast

3. If the spell does not head towards the chest (LABWC1) its because its not an 'Activator' object. I am not sure if containers are considered activators when used with the cast command.

4. The Activator that is casting the spell must have a spell node 'outside' their collision zone. Otherwise, the spell will expload 'inside' the casting object.

5. I am not sure 'why' you are activating the linked parent ref. Does the linked parent ref need to be activated, is it doing something special?

6. Does the 'spell' have visual effects? If not, then why don't you just use the AddItem command to add a leveled list to the chest?

Thats all the notes for now. I am not really sure what you are after so some of my questions may not need to be answered.

Link to comment
Share on other sites

But first, some questions.

1. What is 'LABWRef1' EXACTLY? If its the 'object' name then it will not work the way you have it. The cast command requires a 'Reference' name, not an 'Object' name.

LABWRef1 is the RefID of a placed AREvilStonePulsar01 activator.

2. With the proper reference name to the left of the 'cast' command, you must put a '.' period between them. For example:

LABWRef1.cast

XD I should have noticed that. That's probably what's causing the issue. Would someone please use the console command OpenHeadInsertBrain on me?

3. If the spell does not head towards the chest (LABWC1) its because its not an 'Activator' object. I am not sure if containers are considered activators when used with the cast command.

I've used this setup before (activators firing spells at chests) so the issue is definitely my bad scripting.

4. The Activator that is casting the spell must have a spell node 'outside' their collision zone. Otherwise, the spell will expload 'inside' the casting object.

The AREvilStonePulsar01 .nif (ARTrapEvilStone01.NIF) doesn't actually have collisions. I've walked right through one before. tongue.gif

5. I am not sure 'why' you are activating the linked parent ref. Does the linked parent ref need to be activated, is it doing something special?

The switch isn't actually liked to anything. I just want the switch animation to play and cause multiple activators to cast their spells at their targets. If I make a new switch and give it a script that only tells the activators to shoot their targets (and doesn't also tell the switch to animate), the switch animation won't play and it wouldn't look too good in game.

6. Does the 'spell' have visual effects? If not, then why don't you just use the AddItem command to add a leveled list to the chest?

The spell uses the "Open" magic effect visual. The script for the spell uses the AddItem function to add the item. The spell's script is pretty basic:


scn SpellItemAddSCRIPT


Begin ScriptEffectStart

AddItem  ItemID 1

end

I used the console to add it to my spell list and it works perfectly when cast on any container. It would probably work on NPCs/Creatures too, but I haven't tried that yet.

Link to comment
Share on other sites

The switch isn't actually liked to anything. I just want the switch animation to play and cause multiple activators to cast their spells at their targets. If I make a new switch and give it a script that only tells the activators to shoot their targets (and doesn't also tell the switch to animate), the switch animation won't play and it wouldn't look too good in game.

Then all you need is this:

                playgroup forward 0
You can delete all of the get parent stuff:
                set target to getParentRef
set mySelf to getSelf
target.activate mySelf 1[/code]

The 'playgroup' is what animates the 'casting' reference.

Link to comment
Share on other sites

Ok can anyone help me out with this? I'm at my wits end. Why doesn't this script set my alchemy skill increase to 0? It doesn't seem to work at all. The key lines are the last 2. The former sets a global float to my current Alchemy skill advancement rate. The later line sets the skill advancement rate to 0. I placed this script on a book so it activates when you read it.

scn aaAHRecipeScript


begin OnActivate

	set aaahcontrolquest.stoptut to 1

	Player.AddItem Retort, 1

	Player.AddItem MortarPestle, 1

	Player.AddItem Calcinator, 1

	Player.AddItem Alembic, 1

	Player.EquipItem calcinator

	set aaAHAlchemyRate to (getskilluseincrement alchemy 1)

	SetSkillUseIncrement 0 Alchemy 1

End

Link to comment
Share on other sites

Ok can anyone help me out with this? I'm at my wits end. Why doesn't this script set my alchemy skill increase to 0? It doesn't seem to work at all. The key lines are the last 2. The former sets a global float to my current Alchemy skill advancement rate. The later line sets the skill advancement rate to 0. I placed this script on a book so it activates when you read it.

scn aaAHRecipeScript


begin OnActivate

	set aaahcontrolquest.stoptut to 1

	Player.AddItem Retort, 1

	Player.AddItem MortarPestle, 1

	Player.AddItem Calcinator, 1

	Player.AddItem Alembic, 1

	Player.EquipItem calcinator

	set aaAHAlchemyRate to (getskilluseincrement alchemy 1)

	SetSkillUseIncrement 0 Alchemy 1

End
If this book is being accessed from your inventory, you need to use Begin OnEquip instead of Begin OnActivte
Then all you need is this:
                playgroup forward 0
You can delete all of the get parent stuff:
                set target to getParentRef

                set mySelf to getSelf

                target.activate mySelf 1

The 'playgroup' is what animates the 'casting' reference.

Thanks! It mostly works now, but there is a new issue: the spells add six items per cast to each chest instead of just one. Just as a test, I scripted one activator to fire all 7 spells at the appropriate targets simultaneously. Not only did this work, the spells added only one item to each chest (like they're supposed to). Any ideas as to why the multiple activator setup adds six items to each of the seven chests?

Link to comment
Share on other sites

1. If the blast area radius is too big, it could affect more than one chest.

2. If you 'activate' the object more than once, it will ALWAYS run the cast commands since they are not 'inside' the "if busy" condition.

3. Depending on how your spell script is set up, I suppose it could be repeating itself on the 'add's. But your other test seems to nullify this point. Are you using the 'ScriptEffectUpdate' to add the items?

Link to comment
Share on other sites

1. If the blast area radius is too big, it could affect more than one chest.

That's what I was thinking at first, too. But, the spells are set to "Target" with an area of 0, so that's not the issue. :cookie:

2. If you 'activate' the object more than once, it will ALWAYS run the cast commands since they are not 'inside' the "if busy" condition.

I only activate the switch once. The way it's set up, chests 1, 2, 3 & 4 should each get one of ItemId01 and chests 5, 6 &7 should each get one of ItemID02. Instead, each chest is getting six of the related item. One odd thing I've noticed is that the spell impact sound seems to be louder than it should. It sounds like multiple spells are hitting each target simultaneously instead of one apiece, and the result seems to indicate that's exactly what is happening. I really don't understand why it's doing this. Or how, since it's scripted to fire one spell at each target, instead of six. :totallybaffled:

3. Depending on how your spell script is set up, I suppose it could be repeating itself on the 'add's. But your other test seems to nullify this point. Are you using the 'ScriptEffectUpdate' to add the items?

The script I'm using for the spells looks like this:


scn SpellItemAddSCRIPT


Begin ScriptEffectStart

AddItem  ItemID 1

end

The only difference between the scripts is the part replaced with ItemID. (And, of course, the script names tongue.gif )

And don't forget about Cydonian_Knight! Changing OnActivate to OnEquip might be the solution, but it might not.

Link to comment
Share on other sites

Change your script. I alluded to this, but perhaps you did not understand what I was saying.

	if busy == 0
set target to getParentRef
set mySelf to getSelf
target.activate mySelf 1
playgroup forward 0
set busy to 1
LABWRef1 cast LABWASpell LABWC1 ;LABWref1 is the activator LABWC1 is the target chest
LABWRef2 cast LABWASpell LABWC2 ;LABWref2 is the activator LABWC2 is the target chest etc.
LABWRef3 cast LABWASpell LABWC3
LABWRef4 cast LABWASpell LABWC4
LABVRef1 cast LABVASpell LABVC1
LABVRef2 cast LABVASpell LABVC2
LABVRef3 cast LABVASpell LABVC3
endif[/code]

[color=#FFA500]NOTE:[/color] It also might have trouble with your one object casting the 7 spells all in the same exact execution frame.

Link to comment
Share on other sites

Change your script. I alluded to this, but perhaps you did not understand what I was saying.

I did change it. I felt like a moron for putting Ref cast instead of Ref.cast. The current script is:


scn LABMultiCastSwitchSCRIPT


begin onActivate

playgroup forward 0

LABWRef1.cast LABWASpell LABWC1

LABWRef2.cast LABWASpell LABWC2

LABWRef3.cast LABWASpell LABWC3

LABWRef4.cast LABWASpell LABWC4

LABVRef1.cast LABVASpell LABVC1

LABVRef2.cast LABVASpell LABVC2

LABVRef3.cast LABVASpell LABVC3


end

Note: The above is attached to a switch that has no Parent enabled. The script for LABWASpell is:

scn LABWASpellScript


Begin ScriptEffectStart


additem LABStoneA 1


End

The script for LABVASpell is:

scn LABVASpellScript


Begin ScriptEffectStart


additem LABStoneB 1


End

This is the setup that should add only one stone to each chest, but instead adds six. The script for the activator that casts seven spell simultaneously is:

scn LABTestMultiCastScript


Begin OnActivate


cast LABWASpell LABWC1

cast LABWASpell LABWC2

cast LABWASpell LABWC3

cast LABWASpell LABWC4

cast LABVASpell LABVC1

cast LABVASpell LABVC2

cast LABVASpell LABVC3


End

This activator is activated by a switch. This script works perfectly. The spells all fire from the same activator (which looks really cool :D ) and add only one stone to each chest. I think I'm going to stick to this script since it actually works, but I wish I could understand why the other one doesn't work. :shrug:

Link to comment
Share on other sites

Hello, I looked at script tutorials 1 and 2, I did the HW for 2, but I still don't understand it that much. After saying this, I want to ask for some help with a door activation mod. I want to not be able to open a door until I pull a lever. I looked at some scripts ingame like the Farragut one and the secret leyawiin one.

scn MyDoorLeverActivation01

short doorStage

begin onactivate

if doorStage == 0

set doorStage to 1

endif

end

begin gameMode

if doorStage == 1

set doorstage to 2

elseif doorstage == 2

set doorStage to 0

endif

end

I have this so far. This might be a bit difficult of a project for me not knowing how to script, but I'm determined.

Link to comment
Share on other sites

Can you give more information on what exactly you want?

Depending on your response, there could be 'several' ways you can script what you want.

1. The lever could 'open' the door.

2. The lever could 'unlock' the door.

3. The lever could 'allow' the door to be opened by the player.

:D Smarty Says: Before you ever begin thinking about writing a script, it makes it easier for beginning scripters to 'write down' everything you want to happen, in logical steps. This can be difficult, to think logically and try to think about all the steps it takes to accomplish something.

So, for #1 above, you could say:

When the player activates the lever, if the door is open, it will close, otherwise if the door is closed, it will open.

Link to comment
Share on other sites

I wrote it down, but while I try to find it, I'll tell you what I'm looking to do.

1. Make the door so it MUST be activate by a lever in order to OPEN. Meaning the player can't just walk up to it and open it like most doors.

2. Make the door unclosable until the lever is activated again by a lever on the other side of the door.

A little picture with symbols might help a little. - is a lever and | is a door. 1- | -2 I want to activate the first lever so the door will open, then activate the other to close it. Out of your choices, I would, for sure, go with # 1.

Link to comment
Share on other sites

I need to know what the 'base object name' is, not what you named a copy of the base object.

You will only need one script for both levers and door combination.

So, one lever placed twice with one animated door.

But, the levers will ONLY open that one door.

Link to comment
Share on other sites

Give your door a reference name. (see the right side of the picture)

gallery_85_79_8484.jpg

Put this script on your one lever. Change the "myDoorNameREF" to the reference name you gave your door above.

scn myLeverOpen01Script
begin onActivate
if myDoorNameREF.GetOpenState == 3
; Open door
playgroup forward 1
myDoorNameREF.SetOpenState 1
elseif myDoorNameREF.GetOpenState == 1
; Close door
playgroup backward 1
myDoorNameREF.SetOpenState 0
endif
end[/code]

:D [b][color=#FF0000]Smarty Says:[/color][/b] This is why I needed the information I asked from you above.

1. There can be many different activator levers, buttons and switches. Each one acts differently and needs to be handled differently when its activated.

What I did was look at the existing lever "LeyawiinCastleLeverObject01" and looked at the script on the lever. It uses the basic script I have above. I then edited the script to fit the door you are using. It uses the 'setOpenState' instead of the 'playGroup' command to open this type of door.

2. I check the current open state of the door to determine if it should be opened or closed. Its also used to make sure the door is not currently moving in case somebody repeatedly activates the lever.

I determined it needed the SetOpenState by looking at the NIF in Nifskope, and checking to see what animation type it has. If it had 'forward' and 'backward', then you would use the 'PlayGroup' command to open and close it. But, this one had the animation type of 'Open' and 'Close', so I knew it needed the SetOpenState command to open and close it.

Link to comment
Share on other sites

Wow. I didn't expect it to be that easy. You really know what you are doing, and that's why you are the teacher. If you could give me an assignment or something (like school) that would be great. So, for scripting, would you recommend I get Nifskope? And if i do need it, is there a tutorial you know of for it?

Link to comment
Share on other sites

Nifskope is not needed for scripting. Its used to change a mesh or NIF file.

You can also use Nifskope to apply your own textures to objects. This is called 'Retexturing'.

If you Load the door NIF into Nifskope, on the top right is a little drop down box. It contains what types (if any) animation exist on the object.

To make it so the player cannot open the door manually, you can replace the normal 'Activate' with your own.

scn myDoor01Script
begin OnActivate
if (IsActionRef player)
return
else
Activate
endif
end[/code]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...