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...

[Validation] Scripts for my Mods


Nahkin
 Share

Recommended Posts

Hey and thanks especially to the people who helped me a lot with my first scripts.

Basicly they wrote me the scripts and I adepted them a litle ;). So my big thanks goes to WillieSea, Leianne and BrettM.

Because of this great help I was able to implement some really cool scripts for my next mods.

 

Tho I thought I should post here my future requests and the scripts I am already using. The reason is that I would like to hear some professional opinion on them and know if they are right and don't make some bad entries or so.

Just to know if they are clean or if I could enhance something.

 

1) Summons a enemie with a explosion effect, once you enter a trigger zone:

Scriptname AAAncientRuinsSummonScript extends ObjectReference

Actor Property BadGuy Auto
ObjectReference Property MagicLight Auto
Actor Property PlayerREF Auto ; Least 'costly' way to refer to the player

Int property myinterval Auto
Explosion property summonFX Auto

bool property summoned = False Auto
float property playtime Auto
 

Event OnTriggerEnter(ObjectReference akActionRef)
    if akActionRef == PlayerREF
        Summon()
    endif
EndEvent

Event Summon()
    if (!BadGuy.IsDead() && !summoned)
        BadGuy.PlaceAtMe(summonFX)
        MagicLight.enable(True)
        Utility.Wait(myinterval)
        BadGuy.Enable(True)
        summoned = True
    EndIf
EndEvent

2) This script enables a door or something else, once you drink a potion. It's placed on a magic effect and creates a small explosion at enableing it.

 

Scriptname AAMarcatosPotion extends ActiveMagicEffect  
 

ObjectReference property myDoor Auto
Explosion property summonFX Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

    if akTarget == Game.GetPlayer()
        if myDoor.IsDisabled()
              myDoor.Enable(1);
            myDoor.PlaceAtMe(summonFX);
               Utility.Wait(4.0);
        else
               myDoor.Disable(1);
        endif
    endif
endevent

3) This script just disables a door after the player activated it.

Scriptname AAMarcatosGate extends ObjectReference  

Event OnActivate (ObjectReference akActionRef)
        disable()
       activate(game.getplayer())
EndEvent

Thank you very much again for your help :D.

Edited by Nahkin
Link to comment
Share on other sites

I'm still trying to figure out the proper techniques for avoiding permanent persistence, but it seems to me that your first script is creating such a situation for your BadGuy actor. That actor will never be unloaded from memory using your setup, even when the cell is unloaded and he is no longer required, because you have a permanent reference to him. Note that the Bethesda script for a fake summoning effect is an extension of the actor script, but here you've attached the code directly to the trigger. I believe the appropriate technique would involve using an alias for the actor, with the summoning effect attached to that alias, which is then activated by the trigger.

 

The MagicLight property creates another permanently-persistent reference that will never be unloaded. I don't know what purpose this serves in your setup, but perhaps there is a way to create this on demand from the base object rather than having a preexisting reference to it.

 

Why does the MyInterval property exist? I don't understand why the interval for the Wait() function can't be a simple constant. Likewise, I don't understand the reason for the PlayTime property, since it doesn't seem to be referenced anywhere in the script.

 

The ActiveMagicEffect script creates yet another permanently-persistent reference for the door. Possibly a LinkRef would be a better way to access it, but I'm not sure whether LinkRefs cause permanent persistence unless you fail to clear the variable after you're done with it.

 

If the door is initially disabled, then it will be invisible until the potion is consumed for the first time. What will the player see in that location before using the potion, or after using the potion a second time? It also isn't clear to me why the player would want to use the potion again to make the door go away without having opened it. (Some comments in your scripts wouldn't hurt!)

 

Since you've made the door appear first, isn't playing a summoning FX afterward a little pointless? Normally summoned items do not appear until after the FX play, as is the case for your BadGuy.

 

Your first script used PlayerREF to refer to the player character, but your potion and door scripts use the less-efficient Game.GetPlayer() instead. Why?

 

I don't know whether re-activating the door in the OnActivate event is more efficient or less efficient than playing the animation and setting the state to closed, but why do either? The player will never see the animation because you've already made the door invisible. My guess is that all you really need to do to an invisible door is SetOpen(False) to put it back in the closed state for the next time it is used.

 

@Ghaunadaur: Events are really just functions that have no return value, so I don't think it makes any difference. In fact, some of my reading seems to hint that an Event might be preferable for a function that takes no arguments, but I won't swear to that.

Edited by BrettM
Link to comment
Share on other sites

Big thanks for the answers !! They helped me a lot !!

Yes normally I comment code always, but hey it's not finished haha :D.

Anyway to clarify the situation with the potion and the door further.

 

The player drinks the potion and the door can be disabled it's a magical one. Means I created a custom door, which you have to activate. Where the door stands there is noramlly a fire and some other stuff around it and it just appears in the middle. So it looks pretty cool.

The explosion will be placed before ofc. I haven't seen this till now thank you very much.

 

The purpose of the door scirpt to disable is that the player should only enter or use the door once and than the magical portal closes again.

So you have to gather again all the ingredients and make the potion in order to create the portal.

The potion is used, as it's like a dream that you open.

You enter the realm of Vaermina ^^.

Now I have spoilered hehe :D.

Edited by Nahkin
Link to comment
Share on other sites

You can do delete().

 

Actor tmp

tmp =  placeatme

 

blah blah

 

tmp.delete()

 

Should work. :)

 

I'm still trying to figure out the proper techniques for avoiding permanent persistence, but it seems to me that your first script is creating such a situation for your BadGuy actor.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...