Meaning of "GetOwningQuest() as MG03QuestScript"?

Post » Mon Aug 26, 2013 12:49 pm

What does "(GetOwningQuest() as MG03QuestScript)" mean?

User avatar
Bonnie Clyde
 
Posts: 3409
Joined: Thu Jun 22, 2006 10:02 pm

Post » Mon Aug 26, 2013 9:40 am

It's used to manipulate variables in the script attached to the quest.

User avatar
xx_Jess_xx
 
Posts: 3371
Joined: Thu Nov 30, 2006 12:01 pm

Post » Mon Aug 26, 2013 3:36 am

But what does it mean? I don't understand what happens when a function is casted to a script.

User avatar
Nauty
 
Posts: 3410
Joined: Wed Jan 24, 2007 6:58 pm

Post » Mon Aug 26, 2013 3:51 pm

If you call GetOwningQuest(), it will return a Quest object. However, MG03QuestScript probably has additional variables that Quest doesn't; if you want to manipulate those variables, you need to cast the object as a MG03QuestScript (which is extended from Quest).

Or, put another way:

All MG03QuestScript objects are Quests, but not all Quests are MG03QuestScript objects. If the owning quest happens to be an MG03QuestScript and you need to access the properties that make MG03QuestScript objects special, then you need to cast the owning quest as an MG03QuestScript.

User avatar
Philip Rua
 
Posts: 3348
Joined: Sun May 06, 2007 11:53 am

Post » Mon Aug 26, 2013 1:32 am

I hope you're well rested and can wrap your head around the following as it is convoluted.

GetOwningQuest() returns the quest that for example the info topic, where the function is called, belongs to. Casting the returned quest as a script that is attached to that quest gives you access to the specific instance of the script that is attached to the aforementioned quest.

EDIT: :ph34r:

User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm


Return to V - Skyrim