| 365 | |
| 366 | |
| 367 | bool ApplyDamageOnMove(OsiArgumentDesc & args) |
| 368 | { |
| 369 | auto characterGuid = args[0].String; |
| 370 | auto statusId = args[1].String; |
| 371 | auto sourceCharacterGuid = args[2].String; |
| 372 | auto lifeTime = args[3].Float; |
| 373 | auto distancePerDamage = args[4].Float; |
| 374 | |
| 375 | auto character = FindCharacterByNameGuid(characterGuid); |
| 376 | if (character == nullptr) { |
| 377 | OsiError("Character " << characterGuid << " does not exist!"); |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | auto statusMachine = character->StatusMachine; |
| 382 | if (!statusMachine) { |
| 383 | OsiError("Character has no StatusMachine!"); |
| 384 | return false; |
| 385 | } |
| 386 | |
| 387 | if (distancePerDamage <= 0.01) { |
| 388 | OsiError("DistancePerDamage must be a positive value!"); |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | auto applyStatus = gOsirisProxy->GetLibraryManager().StatusMachineApplyStatus; |
| 393 | if (applyStatus == nullptr) { |
| 394 | OsiError("esv::StatusMachine::ApplyStatus not found!"); |
| 395 | return false; |
| 396 | } |
| 397 | |
| 398 | auto status = ConstructStatus<esv::StatusDamageOnMove>(statusMachine, statusId, StatusType::DamageOnMove); |
| 399 | if (status == nullptr) { |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | if (lifeTime < 0.0f) { |
| 404 | status->Flags0 |= SF0_KeepAlive; |
| 405 | status->CurrentLifeTime = 1.0f; |
| 406 | } else { |
| 407 | status->Flags0 |= SF0_IsLifeTimeSet; |
| 408 | status->LifeTime = lifeTime; |
| 409 | status->CurrentLifeTime = lifeTime; |
| 410 | } |
| 411 | |
| 412 | auto sourceCharacter = FindCharacterByNameGuid(sourceCharacterGuid); |
| 413 | if (sourceCharacter == nullptr) { |
| 414 | status->StatusSourceHandle = ObjectHandle{}; |
| 415 | } else { |
| 416 | ObjectHandle sourceHandle; |
| 417 | sourceCharacter->GetObjectHandle(&sourceHandle); |
| 418 | status->StatusSourceHandle = sourceHandle; |
| 419 | } |
| 420 | |
| 421 | status->StartTimer = 0.0f; |
| 422 | status->StatsMultiplier = 1.0f; |
| 423 | status->DistancePerDamage = distancePerDamage; |
| 424 |
nothing calls this directly
no test coverage detected