Establishing Scripting Concept

Post » Sun Nov 18, 2012 11:42 am

So for my High School Senior computer science I have been allowed to create a skyrim mod.
At its core this mod is essentially an Companion/Follower add-on to allow the player to make their own Dwarven Companions.

My actual question is:
What would be the best route to take to place a follower into the game work by activating an consumable item from a players inventory?
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Sun Nov 18, 2012 2:05 am

Add the food item (a potion item with its "Food Item" flag ticked) and maintain the follower with a Quest. The food item can be added to the Player via a quest script or as an alias "Created in" a Player Alias. To catch the consumption of the food item, you'll need to attach a Magic Effect of the Script archetype to the Potion form via a Spell.

Something like...
ScriptName YourSpellScript Extends ActiveMagicEffectInt iStage = 0ObjectReference rPortalActivator Property SummonTargetFXActivator AutoActor Property YourActorREF AutoEvent OnEffectStart(Actor akTarget, Actor akCaster, Float afScale = 0.0)	While iStage < 5		iStage += 1		If iStage == 1 ; Shroud them with a portal			rPortal = YourActorREF.PlaceAtMe(SummonTargetFXActivator, 1, False, True)			rPortal.Enable()		ElseIf iStage == 2 ; actor becomes invisible, consumed by the portal			afScale = YourActorREF.GetScale()			YourActorREF.SetScale(0.01)		ElseIf iStage == 3 ; move portal to player			rPortal.MoveTo(akCaster, Math.Sin(akCaster.GetAngleZ()) * 60, Math.Cos(akCaster.GetAngleZ()) * 60, akCaster.GetHeight() - 60)		ElseIf iStage == 4 ; actor shows up as portal dissipates			YourActorREF.MoveTo(rPortal)			YourActorREF.SetScale(afScale)		EndIf		Utility.Wait(0.6)	EndWhileEndEvent
...should do.
User avatar
Juan Cerda
 
Posts: 3426
Joined: Thu Jul 12, 2007 8:49 pm

Post » Sun Nov 18, 2012 3:14 am

That makes little sense but I will give it a try. Is it possible to activate a misc item, have it automaticly removed and then place the actor by me?
User avatar
lucile
 
Posts: 3371
Joined: Thu Mar 22, 2007 4:37 pm

Post » Sat Nov 17, 2012 9:40 pm

Yes, you can create a Player Alias and its RefAlias script, then enable your Actor with OnObjectEquipped().

MiscObjects are though not equipped like Armors and this will spawn a Notification, but the Event is still fired in a Player RefAlias script.
User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Sun Nov 18, 2012 12:00 pm

Yes, you can create a Player Alias and its RefAlias script, then enable your Actor with OnObjectEquipped().

MiscObjects are though not equipped like Armors and this will spawn a Notification, but the Event is still fired in a Player RefAlias script.
Ah that's perfect. Thank you!
User avatar
dell
 
Posts: 3452
Joined: Sat Mar 24, 2007 2:58 am

Post » Sat Nov 17, 2012 9:20 pm

Might as well keep my problems in one thread:

I have my Spider Follower behaving correctly using the Default follow player and run equilivent packages but when I try to move through a load door it doesn't want to follow me. Ideas?
User avatar
jodie
 
Posts: 3494
Joined: Wed Jun 14, 2006 8:42 pm

Post » Sun Nov 18, 2012 12:57 am

make sure your navmesh is properly finalised. there should be a coloured triangle under the door

[edit]

... for both doors, I should add.
User avatar
Vickey Martinez
 
Posts: 3455
Joined: Thu Apr 19, 2007 5:58 am

Post » Sun Nov 18, 2012 3:05 am

make sure your navmesh is properly finalised. there should be a coloured triangle under the door

[edit]

... for both doors, I should add.
I managed to figure that out about 20 mins afterwards.
Thank you for your help.
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am

Post » Sun Nov 18, 2012 8:21 am

I have run into another brick wall.
How do I access scripts for an already existing file?
I am trying to reverse engineer one of summon spells and scroll for my custom companions.
User avatar
Farrah Barry
 
Posts: 3523
Joined: Mon Dec 04, 2006 4:00 pm

Post » Sun Nov 18, 2012 12:50 am

The source is in data\scripts\source

Or choose edit from the context menu in the CK
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Sun Nov 18, 2012 3:09 am

Thank you Doc, now I have figured out what I need to make this all work (in theory, making it now).
My custom items, actors etc are spread out. Is there an easy way to group them together in the editor?
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Sun Nov 18, 2012 9:03 am

The "All" branch of the object window and sort by FormID or EditorID.
User avatar
carrie roche
 
Posts: 3527
Joined: Mon Jul 17, 2006 7:18 pm

Post » Sun Nov 18, 2012 12:46 pm

Also, it's good practice to give your mod a prefix - I use "SSG_" for mine. Then you can add that to the IDs of all the elements you add to the game.

After that finding all your bits is as simple as typing "XXXX" into the filter on the object window.
User avatar
sam westover
 
Posts: 3420
Joined: Sun Jun 10, 2007 2:00 pm

Post » Sun Nov 18, 2012 11:26 am

How would I go about removing an actors body from the game world?
My follower appears to "respawn" after it gets killed, the respawn box is unchceked. How do I got about stopping this from happening, or do you need more information?

and

How do I check if an actor/s are alive without recording their status within a global variable?
User avatar
Lawrence Armijo
 
Posts: 3446
Joined: Thu Sep 27, 2007 7:12 pm

Post » Sun Nov 18, 2012 4:01 am

You can disable them if you're not going to use them again. Or move them to a storage cell. You could also try DeleteWhenAble which will remove them once the player is out of the way and won't notice.

Use GetDead in conditions or Actor.IsDead in papyrus to tell if they're dead or not
User avatar
Nadia Nad
 
Posts: 3391
Joined: Thu Aug 31, 2006 3:17 pm

Post » Sun Nov 18, 2012 4:14 am

Will an OnActivate/other object reference events work with an actor?
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Sat Nov 17, 2012 9:33 pm

Will an OnActivate/other object reference events work with an actor?
Yes, as will Form events/functions since Actor extends ObjectReference which extends Form. An Actor function like SetAlpha, however, will only work on an Actor and not an ObjectReference or Form.

If zip extends zap, zip inherits zap's functions and events but not the other way around as all zips being zaps doesn't mean a zap can be treated as a zip.
User avatar
Kelsey Hall
 
Posts: 3355
Joined: Sat Dec 16, 2006 8:10 pm

Post » Sun Nov 18, 2012 12:58 am

If zip extends zap, zip inherits zap's functions and events but not the other way around as all zips being zaps doesn't mean a zap can be treated as a zip.

Or looked at another way: "Dog" inherits the functions of "Mammal". So while all Dogs are Mammals, but not all Mammals are Dogs. As my cats will testify.
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Sun Nov 18, 2012 7:19 am

Is this something Papyrus specific or is this something common in other multi-paradigm languages?
Only have small amounts of experience with python 3.2, VB6 and LUA.
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Sat Nov 17, 2012 11:22 pm

It's called "inheritance" and it's one of the key features of Object Oriented programming languages. C++, Java, C#, Python, Ruby, Perl ... they all support some sort of inheritance. Javascript and Lua too, although its a bit of work in those languages.

It's a useful thing to get your head around if you're coding.
User avatar
Antony Holdsworth
 
Posts: 3387
Joined: Tue May 29, 2007 4:50 am

Post » Sun Nov 18, 2012 6:56 am

It appears that I am unable to be able to activate it from my inventory using OnObjectEquipped() but OnActivate() works when the item is on the ground. I have probably done something wrong but I am unsure and and concerned as OnActivate() works for what I want but I am having a few issues attempting to use Game.GetPlayer().PlaceAtMe(Control_Spider) and before I try anything else I just want to know if there are any obvious issues with:
Event OnActivate()    Debug.MessageBox("Activating")    Utility.Wait(1)    Game.GetPlayer().PlaceActorAtMe(Control_Spider, 3)    Game.GetPlayer().RemoveItem(Control_SpiderCore, 1, bool abSilent = true)    Debug.MessageBox("Activated")EndEvent
User avatar
JERMAINE VIDAURRI
 
Posts: 3382
Joined: Tue Dec 04, 2007 9:06 am

Post » Sun Nov 18, 2012 9:04 am

It appears that I am unable to be able to activate it from my inventory using OnObjectEquipped() but OnActivate() works when the item is on the ground. I have probably done something wrong but I am unsure and and concerned as OnActivate() works for what I want but I am having a few issues attempting to use Game.GetPlayer().PlaceAtMe(Control_Spider) and before I try anything else I just want to know if there are any obvious issues with:
Event OnActivate()	Debug.MessageBox("Activating")	Utility.Wait(1)	Game.GetPlayer().PlaceActorAtMe(Control_Spider, 3)	Game.GetPlayer().RemoveItem(Control_SpiderCore, 1, bool abSilent = true)	Debug.MessageBox("Activated")EndEvent

Shouldn't your activate block be EventOnActivate(ObjectReference akActionRef) instead of OnActivate() ?
User avatar
Brιonα Renae
 
Posts: 3430
Joined: Mon Oct 22, 2007 3:10 am

Post » Sun Nov 18, 2012 3:43 am

If it's an inventory item, you'd want http://www.creationkit.com/OnEquipped_-_ObjectReference.
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Sun Nov 18, 2012 1:15 am

This is a fantastic example of the community coming together to help a new guy.

My two cents is that you shouldn't need to declare the bool as such within the function. In fact, it might throw things off a bit.
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Sun Nov 18, 2012 5:03 am

Shouldn't your activate block be EventOnActivate(ObjectReference akActionRef) instead of OnActivate() ?
It doesn't appear to matter? I just want it to activate the above when the item is activated.

If it's an inventory item, you'd want http://www.creationkit.com/OnEquipped_-_ObjectReference.
The problem is that (I think) because it is a misc it cannot be equipped and because of that the event isn't fired/? But I will have another go.


This is a fantastic example of the community coming together to help a new guy. My two cents is that you shouldn't need to declare the bool as such within the function. In fact, it might throw things off a bit.
:)
User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am

Next

Return to V - Skyrim