| 295 | esv::StatusMachine * GetStatusMachine(char const * gameObjectGuid); |
| 296 | |
| 297 | esv::StatusHit * DamageHelpers::Execute() |
| 298 | { |
| 299 | if (!Target) { |
| 300 | OsiError("No target!"); |
| 301 | return false; |
| 302 | } |
| 303 | |
| 304 | if (DamageList->Size == 0) { |
| 305 | OsiError("At least one damage type should be added!"); |
| 306 | return false; |
| 307 | } |
| 308 | |
| 309 | auto characterHit = gOsirisProxy->GetLibraryManager().CharacterHit; |
| 310 | if (CallCharacterHit && characterHit == nullptr) { |
| 311 | OsiError("esv::Character::Hit not found!"); |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | auto statusMachine = GetStatusMachine(Target->GetGuid()->Str); |
| 316 | if (!statusMachine) { |
| 317 | OsiError("Target has no StatusMachine!"); |
| 318 | return false; |
| 319 | } |
| 320 | |
| 321 | auto createStatus = gOsirisProxy->GetLibraryManager().StatusMachineCreateStatus; |
| 322 | auto applyStatus = gOsirisProxy->GetLibraryManager().StatusMachineApplyStatus; |
| 323 | if (createStatus == nullptr || applyStatus == nullptr) { |
| 324 | OsiError("esv::StatusMachine::CreateStatus not found!"); |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | auto fsHit = ToFixedString("HIT"); |
| 329 | auto hit = (esv::StatusHit *)createStatus(statusMachine, fsHit, 0); |
| 330 | |
| 331 | hit->StartTimer = 0.0f; |
| 332 | hit->HitByHandle = ObjectHandle{}; |
| 333 | hit->HitWithHandle = ObjectHandle{}; // FIXME? |
| 334 | hit->WeaponHandle = ObjectHandle{}; // FIXME? |
| 335 | hit->HitReason = HitReason; |
| 336 | hit->Flags0 &= 0xFB; // Clear IsFromItem |
| 337 | |
| 338 | if (SkillId) { |
| 339 | hit->SkillId = SkillId; |
| 340 | } else { |
| 341 | hit->SkillId = ToFixedString(""); |
| 342 | } |
| 343 | |
| 344 | hit->Strength = Strength; |
| 345 | hit->DamageSourceType = DamageSourceType; |
| 346 | hit->StatusSourceHandle = ObjectHandle{}; |
| 347 | |
| 348 | if (Source != nullptr) { |
| 349 | ObjectHandle sourceHandle; |
| 350 | Source->GetObjectHandle(&sourceHandle); |
| 351 | hit->HitByHandle = sourceHandle; |
| 352 | hit->StatusSourceHandle = sourceHandle; |
| 353 | } |
| 354 |
no test coverage detected