Difference between revisions of "Bethesda Tutorial Quest Aliases/ru"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Vitamant
imported>Vitamant
Line 27: Line 27:


=Aliases as Overlays=
=Aliases as Overlays=
{{Inuse/ru}}
The best way to think of aliases is as roles, defined for the specific purposes of their given quest. Characters and objects take on these roles for the duration of the quest, and then can shed them when the quest is done. This leads to much cleaner design implementation as well as memory savings.  
The best way to think of aliases is as roles, defined for the specific purposes of their given quest. Characters and objects take on these roles for the duration of the quest, and then can shed them when the quest is done. This leads to much cleaner design implementation as well as memory savings.  



Revision as of 07:54, 14 April 2012

Псевдонимы



RoundRussianFlag.pngНа русском языке
Требуется помощь переводчика


Псевдонимы
Серия: Продвинутое квестописания, глава 2
К другим учебникам
LeftArrow.png Предыдущая статья Следующая статьяRightArrow.png


Краткий обзор

Эта глава расскажет немного больше о псевдонимах, и почему же они так важны.

Ты узнаешь:

  • Как использовать условные псевдонимы.
  • Как правильно построить логику квеста, используя псевдонимы.

Мы делали это неправильно

То, что мы делали прежде - неверно.

Ну, не всё, конечно, но логика нашего квеста разнесена по всему мастер-файлу, что очень затрудняет ее изменение (в программировании это называется плохой инкапсуляцией).

Вот смотри: На Бэнду висит скрипт, который переводит стадию квеста GSQ01 на 200, когда тот умирает. Для изолированного случая, все как будто бы нормально. Но представь, что кто-то еще решил использовать Бэнду для своего квеста. Разработчик может изменить наш скрипт, или добавить собственный. Если это нормальный персонаж, без приставки "GSQ" в имени, то будет довольно сложно отследить и узнать, что же стало причиной внезапных багов в нашем квесте.

Та же проблем с амулетом и вором. Конечно, пока мы еще помним - где и что писали, и всё работает корректно, но будет намного лучше, если все будет лежать в одном месте, не правда ли? Вот тут нам и помогут псевдонимы!

Aliases as Overlays

Important.pngРедактируется
Эта секция в настоящий момент редактируется. Чтобы избежать конфликтов, пожалуйста, не вносите в нее никаких изменений, пока это сообщение не исчезнет. Если с момента последней правки статьи прошло больше одного дня, пожалуйста, удалите этот шаблон со страницы.

The best way to think of aliases is as roles, defined for the specific purposes of their given quest. Characters and objects take on these roles for the duration of the quest, and then can shed them when the quest is done. This leads to much cleaner design implementation as well as memory savings.

Open up the GSQBenduOlo actor that we made towards the beginning of the quest design tutorial series. After we tidied up the loose ends, he either has a script on him to handle his death, or has been flagged as essential. Both of these are very quest-specific bits of information though -- ask yourself, if the GSQ01 quest did not exist, is there any reason for them to be there? Since the answer is "no," clear them off of the base object: uncheck the "Essential" flag, and use the "Remove" button in the scripts area to take the script off of the base actor.

Now open the "Bendu" alias we made during the Quest Design Fundamentals chapter on objectives. Then, we were studiously ignoring most of this rather large window and all its various doodads, but now we'll actually look around a bit. Don't be scared.

FilledFirstAliasWindow.png

So looking around here, we see a lot of familiar elements. There's a script panel. A package stack. An inventory. _Et cetera_. We can treat these as we would the same areas on a base object, and when an actor is put into an alias, he will take on all of the data for that alias as if they were his own. More importantly, when a quest stops running, all its aliases are removed from their targets.

This is an important concept, so worth clarifying and mentioning again: An actor only takes on the data from an alias while its quest is running and he is in that alias. Once the quest stops, the actor will shed the alias like taking off a coat. (It's also possible to clear an alias, moving the actor out of it, while the quest is still running.)

This has a number of benefits:

  • Our scripts can be specific to this individual quest, which makes them simpler and thus easier to debug.
  • We can make quest-specific packages that will only govern the actor's behavior during the quest. (Note: the alias package stack sits on top of the actor's normal package stack, so alias packages will have priority.)
  • We can apply spells (including passive abilities) and factions for the duration of the quest, which can have dramatic impact on how an actor behaves, especially in combat.
  • If the quest changes and we decided to use a different character in the world, we only need to change the target of this alias and everything just works. It's kind of delightful.
Protip.jpg To make it easier to swap alias targets after the fact, it's good practice to make dialogue conditions use GetIsAliasRef instead of GetIsID. In this case, we'd want to go back through all our dialogue and replace our "GetIsID GSQBenduOlo == 1" conditions with "GetIsAliasRef Bendu == 1".

One "gotcha" with the overlay concept is the inventory: any items you put into an actor's inventory will stay there when they drop out of the alias. (You could, of course, remove things with a script if you need to, but consider the ramifications carefully.)

Fixing Bendu

But enough talk. Let's fix Bendu's alias so that his quest functionality lives here. As before, we have two approaches:

Immortal Bendu

You can simply click the Essential checkbox at the top of the Alias window, and Bendu will now be unkillable while he is in this alias. When the quest stops, he'll drop out of the alias and again be mortal.

Handling the Death

Or we can put a script on this alias to handle Bendu's death, just like we had previously scripted the base object. Note that we have to change the first line of the script so that it will attach to a ReferenceAlias instead of an actor. The script we would make this time would be called "GSQQuestgiver" and look like this:

Scriptname GSQQuestgiver extends ReferenceAlias

Event OnDeath(Actor akKiller)
	if (!GetOwningQuest().IsCompleted())
		GetOwningQuest().SetStage(200)
	endif
EndEvent

Note that we don't have to set the quest as a property this time around; every ReferenceAlias is aware of the quest that owns it, so we can access it with GetOwningQuest().

Now, setting a stage when an Actor dies is an exceedingly common task, so there's no need to make a specialized script for it. When you click the Add button to put a script on this alias, look for scripts that begin with "default" -- these are provided scripts that perform common tasks. They are generally named pretty descriptively, so you can guess what they do from what they're called. In this case, we want "defaultSetStageOnDeathRefAlias". In this case, we'll need to set properties:

  • myQST: GSQ01
  • preReqStage: <leave blank>
  • StageToSet: 200

(By using default scripts, we can drastically decrease the total number of scripts in the game, which has benefits for memory usage. Since you're modding for a PC that likely has copious memory, it may be less of a concern.)

Changing the Name

One final side note: you can even change the name of a reference when it's in an alias, so that players will see different text when they roll over it. You can define a Message with whatever text you want, and select it from the Display Name pulldown at the top of the alias window.

AliasDisplayName.png

By default, once you place a new display name on a reference, it will retain it even after your quest is over. This is so the player doesn't come back to a cleared-out dungeon to find that all the enemies are now called different things than they were when they were killed. You can override this behavior with the "Clears Name When Removed" checkbox in the upper right.

Packages

The package stack for the alias will be placed above an actor's normal package stack, effectively overriding it.


LeftArrow.png Предыдущая статья К другим учебникам Следующая статья RightArrow.png



Language: English  • français • русский