WillieSea

General Script Questions #2

160 posts in this topic

General Script Questions

1. Use this thread to ask question about scripts.

2. Use this thread to request classes on scripting topics.

3. Use this thread to ask if something you want to do can be scripted.

4. Just need to say something about anything scriptwise, use this thread.

5. Anyone can reply to questions asked in this thread.

NOTE regarding OBSE:

I do not code using OBSE but you may get help from others that do. So there are no guarantees that an OBSE question will be answered.

0

Share this post


Link to post
Share on other sites

I do have a question on scripting. I got a creature to act as a statue(thanks to the mod/resource out there I'm using the script) this isn't the problem, the problem is I can't seem to figure out how to get the creature to no longer be a statue when the player either walks close enough or passes through an activator/trigger zone. Now sure how possible it is or how hard it really is. I'd think that it's setting the unconscious, restrained and ghosts to 0 instead of one. It make sense to do that, the problem I have is how to bring them back to life to attack the player.

0

Share this post


Link to post
Share on other sites

Scn aaNexusStatueScript


Float Timer

Short doOnce


Begin onLoad


; resets timer for current cell load

    set Timer to 0


; resets var for current cell load, so setRestrained/setGhost aren't called every frame

    set doOnce to 0


; need to input values for these or else actor will spawn in between path grid nodes. Find these values in the CS.

    setPos x -498

   setPos y -566

    setPos z 9451

    setAngle z 0


; pick group from list provided

    PlayGroup CastSelf, 1


End


Begin GameMode


; change value for desired pose

    if ( Timer < 1.5 )


; this increments timer var to be able to stop anim

        set Timer to ( Timer + GetSecondsPassed )


    else


; these only need to be set once when player enters cell

        if doOnce == 0


            set doOnce to 1


; Unconscious actors do not "think" at all; this is not absolutely necessary, but can't hurt

            setUnconscious 1


; Restrained actors will not move from their current position, but will continue to "think" (pick packages, run detection so they could yell alarms) & go into dialogue

            setRestrained 1


; no combat, not harmed by hits/spells, will talk, cannot be pickpocketed

            setGhost 1


        endif


; causes the current animation to not be played for this frame

    skipAnim


    endif


End

for the statue, using the creature resource script for it here's what I have for the trigger. so far I got it so the lich can take damage, but his animations don't come back.
scn aavounexusTriggerstatueScript01


short doonce


Begin OnTrigger Player


If doonce == 0

     ; aavounexuslichstatue01.enable

aavounexuslichstatue01.setUnconscious 0

aavounexuslichstatue01.setRestrained 0

aavounexuslichstatue01.setGhost 0

       set doonce to 1

endif


End

killed the enable with a comment for now to make it work. so far only works partially. Only other idea I have is to use the statues, then put a activator nearby so it "summons" a monster. I was hoping not to have to do that, if I do okay.

0

Share this post


Link to post
Share on other sites

SetUnconscious causes problems with animations. That may be the culprit. You might try commenting that part out of both scripts.

0

Share this post


Link to post
Share on other sites

disabled the unconscious with no effect, then did unconscious and the restraint and nothing, ghost just does no damage which I set it to 0 and he takes damage. I have a grid setup around him just for the purpose of testing him out.

0

Share this post


Link to post
Share on other sites

It looks like you covered about all the commands enabled and disabled.

I am not sure how those commands affect creatures since I think they were mainly meant for NPCs. You may have just found one of the many bugs.

0

Share this post


Link to post
Share on other sites

Yay for uncovering bugs! :lol: So I presume the best thing I could do is create statues then use activators to make the spawns appear as if the statues summoned them. It could still make for a very interesting event to see and all the more frightening when they realize the statues summoned creatures to attack

0

Share this post


Link to post
Share on other sites

I don't know if you ever saw the mod that had the 'chests' that would come alive with snapping lids and crab-like feet. That takes a static chest and replaces it quite nicely with a creature in the same spot. (I wrote that script). Now if I could just figure out what the name of the mod was. It was based on the novels by Terry Pratchett, which had a chest called 'The Luggage' that follows Rincewind around.

0

Share this post


Link to post
Share on other sites

It wouldn't happen to be called Mimics would it? Chests with teeth if I remember right. A nifty little thing. Right now I'll keep it just with vanilla items as it's more for a semester project for class. After I'm done though I'll make the improved version.

0

Share this post


Link to post
Share on other sites

Yeah, mimics. What I was saying is you could look at the 'replacement' script if you wanted to know how to replace a static with a living creature.

0

Share this post


Link to post
Share on other sites

That's a good idea, will they respawn when the cell does? Would make it a lot more like what I intended.

0

Share this post


Link to post
Share on other sites

Static objects do not respawn, but you can script a variation of it to re-enable the static object after so many days.

0

Share this post


Link to post
Share on other sites

Well they're originally creatures, so I wouldn't imagine that they are considered statics. The mimic script just made me scratch my head leaving me like "um.. okay... what do I do with this?"

0

Share this post


Link to post
Share on other sites

Well, 'I' did script that little gem. (not sure how much it has changed since I wrote it.)

What it does is run on a static chest. When activated, it disables the chest, plays some magical effects and places the creature in the same spot the chest was in. I don't remember much more about it since its been so many years since I wrote that.

0

Share this post


Link to post
Share on other sites

Greetings Will, I'm back into modding after a couple of months devoted to a mod called Real Life. :)

I have a quick scripting question that does not require its own topic.

I'm simulating the "Go To Jail" mechanics in a prison controlled by knights. I am simulating it because I do not want imperial legionnaires to throw the players in there since the prison does not belong to them.

So the player is moved to the prison cell and succesfully managed to script any regular jail mechanics. Such as the equipment is removed from the player and put in a chest, if the prison cell door is picklocked, the guards will be aware of your escape, etc.

When the player uses the bedroll to serve his time, he gets teleported to the front of the keep and is free to go.

But there's one issue I have.

As mentioned, the player's equipment is removed by using the RemoveAllItems function and calling a chest as the target container. That works fine.

But what I'm trying to do is when the player has served his time, I want the equipment in the chest to return to the player. I have noticed no specific commands to do that.

Would it be possible to do so without having the player to manually go take back his equipment from the chest?

EDIT: Hmm maybe I could use the RemoveAllItems on the chest and target the player as the receiver? I just thought about it.

EDIT2: Okay. It actually works. It does not work if the chest is another cell, as my previous plans, but I decided to move the evidence chest to the prison cell.

Well. Case resolved. :smug:

Edited by Cliffworms
0

Share this post


Link to post
Share on other sites

I got a little problem. I'm trying to get a button to activate a specific set within 192 moving walls to create the layout for a maze. If I get it to work the projected plan is to create 3 more buttons to reconfigure the maze as each specifies. I would like to know if this is possible and if so how would I go about scripting....

0

Share this post


Link to post
Share on other sites

It depends on 'how' those 'moving walls' are animated.

You would use SetOpenState for door like objects.

You would use PlayGroup and give the command the animation group you want to play.

Sometimes the Activate command can be used on the object.

So, it depends on the object.

0

Share this post


Link to post
Share on other sites

Activator: ARSecretWallFAST01 is a secret wall with a up and down option. Specifics do waste less time I suppose :smug: But, When I try to activate a wall in a parent scenario it just won't serve my purpose. I still need just one button with say....like 196 walls attached to it. But then another button with 100 walls or so attached to it, yet I'd prefer that the script function toggled each wall in order to bring up the old walls and put down the new ones so that re-pushing the button would reset back and forth. ugh...just trying to make up a way to say this is tiring... :unsure: Anywho, I'm still learning by doing and reading and then doing some more, but limitations seem to creep up on me. :noway: Hopefully that was a good amount of info to aid in a helpfull reply.

0

Share this post


Link to post
Share on other sites

That object has two animation on it, "Forward" to open it and "Backward" to close it.

About your 'hundreds' of objects you want to activate on one button push. You may find that the game engine will not allow that many to be activated. Or not. I have run into issues with the Oblivion engine not being able to handle that many objects being changed.

So, you would use the PlayGroup command on each and every wall you want to be changed using the command I gave you above.

Open:

myWall001REF.PlayGroup Forward 1
Close:
myWall001REF.PlayGroup Backward 1

You need to give each wall a unique reference ID.

In your button script, you need to know which state you are in, state 1 or state 2. This way you know to open or close the walls.

0

Share this post


Link to post
Share on other sites

Okay, I have a mildly embarrassing scripting problem. When I try to save this script, it simply doesn't work- it doesn't come up with any error messages, the script is just not saved. After a discussion in the shouty, it seems that this is caused by my lack of knowledge regarding scripting syntax (although why the Cs isn't telling me like it usually does is anyone's guess). Anyway, all I want to do is to make an activator check whether or not the reference is enabled, then disable it if it is, and enable it if it isn't. Basically a simple switch to turn the reference "on or off". Here's the script:


scn *NAME*


begin onactivate

 if

*OBJECTREF*.getdisabled == 1

*OBJECTREF*.enable 

 elseif

*OBJECTREF*.getdisabled == 0

*OBJECTREF*.disable

 endif

end

Where am I going wrong?

0

Share this post


Link to post
Share on other sites

you can't divide lines as you see fit, oblivion's scripts are very restrictive in terms of syntax.

each comparison needs to be in the same line as if / elseif:

scn *NAME*


begin onactivate


if *OBJECTREF*.getdisabled == 1

	*OBJECTREF*.enable 

elseif *OBJECTREF*.getdisabled == 0

	*OBJECTREF*.disable

endif


end
anyway you can write it in slightly shorter way:
scn *NAME*


begin onactivate


if *OBJECTREF*.getdisabled

	*OBJECTREF*.enable 

else

	*OBJECTREF*.disable

endif


end

1

Share this post


Link to post
Share on other sites

Try this;


scn *NAME*


begin onactivate

 if

*OBJECTREF*.getdisabled == 1

*OBJECTREF*.enable 

 elseif *OBJECTREF*.getdisabled == 0

*OBJECTREF*.disable

 endif

end

EDIT: Ninja'd and Trollf's way is better anyway :P

Edited by AliTheLord
1

Share this post


Link to post
Share on other sites

Thanks for the quick response :)that was it, I'm laughing at myself now! Well, thanks again- have a cookie :cookie4u: it works perfectly now.

EDIT: sorry Ali, missed yours. Thanks to you as well, and have a cookie :D:cookie4u:

Edited by the-manta
0

Share this post


Link to post
Share on other sites

One note.

When putting your scirpt on the forum, avoid using 'markers' for your scripts. That would cause me to also say that is the problem. :rofl:

I know I am being picky, but its like throwing a wrench into my logically wired brain to see it this way:

scn *NAME* 
begin onactivate
if *OBJECTREF*.getdisabled [/code] Instead of this way:
[code]scn myScript
begin onactivate
if myObject01Ref.getdisabled

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