| 347 | } |
| 348 | |
| 349 | bool Summon(OsiArgumentDesc & args) |
| 350 | { |
| 351 | auto character = FindCharacterByNameGuid(args[0].String); |
| 352 | if (character == nullptr) { |
| 353 | OsiError("Character '" << args[0].String << "' does not exist!"); |
| 354 | return false; |
| 355 | } |
| 356 | |
| 357 | auto objectTemplate = NameGuidToFixedString(args[1].String); |
| 358 | if (!objectTemplate) { |
| 359 | OsiError("Template '" << args[1].String << "' not in FixedString table!"); |
| 360 | return false; |
| 361 | } |
| 362 | |
| 363 | auto const & lib = gOsirisProxy->GetLibraryManager(); |
| 364 | if (lib.SummonHelpersSummon == nullptr) { |
| 365 | OsiError("Summon helper symbols not available in library manager"); |
| 366 | return false; |
| 367 | } |
| 368 | |
| 369 | auto pos = args.GetVector(2); |
| 370 | auto lifetime = args[5].Float; |
| 371 | auto summonLevel = args[6].Int32; |
| 372 | auto isTotem = args[7].Int32 != 0; |
| 373 | auto mapToAiGrid = args[8].Int32 != 0; |
| 374 | |
| 375 | if (pos.x == -1.0f && pos.y == -1.0f && pos.z == -1.0f) { |
| 376 | pos = character->WorldPos; |
| 377 | } |
| 378 | |
| 379 | esv::SummonHelperResults results; |
| 380 | esv::SummonHelperSummonArgs summonArgs; |
| 381 | |
| 382 | ObjectHandle characterHandle; |
| 383 | character->GetObjectHandle(&characterHandle); |
| 384 | summonArgs.OwnerCharacterHandle = characterHandle; |
| 385 | summonArgs.GameObjectTemplateFS = objectTemplate; |
| 386 | summonArgs.Level = *character->GetCurrentLevel(); |
| 387 | summonArgs.Position = pos; |
| 388 | summonArgs.SummonLevel = summonLevel; |
| 389 | summonArgs.Lifetime = lifetime; |
| 390 | summonArgs.IsTotem = isTotem; |
| 391 | summonArgs.MapToAiGrid = mapToAiGrid; |
| 392 | |
| 393 | lib.SummonHelpersSummon(&results, &summonArgs); |
| 394 | if (results.SummonHandle) { |
| 395 | FixedString guid; |
| 396 | |
| 397 | auto summonCharacter = FindCharacterByHandle(results.SummonHandle); |
| 398 | if (summonCharacter != nullptr) { |
| 399 | guid = *summonCharacter->GetGuid(); |
| 400 | } |
| 401 | else { |
| 402 | auto summonItem = FindItemByHandle(results.SummonHandle); |
| 403 | if (summonItem != nullptr) { |
| 404 | guid = *summonItem->GetGuid(); |
| 405 | } |
| 406 | } |
nothing calls this directly
no test coverage detected