Advertisement
alaestor

ZMyCharacter.cpp OnDelayedWork - Angle and Phase

Sep 22nd, 2019
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. // commented to point out logic related to angle and phase
  2.  
  3. void ZMyCharacter::OnDelayedWork(ZDELAYEDWORKITEM *pItem)
  4. {
  5.     ZMyCharaterStatusBitPacking & zStatus = m_statusFlags.Ref();
  6.  
  7.     switch(pItem->nWork) {
  8.     case ZDW_SHOT :
  9.         {
  10.             for (ZCharacterManager::iterator itor = ZGetCharacterManager()->begin();
  11.                 itor != ZGetCharacterManager()->end(); ++itor)
  12.             {
  13.                 ZCharacter* pTar = (*itor).second;
  14.                 if (this == pTar || pTar->IsDie()) continue;
  15.  
  16.                 // pos + look direction * offset so slash doesnt occur behind you
  17.                 // in very early versions, slash originated behind character;
  18.                 // tipslash was much harder but you could "phase" slashes
  19.                 // by aiming away from your enemy because the slash would
  20.                 // originate behind their block, hitting their back
  21.                 rvector diff = GetPosition() + m_Direction * 10.f - pTar->GetPosition();
  22.                 diff.z *= .5f;
  23.                 float fDist = Magnitude(diff);
  24.  
  25.                 // within recoil (and massive) range
  26.                 if (fDist < 200.0f)
  27.                 {
  28.                     bool bCheck = false;
  29.                     if (ZGetGame()->GetMatch()->IsTeamPlay())
  30.                     {
  31.                         if(IsTeam(pTar) == false)
  32.                             bCheck = true;
  33.                     }
  34.                     else bCheck = true;
  35.  
  36.                     // collision check
  37.                     if (ZGetGame()->CheckWall(this,pTar)==true)
  38.                         bCheck = false;
  39.  
  40.                     // this section is what is responsible for Angle and Phase
  41.                     if (bCheck)
  42.                     {
  43.                         rvector fTarDir = pTar->GetPosition() - GetPosition();
  44.                         Normalize(fTarDir);
  45.                         float fDot = D3DXVec3Dot(&m_Direction, &fTarDir);
  46.                         if (fDot > 0.1 && DotProduct(m_Direction, pTar->m_Direction) < 0)
  47.                         { // if looking in the direction of the attack
  48.                             if (pTar->IsGuard()) // if blocking
  49.                                 ShotBlocked(); // no damage
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.         break;
  56.     case ZDW_UPPERCUT :
  57.         // logic for flipping
  58.     case ZDW_DASH :
  59.         // dash logic?
  60.     case ZDW_SLASH:
  61.         // something about "splashshot", I believe is something to do with executing a massive
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement