Download Complete Unreal Engine 5 Game Development with C++ Scripting: Become a professional game developer and create fully functional, high-quality games 1st Edition Zhenyu George Li PDF for All Chapters
Download Complete Unreal Engine 5 Game Development with C++ Scripting: Become a professional game developer and create fully functional, high-quality games 1st Edition Zhenyu George Li PDF for All Chapters
com
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/advanced-unity-game-development-build-
professional-games-with-unity-c-and-visual-studio-victor-g-brusca/
ebookmeta.com
https://ebookmeta.com/product/our-living-tradition-first-series-1st-
edition-claude-bissell/
ebookmeta.com
Demon Huntress 1st Edition Milly Taiden
https://ebookmeta.com/product/demon-huntress-1st-edition-milly-
taiden-3/
ebookmeta.com
https://ebookmeta.com/product/lonely-planet-colombia-10th-edition-
lonely-planet/
ebookmeta.com
https://ebookmeta.com/product/leading-from-the-edge-of-the-inside-
embracing-the-heart-of-business-leadership-jim-moats/
ebookmeta.com
https://ebookmeta.com/product/haxe-game-development-essentials-1st-
edition-jeremy-mccurdy/
ebookmeta.com
https://ebookmeta.com/product/colorado-cold-case-1st-edition-elle-
james/
ebookmeta.com
Complete Calisthenics 2nd Edition The Ultimate Guide to
Bodyweight Exercise Ashley Kalym
https://ebookmeta.com/product/complete-calisthenics-2nd-edition-the-
ultimate-guide-to-bodyweight-exercise-ashley-kalym/
ebookmeta.com
Unreal Engine 5
Game Development
with C++ Scripting
Zhenyu George Li
BIRMINGHAM—MUMBAI
Unreal Engine 5 Game Development with C++ Scripting
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.
ISBN 978-1-80461-393-1
www.packtpub.com
Foreword
I have known and worked with George Li in various capacities for more than 20 years.
We met first as colleagues at a private college of interactive arts in downtown Vancouver, Canada. I
was a full professor of linguistics at a university in the area, with extensive experience in developing
a cognitive science program at the university. Establishing a curriculum for such a program involved
familiarizing myself with areas well beyond the area of my specific academic position and collaborating
closely with colleagues – particularly in computing science (cognitive), psychology, and philosophy
(particularly concerning socio-epistemological issues such as AI). It was in this spirit that I was happy
to associate myself with a private college, focusing on language study and teaching, together with
preparing students to handle 3D computer applications (e.g., 3ds Max, 3D GameStudio, and Unreal)
and showing them how to generate animation materials for film, TV, and games.
George Li was in charge of all the technical requirements of the college. I very quickly realized that he
was not merely extremely competent and forthcoming (he had already occupied high-level computing-
related positions, software engineering for instance, in China prior to emigrating to Canada) but
also computationally competent and brilliantly innovative. He also had a particular interest in the
development of game engines and was already collaborating with his colleague, Charles Yeh, on a
practical reference book, XNA PC & Xbox360 C# Game Programming, with proprietary-produced
text and games to his credit.
As colleagues in the college, George and I found common, mutually strengthening interests. Eventually,
he and I found ourselves in charge of creating a two-year interactive-arts program curriculum for
the college.
My whole career, at universities in the UK and Canada, and as a member of the editorial boards of
a major academic journal and a very influential series, has closely involved the evaluation of the
intellectual quality of people’s capabilities and work, and in my opinion, George Li’s innate talents
shine out clearly throughout his work and will continue to do so in the future. His ability to express
his knowledge of the subject at hand is outstandingly demonstrated in all his work, performance,
expressions, and character.
This book, like the one co-authored with Yeh, is designed for independent developers and company
training, plus for reference after post-secondary education. The knowledge presented herein is most
intelligently, clearly, and effectively presented so as to be as efficiently applicable and pedagogically
effective as possible on any device or platform, producing high-quality games, accessories, and edits.
This volume will certainly stand the test of time and fulfill the majority of the needs of those working
in the field of gaming. However, I am certain that George will make further, very crucial contributions
to this topic.
Until then, this volume will serve you excellently, helping you enjoy and prosper with your future
activities and products.
I express my gratitude to my wife, Alison Guo, for her support in handling family responsibilities and
for enabling me to dedicate time to completing this book. I also extend my thanks to Sarah Beck and
Willy Campos for their encouragement and support throughout the writing process.
About the reviewers
Aditya Dutta holds a game programming advanced diploma from Humber College and is a highly
accomplished senior software engineer at Archiact Interactive, bringing expertise in Unreal Engine
and C++ system design and implementation.
With a strong collaborative spirit, Aditya leads feature development and takes ownership of tools
while actively improving team processes. These leadership skills were evident during his tenure
as lead programmer at Humber College, where he successfully guided and mentored a team of
programmers, overseeing the technical aspects of significant projects in the virtual production and
architecture industries.
His contributions at UP360 Inc. as a programmer included shipping numerous training VR simulations,
developing iterative tools, and implementing gameplay mechanics using Unreal Engine.
Michael Oakes is a senior software consultant for Unity and has over 27 years of experience in the
IT industry. He has worked with real-time 3D and games for over eight years, specializing in mixed
reality design and development, shader programming, and AI and multiplayer systems.
He has worked as a technical consultant on other titles, including Packt Publishing’s Learn ML-Agents
– Fundamentals of Unity Machine Learning, written by Micheal Lanham.
Table of Contents
Part 1 – Getting Started with Unreal C++
Scripting
1
Creating Your First Unreal C++ Game 3
Technical requirements 3 Ensuring your UE has the source code installed 9
Understanding C++ scripting in Unreal 4 Launching the UE5 editor through the Epic
Games Launcher 10
What is the difference between C++ and
Creating the MyShooter C++ project 10
Blueprint?4
Associating VS with UE5 as the default source
When do you use C++? 5
code editor 12
What is the difference between C++
Opening the C++ source code in VS (optional) 13
programming and C++ scripting? 5
2
Editing C++ Code in Visual Studio 21
Technical requirements 21 Solution Explorer 26
Launching VS 22 Output window 27
Error List window 28
Walking through the VS IDE’s UI 24
Code editor 25 Editing code in VS 29
Menus26 Controlling the caret (input cursor) 30
Search box 26 The text editing keys 30
Toolbar26 Code selection 30
viii Table of Contents
3
Learning C++ and Object-Oriented Programming 43
Technical requirements 44 Working on the improved calculator
What is C++? 44 program66
Exploring the C++ program structure 45 Creating references and pointers 72
Defining C++ functions 46 References73
Pointers74
Defining functions with or without parameters 47
Calling functions 47 Understanding OOP 74
Writing the main() function 47 What is OOP? 75
Working with a basic calculator What are classes and objects? 75
program48 Creating classes in C++ 76
Creating objects in C++ 77
Learning the C++ syntax 49
Using the C++ data types 50 Working on an OOP calculator
Defining variables 51 program78
Using C++ arrays 52 Adding constructor and getter functions for
Using C++ operators 53 the calculator class 83
Accepting user input 57 Creating the CalculatorEx class, which
Adding C++ comments 57 inherits from the Calculator class 84
Controlling the C++ flow 58 Summary88
4
Investigating the Shooter Game’s Generated Project and C++ Code 89
Technical requirements 89 Getting familiar with the source code 95
Understanding the MyShooter C++ MyShooterCharacter.h95
project structure 90 MyShooterCharacter.cpp100
Understanding the game program MyShooterProjectile.h and
structure92 MyShooterProjectile.cpp103
Table of Contents ix
Using the UFUNCTION macro 132 Using the Cast template function 145
The UFUNCTION syntax 132 Summary147
UFUNCTION specifiers and metadata keys 132
Tagging ADefenseTower and APlayerAvatar
member functions as UFUNCTION macros 133
6
Creating Game Actors 149
Technical requirements 149 Replacing the game’s player pawn 160
Setting up the player avatar 150 Creating the player avatar’s
Adding SpringArmComponent and animation blueprint 162
CameraComponent to PlayerAvatar 150 Creating the PlayerAvatarAnimInstance class 163
Initializing the player avatar 154 Creating the ABP_PlayerAvatar blueprint 169
Setting up the character’s Creating the State Machine on ABP_
SkeletalMeshComponent155 PlayerAvatar171
Syncing the movement speed with the
Importing the character model 155
animation instance 174
Using the Hero skeletal mesh in BP_
PlayerAvatar160 Summary176
7
Controlling Characters 179
Technical requirements 180 Implementing the OnStateAnimationEnds
function186
Controlling the player character to
attack180 Destroying actors 187
Adding the Attack action to the action map 180 Creating the enemy character 189
Binding the handler function to the Attack Creating the Enemy class 190
action181
Creating the EnemyController class 195
Implementing the OnAttackPressed() action
Creating the ABP_Enemy animation blueprint 200
handler function 182
Creating the BP_Enemy blueprint 201
Implementing the CanAttack() and Attack()
functions182 Testing the game 203
Processing non-loop animations 184 Summary204
8
Handling Collisions 205
Technical requirements 205 Using collisions for game interactions213
Understanding collision detection 206 Downloading and creating the weapon,
defense tower, and fireball actors 214
Setting the collision presets 210
Table of Contents xi
9
Improving C++ Code Quality 239
Technical requirements 239 Creating a fireball pool 256
Refactoring code 240 Outputting debug messages 263
Combining the PlayerAvatarAnimInstance Using the UE_LOG macro 264
and EnemyAnimInstance classes 240 Printing debug messages to the screen 265
Making PangaeaCharacter the parent class of
APlayerAvatar and AEnemy 243 Checking an Actor instance’s actual
class type 266
Refining code 255
Summary269
Using caching variables 255
11
Controlling the Game Flow 295
Technical requirements 295 Adding the Timer variable to the
APangaeaGameState class 313
Designing the Pangaea game’s flow 296
Making the Timer variable replicable 314
Creating the UI widgets 297
Defining OnTimeChangedDelegate 314
Creating BP_LobbyWidget 298
Creating and binding the custom event to
Creating BP_HUDWidget 301 OnTimeChangedDelegate315
Creating BP_GameOverWidget 303 Counting down the timer 317
Adding networking functions to Designating APangaeaGameState as the
PangaeaGameInstance306 project’s game state class 319
12
Polishing and Packaging the Game 327
Technical requirements 327 Packaging the game 338
Polishing the game 328 Configuring the project settings for packaging 338
Importing and using high-quality game assets 328 Making the build a windowed game 340
Fixing bugs 331 Avoiding the hardcoded path for finding
Profiling and optimization 331 content341
Packaging the project 344
Using Unreal Engine console
commands332 What to do next 347
Exploring modes and console commands 332 Summary348
Executing console commands in C++ 336
Index349
As an Unreal Engine developer, you may have a genuine interest in understanding C++ and how it
integrates with the engine, even if you don’t identify as a software engineer or aspire to become one.
This book is designed to assist you in expanding your knowledge and skills by guiding you through
the necessary steps to create a fully fledged game, covering essential aspects of game development. It
aims to smoothen the learning curve, allowing for a more seamless and efficient grasp of the concepts
presented. The carefully organized topics eliminate the need for random searching and prevent wasted
time on unrelated readings, enabling you to focus on the relevant information. Moreover, this book
serves as a valuable reference manual, offering a comprehensive resource that can be revisited and
utilized for further study.
• Non-engineer game developers, such as game designers and artists who aspire to learn and
comprehend C++ in the context of Unreal Engine development
• Software engineers who may lack prior experience in Unreal Engine C++ programming but
wish to quickly acquire the necessary skills for their next project or job
• Students who are interested in learning and digging into Unreal C++ programming for their
study or personal projects
• Individuals with a keen interest in game development using Unreal Engine will benefit from
the comprehensive knowledge presented within these pages
In the autumn of 1328, Ivan went to the Horde to report that the
Khan’s demand was accomplished. With him were the Novgorod
envoys and Feodor Kolenitsa, their chief man, also Constantine, the
Tver prince. Uzbek met all very graciously, and received Ivan with
much honor. He gave him the Grand Principality, adding lands also
to Moscow, and granting everything that the prince asked for; he
gratified Kolenitsa as well. But he commanded them all to the last
man to seek out Alexander and bring him to the Horde to receive the
Khan’s sentence.
After the countless quarrels between princes, and the Mongol raids
which did not cease for even one year during five decades after the
death of Alexander Nevski, the peace which now began, when
Nevski’s grandson, Ivan, became Grand Prince of Vladimir, must
have seemed a miracle. And for many a day it remained in the minds
of the people as a wonderful benefaction. This lasting peace was the
great event of Ivan’s reign. All knew that he had Uzbek’s confidence.
Russian princes saw that the Khan granted whatever Ivan asked of
him. They saw this even before, but when Constantine, brother of
the fugitive Alexander, was confirmed in Tver through Ivan’s
influence, all were convinced of Uzbek’s friendship for him, none
more firmly than the Novgorod envoys, who had visited the Horde
with the Grand Prince.
In 1328, upon his return from Sarai, Ivan and the other princes met
in Novgorod, for they had to find Alexander. They decided to send
envoys to that prince, and say, “The Khan summons thee to
judgment; wilt thou suffer for the Russian land like a warrior of Christ,
or survive alone, and give the whole Russian land to destruction?”
The envoys returned with the declaration that the Pskoff men would
not yield Alexander. They had agreed and kissed the cross not to
forsake him. He and they would stand or fall in one company. The
princes moved now on Pskoff with strong forces. Besides Ivan’s
army, he commanded Tver troops with the troops of other princes,
and men of Novgorod also. Wishing no harm to Pskoff, he pitched
his camp at some distance [315]and negotiated. He sent the
Novgorod bishop with the Novgorod commander to the prince, and
strove to act with kindness. Alexander was moved to tears and
answered that he was willing to stand before Uzbek, but the Pskoff
men swore that they would not allow him to go from their city.
Alexander sent this message from himself: “It is better that I die for
all, than that all should perish for me. But ye might defend your own
brothers and not yield them to pagans. Ye do just the opposite, and
with you ye bring Mongols.”
“It is impossible to take the prince from Pskoff or drive him from the
city.” These words were current in the camp of the allies. Ivan knew
much more of the true state of affairs than could be gathered from
camp reports, or the words of Alexander. He knew that Pskoff hoped
to be independent of Novgorod, that it wished for its own prince, and
thought that it had one now in Alexander. He knew also that Livonia
supported the city in secret, understanding well that if alone it would
be weaker and more easily subjected, while Lithuania supported
Pskoff openly and roused the city to resistance. Alexander,
consciously or not, was the helper of Gedimin. Ivan knew, perhaps,
of a treaty made by Pskoff and Alexander with Livonia. “The
Germans are near them, and they expect aid from them,” said Ivan
in council. It was difficult for him to act. In those straits he
remembered that when Yuri, his brother, was struggling with Tver,
Maxim, the metropolitan, made peace at the outset. There was still
another case, even more memorable. At the time when Dmitri of the
Terrible Eyes, intending to war against Yuri, was leading his troops to
Nizni, and had reached Vladimir, Pyotr, the bishop, stopped him by
refusing to give him his blessing, and Dmitri, after waiting three
weeks, returned home without meeting Yuri. Ivan turned now to
Feognost, the metropolitan, and begged for his assistance.
Thus Ivan was the first Moscow prince who gave peace to Pskoff in
the old fashion, as he would to his own principality. The metropolitan
blessed the Pskoff people, and Ivan marched homeward with the
princes. After Ivan had reached Moscow, Gedimin proposed that
Novgorod should take as prince his son Narimont, and give him
Oraihovo and Ladoga, with a part of Karelia, as inheritance. Moscow
learned then for the first time that since Ivan had left Pskoff,
Alexander had returned, and was prince there, supported by
Gedimin. It was not this return alone which roused Novgorod, but the
treason of the Pskoff men. The city had accepted Alexander as
prince from Lithuania, and were striving now for church separation.
When Vassili, the new archbishop, went from Novgorod for
ordination, Gedimin of Lithuania and Alexander of Pskoff sent
envoys to Feognost, Metropolitan of Russia, then in Volynia. These
envoys took with them Arseni to be bishop in Pskoff. Gedimin had
given Pskoff a prince in Alexander, and would now give a bishop.
Feognost ordained Vassili as Archbishop of Novgorod, but refused to
ordain Arseni, and Alexander’s envoys returned without a bishop.
Gedimin, enraged by the Novgorod success, and the failure of
Arseni, sent men to seize Vassili, but, warned by a messenger from
Feognost, he escaped the Lithuanians, and returned in safety to
Novgorod.
Besides having the Khan’s confidence, Ivan was strong through the
tribute. No other Grand Prince had given the Khan such an income;
and no prince held such uncontrolled management of tribute. This
gave Ivan unique power and position. Of all princes in that day he
was the only one, or at least the only one known to us, who had a
fixed object. He took no part in local quarrels in favor of one or
another region. He strove for Russia, and when prince only in
Moscow he saw all Russia far in the future. This was clearly shown
in his every act, not merely in the title which he assumed, “Grand
Prince of Moscow and All Russia,” but in his relations with other
princes and with Novgorod, and even with Uzbek. To preserve the
Russian land in its integrity was, by the very working of fate, to
preserve the Khan’s lordship, and support it for a season. There is
no doubt that Ivan explained always to Uzbek the harmful growth of
Lithuania, and as he himself warred with that power, so he roused
Uzbek to war with it. He showed the Khan, too, the immense wealth
of Novgorod in the distant lands of the East and the Pechora, to
which Novgorod admitted no Grand Prince. Uzbek rewarded and
honored his untiring assistant, and Ivan all the more easily reached
his object, calling himself with deep reason Grand Prince, not of
Moscow alone, but of all Russia.
The boyars of Novgorod not only considered that they had a right to
invite a prince from Lithuania, but apparently they were ready to
place Novgorod under Lithuanian protection, if thus they could keep
independent of other princes, and preserve to their city those rich,
boundless lands on the north and the east.
Ivan would not admit for a moment that they had the right to call in a
foreign prince, or owned exclusively those lands which they claimed
for their own.
In 1332, when returning from the Horde, Ivan made a demand in the
name of the Khan to which the people of Novgorod gave a stern
refusal. He insisted, and to make sure of their compliance he seized
the Upper Baijets and Torjok immediately. From that began a long
quarrel. At times Novgorod seemed to yield, and the quarrel
apparently ceased; again it would blaze up on the city’s renewed
refusal. Thus the dispute continued during Ivan’s reign.
The main cause of the dispute was the silver beyond the Ural
Mountains. Ivan demanded from Novgorod an income from places
claimed by the city, no part of which income should go to any prince
ruling in Novgorod. He wished to extend taxes over all Novgorod
possessions to the boundaries of Siberia. [319]
At that time Novgorod had entered into friendship with Lithuania, and
Narimont, son of Gedimin, had arrived in the city. Novgorod received
him with gladness, and gave him Ladoga with Oraihova and Karelia
in part as a portion. In view of these acts Ivan went to Sarai, and
when he came back it was stated that he had been shown great
honor, and had gained large accessions of power while with Uzbek.
This alarmed Novgorod. During Ivan’s absence the Novgorod
archbishop had gone on a visit to Moscow, bearing gifts from the city
to the metropolitan, who had just come from Tsargrad. The
archbishop begged the metropolitan to speak with Ivan about
Novgorod. This intercession succeeded, for when envoys arrived in
Moscow and invited Ivan to Novgorod, he set aside his dislike for the
city, entered Novgorod February 16, 1335, and was received there in
triumph. They offered to add all their forces to his, and fall upon
Pskoff if he so ordered. But he would not attack Pskoff at that period;
he accepted their service, however, and marched on Lithuania. His
forces, and those of the city, took towns in good number, and though
this Lithuanian campaign was not the most important in conquest, it
was in agreement.
Ivan purchased from poor princes not only villages, but towns such
as Uglitch, Bailozersk, and Galitch beyond the Volga, and thus
increased his inheritance unceasingly. He also bought from boyars
and monasteries, and exchanged with them. He received presents of
land and property through wills of friends and relatives. With the
wealth which belonged to him personally, and that which pertained to
his office, he was able to meet all possible demands.
Responsible to the Khan for Russian tribute, and paying this tribute
at regular intervals, he frequently had to pay for princes who lacked
ready money. Of these some grew insolvent and paid him with land.
All, in greater or less degree, were dependent upon him; all in fact
needed his protection. Without regard to the [321]murmurs of
Novgorod boyars, he bought towns and villages in Novgorod regions
continually. So, extending power from his capital always with the
rights of a Grand Prince, to which he knew how to give proper
emphasis, he was strong at all points, and for many reasons.
Consequently boyars and warriors of weakening principalities went
gladly to the service of Moscow.
For a moment Uzbek was dumb from astonishment, and all present
wondered. Alexander was kneeling with bowed head, and in silence.
“See ye,” said Uzbek at last, “how with obedient wisdom Alexander
has saved himself.” The Khan pardoned him straightway, gave him
back the Tver principality, and sent him home without injury.
Ivan went now to the Horde. This visit of his to Uzbek produced on
all a peculiar impression. He took with him his eldest and second
sons, Simeon and Ivan; the youngest, Andrei, he sent to Novgorod.
This sending of a son to Novgorod was not without special meaning.
Ivan had remained two years, not in peace, not in war with the city.
Lord Novgorod had not met his demands, and he had not dropped
them. By sending Andrei to the city at this juncture, Ivan reminded
Novgorod men once again that he looked on their capital as his
inheritance.
Ivan came back from the Horde with added power and new honor.
All princes were placed under his hand still more firmly. It became
known very quickly that, owing to Ivan’s suggestion, [323]the princes
were summoned to Sarai to receive the Khan’s commands.
Alexander knew that now he must go, and that he would never again
see Tver. He sent quickly to his son for any information which he
might have regarding the affair. The tidings which came back were
woeful and he hesitated. An envoy now came to Alexander from the
Khan promising him favor, but at the same time reminding him that
his son was held as hostage. If a year before the Tver prince had
hastened to the Horde when he himself was in danger, he hastened
all the more now when Feodor was threatened.
Meanwhile Ivan had gone to Sarai still a second time, and taken with
him his three sons. Before Alexander’s arrival at the Horde Ivan was
back in Moscow, but his sons had wished to remain with the Khan.
That winter Ivan’s three sons were sent home in high favor. By
command of “the Godless Uzbek,” adds the chronicler, “the following
princes were put to death during that winter: Feodor of Starodub,
Ivan and Vassili of Ryazan, and Alexander Novosilski.”
Six months had not passed after the death of Alexander and his son,
when Ivan died, March 31, 1340, being about fifty years of age. He
died before his time, and perhaps unexpectedly, but he was able to
go to Spasski, his favorite monastery, and put on the monk’s habit.
He was buried in the Archangel Cathedral, his tomb being the first in
that series of Moscow sovereigns, his descendants.
During 1340 died Ivan Kalitá, Gedimin, and Uzbek Khan of the
Golden Horde, three men who left profound traces in Russia.
In 1252, Mindog sent Vykint, his uncle, and two nephews, Tovtivil
and Edivil, to attack Smolensk places, and to ravage the country.
“Let each of you keep what he wins,” said he at parting. But these
words were used simply to mislead and deceive his three relatives.
As soon as they had gone, Mindog seized their possessions, and
sent warriors to follow and kill them. They heard of this treachery in
season, and took refuge quickly with Daniel, who had married the
sister of Tovtivil and Edivil. Mindog sent at once to Daniel, asking him
not to assist them, but Daniel paid no heed to this message; first
through regard for his wife’s brothers and her uncle, and second
because he wished to weaken Mindog and his people. After
counseling with Vassilko, Daniel formed a plan. He sent to Polish
princes this message: “It is time for us to fall upon pagans, since
they are warring against one another.” He sent similar messages to
the Yatvyags, to Jmud, and to the Germans in Riga. [326]
Vykint, Daniel’s envoy, roused the Yatvyags, and half the Jmud
region. The Germans sent this answer to Daniel: “Though Vykint, thy
relative, has killed many of our men, we have made peace with him,
and will assist you.” The brothers now set out to make war in
earnest. Daniel sent Vassilko to Volkovisk, his son to Slonim, and
then marched to Zditov. They captured many towns and returned to
Galitch well satisfied. After that, he sent Tovtivil with Russians and
Polovtsi against Mindog. The Germans made no move whatever,
until Tovtivil went to Riga, where he received baptism from them;
then they made ready for action.
Mindog saw that he could not meet two foes in one conflict. He could
not war with the Germans and Daniel of Galitch at the same time.
Hence he sent secretly rich gifts to the Grand Master Von
Schtükland, and the following proposal: “If thou kill Tovtivil or expel
him, thou wilt get still greater gifts from me.” Von Schtükland replied
that he felt immense friendship for Mindog, but could give no aid till
baptism had changed him. Mindog asked for a meeting, which was
granted, and he settled the question while feasting with Von
Schtükland. The Lithuanian prince was to be baptized. On hearing
this news, the Pope was delighted, and wrote to the bishop that no
one should offend the new convert. The Bishop of Culm was to
crown him.
During 1252, the war was not marked by notable action, but in 1253
Daniel took part in it personally, and with such success that Mindog
asked for peace. He offered his daughter to Daniel’s son, Svaromir,
and found still other means of persuasion.
Tovtivil declared now that Mindog had bribed the Yatvyags, who
refused to assist Daniel longer. Daniel was enraged at the Yatvyags,
but that could not serve him. Two years passed. In 1255, there was
peace between Daniel of Galitch and Mindog’s son, Voishelk.
Voishelk was a man greatly noted, even in that [327]time of
bloodshed. Mindog was cruel and terrible, but Voishelk surpassed
him, if the annalist is truthful. Voishelk shed blood from his youth up.
“Every day he killed three or four men for amusement. When his time
passed without bloodshed, he was sad, and when he had killed a
man, good feeling returned to him.”
All at once news came of Voishelk’s baptism; nay, more, it was said
that he had left ruling, and had put on a monk’s habit. This man now
appeared as a peacemaker between Daniel and Mindog. The
conditions seemed so favorable that Daniel did not reject them.
Daniel’s son, Svaromir (familiarly Shvarn), was to marry Mindog’s
daughter; Shvarn’s elder brother, Roman, was to have Novgrodek
from Mindog, and Daniel was to get Slonim and Volkovisk from
Voishelk, on condition of recognizing Mindog as his superior in those
places.
Mindog had promised the Order to accept its religion for himself and
all the people under him. He was to receive the friendship of the
Order, and the kingly office as a reward. In exchange, he was to give
the Order various places in Jmud, those same places where there
had been such terrible bloodshed because of newcomers fleeing
from Prussia. The friendship seemed to be made for the ages, and a
speedy union of the two lands appeared imminent. In case that he
had no heir, Mindog agreed to give his kingdom to Livonia, now of
one faith with him.
The Bishop of Culm came with priests and monks; the Grand Master
with knights of the Order. Mindog was christened, anointed, and
crowned at Novgrodek. Pope Innocent IV in 1255 blessed the new
convert to war against Russia and its inhabitants who were
schismatic, and confirmed in advance to him all regions which he
might join to his kingdom.
He did not cease to observe the ancient rites of his people; he made
sacrifices to their deities, but for him that was not sufficient. He was
a shrewd leader of men; he had also learned the policy of Germans.
It was necessary to fire the hearts of his people, and to purify himself
perfectly from any taint of German religion, hence before Lithuanians
he ridiculed his own pretended conversion.