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 script is running on the parent ref, part of a global run scavenger hunt. As each object in the hunt is collected its script raises the global count in the quest script.

scn aaScavengerHuntObjectSCRIPT

short doonce

begin onAdd player
if doonce == 0
set QuestName.VariableName to QuestName.VariableName + 1
set doonce to 1
endif
end[/code]

The problem is that in order to catch the attention of players and make finding the objects easier, I've added a light object to enable over each. When the scavenger hunt item is collected by the player, the quest global updates, but the light object remains. I need to find the best way to disable those light objects once their scavenger hunt item is collected so there are no mystery lights shining around the hunting ground.

Link to comment
Share on other sites

I am still not clear on the full linkage of all the objects your using.

But...

You can parent children to parents, and have the parents be children of other parents.

child -> parent -> grandparent -> etc..

The child script can then find out who the 'grandparent' is like this:

Ref myParent
Ref myGrandParent
...
set myParent to GetParentRef
set myGrandParent to myParent.GetParentRef[/code]

If that does not help, let me know what objects your using and how they are linked and how they need to interact.

I did something similar to this in the ice caves (remember?) where you pick up the frozen tears. Its a static object that disables on activation, adds a real tear to the players inventory, and when the tear disables, so do the lights and fog effects.

Link to comment
Share on other sites

  • 1 month later...

okay, i need a script for a trap, where the player activates a triggerzone, plays a sound, and enables a reference...

i was looking at the trigzones in the cs and i tried to do my best:

scn VmpTrigZoneSpook01SCRIPT


; Activates linked Parent object once


short triggered

ref target

ref mySelf


begin onTrigger player


	if triggered == 0

		set triggered to 1

		set target to getParentRef

		set mySelf to getSelf

		target.activate mySelf 1

                playsound "xxxx"

                set target to enable

	endif


end

does that look right-ish? this was just my best guess...do i even need
set mySelf to getSelf

                target.activate mySelf 1

?

any help would be much appreciated :blush:

Link to comment
Share on other sites

so this is all good then?

scn VmpTrigZoneSpook01SCRIPT


; Activates linked Parent object once


short triggered

ref target

ref mySelf


begin onTrigger player


        if triggered == 0

                set triggered to 1

		set target to getParentRef

                set mySelf to getSelf

                playsound DRSFleshsackOpen

		target.enable mySelf 1

        endif


end

what is the "set mySelf to getSelf" for? Is "myself" supposed to by in "target.enable mySelf 1"?

Link to comment
Share on other sites

No. The script you create depends on WHAT trap you are talking about. Most traps NEED the activate line of code to be set off.

Everything after 'target.enable' is ignored. All that line does is make the target reference (the target is set by your triggerzones enable parent) to be enabled. In this case, if your trap is disabled, your trigger zone will be disabled as well, and not work. Since its disabled through the enable parentage.

You should use the 'activate' line of code just like you had in the first post for most traps. But, not knowing what you are using, I could not say for sure.

Link to comment
Share on other sites

well i have a triggerbox, and i'm trying to make it so that when the player triggers it a sound is played and a creature (tagged "initially disabled") is enabled.

I placed a triggzone box, and a creature. I then set the creature as initially disabled. Then I set the parent ref of the triggerbox to the creature, and i have the script in post #105 on the triggerzone...

Link to comment
Share on other sites

Ok, so you are not scripting a 'trap' item, but you are scripting for an 'ambush'. Gotcha.

But, you never did say what is or is not happening when you test your trigger zone and script.

This is the fixed version of your script.

scn VmpTrigZoneSpook01SCRIPT
; Activates linked Parent object once

short triggered
ref target

begin onTrigger player
if triggered == 0
set triggered to 1
set target to getParentRef
playsound DRSFleshsackOpen
target.enable
endif
end[/code]

You do not need the 'mySelf' reference. The 'enable' code does not work with anything other than a reference, which is what your 'target.' reference variable name contains.

Link to comment
Share on other sites

What I want to do is script a bow to add a specific arrow type to the Player's inventory whenever that arrow type is fired (even if it doesn't hit anything). For instance:

I fire 1 Elven arrow with this bow. 1 Elven arrow is added to back to my inventory immediately.

I fire 1 Glass arrow with the same bow. The script does nothing because it's set only to add 1 Elven arrow when an Elven arrow is fired.

Is this possible to do?

Link to comment
Share on other sites

well, i think you could attach a script onto the bow so that it keep your arrow count at a set amount.

The script could look like this:

scn SpecialBowSCRIPT01


Begin GameMode 


if (GetItemCount "elvenarrowID" < 20)

  player.additem "elvenarrowID" 1

endif


End

this should make it so that anytime the player equips the bow, and the arrow count is below 20, an arrow will be added.

i'm not much of a scripter, so there might be a better way, but this should get the job done :P

i think OnEquip would work as well, instead of GameMode, but i don't see a difference since the script would be attached to the bow.

goodluck :shrug:

Link to comment
Share on other sites

SNIP

OnEquip would only run the script when the bow is equipped. I have never scripted a bow to do that nor have I tested this script, but I think this will work:

Scriptname ISBowScript

Short CurrentCount
Short BaseCount
Short AddCount

Begin GameMode

Set CurrentCount Player.GetItemCount elvenarrowID
Set BaseCount to 20

If CurrentCount < BaseCount
Set AddCount to BaseCount - CurrentCount
Player.Additem elvenarrowID AddCount
Endif

End[/code]

Link to comment
Share on other sites

The problem with this type of scripting is that the added arrows are NOT added to the equipped arrow count. (unless something has changed since I tried this last.)

So, you have 25 arrows. You shoot 6 of them, and the script adds one arrow. (base cound of 20) You will now have 19 arrows equipped and 1 in your inventory. Shoot another arrow and you will have 18 arrows equipped on the bow and 2 in your inventory.

You could try 'equipItem' on the arrow to reset the count that is equipped. But that spams your messages.

Link to comment
Share on other sites

Thanks IS, your originsl script acually works (with one slight oddity-see below).

The problem with this type of scripting is that the added arrows are NOT added to the equipped arrow count. (unless something has changed since I tried this last.)

So, you have 25 arrows. You shoot 6 of them, and the script adds one arrow. (base cound of 20) You will now have 19 arrows equipped and 1 in your inventory. Shoot another arrow and you will have 18 arrows equipped on the bow and 2 in your inventory.

You could try 'equipItem' on the arrow to reset the count that is equipped. But that spams your messages.

Actually, the arrows did get added to the equipped item count using just the script on the bow. The only oddity I ran into was that 20 arrows got added to my inventory as soon as I entered the room with the chest containing the bow. Is there an easy way to delay this until the bow is in the Player's inventory?

Link to comment
Share on other sites

You might try something like this...

Scriptname myBowArrowScript
Short CurrentCount
Short BaseCount
Short AddCount
short myStat

Begin OnEquip
set myStat to 1
End

Begin OnUnEquip
set myStat to 0
End

Begin GameMode
if myStat == 1
Set CurrentCount Player.GetItemCount elvenarrowID
Set BaseCount to 20
If CurrentCount < BaseCount
Set AddCount to BaseCount - CurrentCount
Player.Additem elvenarrowID AddCount
endif
endif
End[/code]

Link to comment
Share on other sites

Hi!

For Oblivifall - Better Inns, I'm placing leveled creature markers inside taverns, streets, temples, etc. The NPCs spawned by the markers have a script attached to them that remove them from the world under certain conditions. For example, if the NPC is spawned inside and the player leaves the place and goes away for a certain number of units, the NPC will disable himself. But what I can't seem to do/find is a way for the leveled creature marker to spawn a new NPC when the older one has dissapeared, with the Chance None setting to stay, so that there MAY be a NPC spawned, or not.

Basicly, somehow re-enabling the Leveled Creature Marker instead of waiting the in-game 3 Days respawn time.

My thoughts on how to proceed:

To let the Leveled Creature marker know that the NPC has disabled himself: The script on the NPC sets a Quest variable to 1. The leveled creature marker checks the quest variable each time the conditions are met (Player enters the cell, for instance) and if it is at 1, it spawns a new NPC.

Though the problem with calling a quest variable is that some leveled creature markers appear at more than one place at a time. So I think that giving a quest variable will make other markers think their NPCs has been disabled, and they'll spawn more. Soon, we'll have hundreds of NPCs everywhere.

So! in short:

- The function for a leveled creature marker to spawn a new NPC from its leveled list.

- Finding a way to let the marker know his latest spawned NPC has been disabled.

Those are my questions. :pints:

Other than those two things, the NPCs script work wonderfully. They disable themselves during the night (For non-thief NPCs), or simply dissapear if you go away for too long, simulating the come and go of the NPCs.

:clap:

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.

Link to comment
Share on other sites

Hi there,

Still making my Sneak/Dagger Mod, slowly but surely. I'm seeking a master of knowledge just to be sure I'm taking the right way...

Here are my (noobish) questions :

This is the general question :

Is it difficult to script a combat move ? "I mean an attack, triggered by pressing a mod-specific action key, causing damage and eventually another effect on the target, and potentially triggering a nice animation (with a lot of blood and guts, of course)".

And to be more specific :

* Let's put the animation aside, as I'm unable to do it - with any tool - and will probably ask a talented animator once my mod is more advanced. until then, I plan to use vanilla animation file. Is there something I must know to be able to replace easily this animation with a new one once I get it ?

* For creating the "hit" sequence (PC facing target ? PC distance from target < weapon reach, etc...), should do it all "by hand" or is there some kind of way to override the onhit method ?

* I just discovered I can make function blocks using obse, how do I store them to make a library ? In a quest script maybe ?

Thanks in advance and merry christmas :thumbup:.

Link to comment
Share on other sites

You can 'script' an animation to play on a target, and its pretty easy. But getting it all to work smoothly can be a hassle. You can force an animation to play using the PlayGroup function call. Make sure to read the wiki page as it has notes that apply to playing animations on the player. So, you can see it would be easy to play any animation you want if you get a different animation at a later time.

I am not sure how you would tell if the player is facing a target. You can use GetDistance to find out how far you are from the target.

If you want to use a different attack key, you would need to use OBSE. Since I do nto deal with OBSE, I could not help you with those types of questions.

My question is this: Is this for using 'any' dagger or a specific dagger? Oblivion is difficult to make 'dynamic' things do special stuff. I am not sure how you would make it work for 'all 1 handed blade' weapons. Perhaps OBSE has a command that can check weapon types.

Link to comment
Share on other sites

Thanks a lot for your answers, WillieSea, I'll have a look on the wiki for the animation part.

Yes, I plan to use OBSE. The reason is that a part of the mod checks equipped items to compute a sneak penalty/bonus. So I need the OBSE "getEquippedObject" function. This function returns a reference when called on the weapon slot, on which I can work to get the weapon type/range/speed/weight. Once I get those vars, I can tell whether the equipped weapon is a dagger or not.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...