亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chars.cpp

?? 3D游戲引擎 Programming Role-Playing Games with DirectX, 2nd Edition by Jim Adams
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
                            Character->TargetChar->YPos);
        ZDiff = (float)fabs(Character->ZPos -                 \
                            Character->TargetChar->ZPos);
        Dist = XDiff*XDiff + YDiff*YDiff + ZDiff*ZDiff;

        // Update if closer then distance
        if(Dist < (Character->Distance*Character->Distance)) {

          // Setup movement away from target
          Dist = (float)sqrt(Dist);
          if(Speed > Dist)
            Speed = Dist;
          MoveX = -(Character->TargetChar->XPos -             \
                 Character->XPos) / Dist * Speed;
          MoveZ = -(Character->TargetChar->ZPos -             \
                 Character->ZPos) / Dist * Speed;

          // Set new direction
          Character->Direction = (float)atan2(MoveX, MoveZ);

          // Set new action
          Character->Action = CHAR_MOVE;
        }
      }

      break;
  }

  // Process monster actions if at full charge
  if(Character->Type == CHAR_MONSTER &&                       \
                                Character->Charge >= 100.0f) {

    // Determine chance of attacking
    if((rand() % 100) <= Character->Def.ToAttack) {
      // Scan through list and pick a character
      CharPtr = m_CharacterParent;
      while(CharPtr != NULL) {
        // Randomly pick enabled target (a PC),
        // and make sure the target is not hurt or dead.
        if(CharPtr != Character && CharPtr->Type==CHAR_PC &&  \
           (rand() % 100) < 50 &&                             \
           CharPtr->Enabled == TRUE &&                        \
           CharPtr->Action != CHAR_DIE &&                     \
           CharPtr->Action != CHAR_HURT) {

          // Get distance to target
          XDiff = (float)fabs(Character->XPos - CharPtr->XPos);
          YDiff = (float)fabs(Character->YPos - CharPtr->YPos);
          ZDiff = (float)fabs(Character->ZPos - CharPtr->ZPos);
          Dist  = XDiff * XDiff + YDiff * YDiff + ZDiff * ZDiff;

          // Make sure in range to attack
          Radius = GetXZRadius(Character);
          Radius += Character->Def.Range;

          // Attack if in range
          if((Radius*Radius) >= Dist) {
            // Set attack data
            Character->Victim = CharPtr;
            CharPtr->Attacker = Character;

            // Clear movement
            MoveX = MoveY = MoveZ = 0.0f;

            // Point towards target character
            XDiff = CharPtr->XPos - Character->XPos;
            ZDiff = CharPtr->ZPos - Character->ZPos;
            Character->Direction = (float)atan2(XDiff, ZDiff);

            // Perform attack action
            SetAction(Character, CHAR_ATTACK);

            break;
          }
        }

        // Go to next character
        CharPtr = CharPtr->Next;
      }
    } else

    // Determine chance of spell casting
    if((rand() % 100) <= Character->Def.ToMagic &&            \
                 m_MSL != NULL && m_SpellController != NULL) {

      // Flag no spells cast
      SpellCast = FALSE;

      // If health is less then half, then there's a 50% chance
      // of healing (if the monster knows any heal spells)
      if(Character->HealthPoints <=                           \
                          (Character->Def.HealthPoints / 2)) {

        // Search for a known heal spell
        for(i=0;i<64;i++) {
          if(m_MSL[i].Name[0] &&                              \
             m_MSL[i].Effect == ALTER_HEALTH &&               \
             m_MSL[i].Value[0] > 0.0f &&                      \
             Character->ManaPoints >= m_MSL[i].Cost &&        \
             Character->Def.MagicSpells[i/32] & (1<<(i&31))) {

            // This is the spell, determine chance to heal
            if((rand() % 100) < 50) {
              // Set spell data
              Character->Victim      = Character;
              Character->Attacker    = Character;
              Character->SpellNum    = i;
              Character->SpellTarget = CHAR_MONSTER;
              
              // Store target coordinates
              Character->TargetX = Character->XPos;
              Character->TargetY = Character->YPos;
              Character->TargetZ = Character->ZPos;

              // Clear movement
              MoveX = MoveY = MoveZ = 0.0f;

              // Perform spell action
              SetAction(Character, CHAR_SPELL);

              // Flag spell as cast
              SpellCast = TRUE;

              break;
            }
          }
        }
      }

      // If there are bad status ailments, then there's a 
      // 50% chance of dispeling magic.
      if(Character->Ailments & AILMENT_POISON ||              \
         Character->Ailments & AILMENT_SLEEP ||               \
         Character->Ailments & AILMENT_PARALYZE ||            \
         Character->Ailments & AILMENT_ENCHANTED ||           \
         Character->Ailments & AILMENT_DUMBFOUNDED ||         \
         Character->Ailments & AILMENT_SLOW ||                \
         Character->Ailments & AILMENT_BLIND ||               \
         Character->Ailments & AILMENT_SILENCED &&            \
         SpellCast == FALSE) {
        
        // Search for a known dispel spell
        for(i=0;i<64;i++) {
          if(m_MSL[i].Name[0] &&                              \
             m_MSL[i].Effect == DISPEL_MAGIC &&               \
             Character->ManaPoints >= m_MSL[i].Cost &&        \
             Character->Def.MagicSpells[i/32] & (1<<(i&31))) {

            // This is the spell, determine chance to dispel
            if((rand() % 100) < 50) {
              // Set spell data
              Character->Victim      = Character;
              Character->Attacker    = Character;
              Character->SpellNum    = i;
              Character->SpellTarget = CHAR_MONSTER;
              
              // Store target coordinates
              Character->TargetX = Character->XPos;
              Character->TargetY = Character->YPos;
              Character->TargetZ = Character->ZPos;

              // Clear movement
              MoveX = MoveY = MoveZ = 0.0f;

              // Perform spell action
              SetAction(Character, CHAR_SPELL);

              // Flag spell as cast
              SpellCast = TRUE;

              break;
            }
          }
        }
      } 

      // If now spells already cast, then pick a random one
      if(SpellCast == FALSE) {

        // Pick a random spell to attack with
        SpellNum = rand() % 64;

        // Scan through list until a spell is found the
        // monster can cast.
        for(i=0;i<64;i++) {
          if(m_MSL[SpellNum].Name[0] &&                       \
             Character->Def.MagicSpells[SpellNum / 32] &      \
                                   (1 << (SpellNum & 31)) &&  \
             Character->ManaPoints >= m_MSL[SpellNum].Cost && \
             (rand() % 100) < 50) {

            // Scan through list and pick a character
            CharPtr = m_CharacterParent;
            while(CharPtr != NULL) {

              // Randomly pick an enabled target (a PC), 
              // and make sure the target is not hurt or dead.
              // Also, don't cast self-targeting spells here.
              if(CharPtr != Character &&                      \
                 CharPtr->Type == CHAR_PC &&                  \
                 m_MSL[SpellNum].Target != TARGET_SELF &&     \
                 (rand() % 100) < 50 &&                       \
                 CharPtr->Enabled == TRUE &&                  \
                 CharPtr->Action != CHAR_DIE &&               \
                 CharPtr->Action != CHAR_HURT) {

                // Get heights of attacker and target
                // for line of sight checking
                Character->Object.GetBounds(NULL,NULL,NULL,   \
                                            NULL,&y1,NULL,NULL);
                y1 = (y1 * 0.5f) + Character->YPos;

                CharPtr->Object.GetBounds(NULL,NULL,NULL,     \
                                          NULL,&y2,NULL,NULL);
                y2 = (y2 * 0.5f) + CharPtr->YPos;

                // Get distance to target
                XDiff = (float)fabs(Character->XPos -         \
                                    CharPtr->XPos);
                YDiff = (float)fabs(Character->YPos -         \
                                    CharPtr->YPos);
                ZDiff = (float)fabs(Character->ZPos -         \
                                    CharPtr->ZPos);
                Dist  = XDiff*XDiff+YDiff*YDiff+ZDiff*ZDiff;

                // Reduce distance by character's radius
                Radius = GetXZRadius(CharPtr);
                Dist -= (Radius*Radius);

                // Get spell radius
                Radius = m_MSL[SpellNum].Distance;

                // Make sure target is in range and in sight
                if(LineOfSight(Character, CharPtr,            \
                               Character->XPos, y1,           \
                               Character->ZPos,               \
                               CharPtr->XPos, y2,             \
                               CharPtr->ZPos) &&              \
                   Dist <= (Radius * Radius)) {

                  // Set the spell data
                  Character->Victim      = CharPtr;
                  CharPtr->Attacker      = Character;
                  Character->SpellNum    = SpellNum;
                  Character->SpellTarget = CHAR_PC;

                  // Store target coordinates
                  Character->TargetX = CharPtr->XPos;
                  Character->TargetY = CharPtr->YPos;
                  Character->TargetZ = CharPtr->ZPos;

                  // Face toward target (only if not self)
                  if(m_MSL[SpellNum].Target != TARGET_SELF) {
                    XDiff = CharPtr->XPos - Character->XPos;
                    ZDiff = CharPtr->ZPos - Character->ZPos;
                    Character->Direction =                    \
                                 (float)atan2(XDiff, ZDiff);
                  }

                  // Clear movement
                  MoveX = MoveY = MoveZ = 0.0f;

                  // Set the spell action
                  SetAction(Character, CHAR_SPELL);

                  // Flag spell as cast
                  SpellCast = TRUE;

                  break;
                }
              }

              // Go to next character
              CharPtr = CharPtr->Next;
            }
            break;
          }

          // Go to next spell
          SpellNum = (SpellNum + 1) % 64;
        }
      }

      // If still no spell cast, try casting a known
      // self-enhancing ailment-effecting spell.
      if(SpellCast == FALSE) {
        for(i=0;i<64;i++) {
          if(m_MSL[i].Name[0] &&                              \
             m_MSL[i].Effect == CAUSE_AILMENT &&              \
             Character->ManaPoints >= m_MSL[i].Cost &&        \
             Character->Def.MagicSpells[i/32]&(1<<(i&31)) &&  \
             (rand()%100) < 10) {

            // Make sure it's self-enhancing
            if((long)m_MSL[i].Value[0]&AILMENT_STRONG ||      \
               (long)m_MSL[i].Value[0]&AILMENT_BARRIER ||     \
               (long)m_MSL[i].Value[0]&AILMENT_SUREFOOTED ||  \
               (long)m_MSL[i].Value[0]&AILMENT_FAST ||        \
               (long)m_MSL[i].Value[0]&AILMENT_HAWKEYE) {

              // Make sure ailment not already set
              if(!(Character->Ailments &                      \
                                   (long)m_MSL[i].Value[0])) {

                // Set spell data
                Character->Victim      = Character;
                Character->Attacker    = Character;
                Character->SpellNum    = i;
                Character->SpellTarget = CHAR_MONSTER;
              
                // Store target coordinates
                Character->TargetX = Character->XPos;
                Character->TargetY = Character->YPos;
                Character->TargetZ = Character->ZPos;

                // Clear movement
                MoveX = MoveY = MoveZ = 0.0f;

                // Perform spell action
                SetAction(Character, CHAR_SPELL);

                break;
              }
            }
          }
        }
      }
    }
  }

  // Store movement and return
  *XMove = MoveX;
  *YMove = MoveY;
  *ZMove = MoveZ;

  return TRUE;
}

BOOL cCharacterController::CheckMove(sCharacter *Character,   \
               float *XMove, float *YMove, float *ZMove)
{
  sCharacter *CharPtr;
  float XDiff, YDiff, ZDiff, Dist;
  float Radius1, Radius2;
  float XPos, YPos, ZPos;
  float MinX, MaxX, MinZ, MaxZ;

  // Error checking
  if(Character == NULL)
    return FALSE;  // Don't allow movement

  XPos = Character->XPos + (*XMove);
  YPos = Character->YPos + (*YMove);
  ZPos = Character->ZPos + (*ZMove);

  // Get character's X/Z radius
  Character->Object.GetBounds(&MinX, NULL, &MinZ,             \
                              &MaxX, NULL, &MaxZ, NULL);
  Radius1 = max(MaxX-MinX, MaxZ-MinZ) * 0.5f;

  // Check movement against other characters
  if((CharPtr = m_CharacterParent) != NULL) {
    while(CharPtr != NULL) {

      // Don't check against self or disabled characters
      if(Character != CharPtr && CharPtr->Enabled == TRUE) {
        // Don't check against other PC characters
        if(Character->Type == CHAR_PC &&                      \
           CharPtr->Type == CHAR_PC)
          break;
        
        // Get distance between characters
        XDiff = (float)fabs(XPos - CharPtr->XPos);
        YDiff = (float)fabs(YPos - CharPtr->YPos);
        ZDiff = (float)fabs(ZPos - CharPtr->ZPos);
        Dist = XDiff*XDiff + YDiff*YDiff + ZDiff*ZDiff;

        // Get checking character's X/Z bounding radius
        CharPtr->Object.GetBounds(&MinX, NULL, &MinZ,         \
                                  &MaxX, NULL, &MaxZ, NULL);
        Radius2 = max(MaxX-MinX, MaxZ-MinZ) * 0.5f;

        // Don't allow movement if intersecting
        if(Dist <= (Radius1*Radius1 + Radius2*Radius2))
          return FALSE;
      }

      CharPtr = CharPtr->Next;
    }
  }

  // Bounds check movement if MinX != MaxX
  if(Character->MinX != Character->MaxX) {
    if(XPos < Character->MinX || XPos > Character->MaxX)
      *XMove = 0.0f;
    if(YPos < Character->MinY || YPos > Character->MaxY)
      *YMove = 0.0f;
    if(ZPos < Character->MinZ || ZPos > Character->MaxZ)
      *ZMove = 0.0f;

    // Return no movement at all
    if(!(*XMove) && !(*YMove) && !(*ZMove))
      return FALSE;
  }

  // Call overloaded check custom collisions (maps, etc)
  if(ValidateMove(Character, XMove, YMove, ZMove) == FALSE)
    return FALSE;  // Don't allow movement

  return TRUE;
}

BOOL cCharacterController::ProcessUpdate(                     \
                      sCharacter *Character,
                      float XMove, float YMove, float ZMove)
{
  // Move character
  Character->XPos += XMove;
  Character->YPos += YMove;
  Character->ZPos += ZMove;

  // Move object and point in direction
  Character->Object.Move(Character->XPos,                     \
                         Character->YPos,                     \
                         Character->ZPos);                    \
  Character->Object.Rotate(0.0f, Character->Direction, 0.0f);

  // Set new animation
  if(Character->LastAnim != Character->Action) {
    Character->LastAnim = Character->Action;

    if(m_NumAnimations && m_Animations != NULL) {
      Character->LastAnimTime = timeGetTime() / 30;
      Character->Object.SetAnimation(                         \
                 &m_Meshes[Character->Def.MeshNum].Animation, \
                 m_Animations[Character->Action].Name,        \
                 Character->LastAnimTime);
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品视频1区2区| 欧美三级三级三级爽爽爽| 日韩激情中文字幕| 亚洲午夜一区二区| 亚洲国产成人va在线观看天堂| 亚洲精选在线视频| 综合久久久久久久| 国产精品欧美久久久久无广告 | 成人伦理片在线| 国产一区二区三区日韩 | 久久久精品2019中文字幕之3| 日韩免费观看高清完整版| 91精品国产综合久久小美女| 日韩一二三区不卡| 日韩精品一区国产麻豆| 久久―日本道色综合久久| 国产亚洲综合在线| 国产精品夫妻自拍| 亚洲成人免费视频| 久久超碰97中文字幕| 国产精品69久久久久水密桃| 99精品国产99久久久久久白柏| 色婷婷狠狠综合| 69av一区二区三区| 久久麻豆一区二区| 亚洲欧洲日产国码二区| 午夜精品久久久久久久| 精品制服美女久久| av亚洲精华国产精华精华 | 亚洲一区av在线| 青草av.久久免费一区| 国产成人综合在线播放| 日本道在线观看一区二区| 91精品国产色综合久久不卡电影 | 亚洲欧美日韩电影| 免费观看久久久4p| 99精品黄色片免费大全| 欧美电影在线免费观看| 国产日韩高清在线| 日韩中文字幕不卡| 成人白浆超碰人人人人| 91精品国产综合久久精品性色| 久久久久国产精品人| 一级精品视频在线观看宜春院 | 国模无码大尺度一区二区三区| 不卡在线观看av| 日韩午夜精品视频| 亚洲欧美日韩在线不卡| 极品美女销魂一区二区三区| 色婷婷久久综合| 国产午夜精品久久久久久免费视| 亚洲欧美另类图片小说| 国产福利一区二区三区视频| 制服丝袜国产精品| 亚洲资源在线观看| 成人av免费在线| 亚洲精品一区二区三区香蕉| 亚洲成av人影院在线观看网| a级精品国产片在线观看| 精品国产一区二区三区久久影院| 亚洲黄色录像片| gogogo免费视频观看亚洲一| 久久―日本道色综合久久| 免费亚洲电影在线| 欧美一区二区三区公司| 亚洲超碰97人人做人人爱| 色婷婷av一区二区三区gif | 欧美在线你懂的| 中文字幕一区日韩精品欧美| 成人一区在线观看| 久久久综合视频| 国产麻豆一精品一av一免费| 精品捆绑美女sm三区| 日韩不卡手机在线v区| 91精品国产一区二区三区蜜臀 | 国产一区二区三区四| 精品99一区二区| 久久精品国产精品青草| 欧美一级在线视频| 美女视频一区二区| 精品sm在线观看| 国产不卡视频一区| 国产精品久久久久久福利一牛影视| 成人黄色免费短视频| 国产精品美女久久久久久 | 午夜精品福利久久久| 在线观看av一区二区| 亚洲一区二区三区激情| 欧美裸体bbwbbwbbw| 美国十次综合导航| 亚洲精品一区二区三区福利| 国产老妇另类xxxxx| 中文字幕高清一区| 在线亚洲一区二区| 天天色 色综合| 欧美大白屁股肥臀xxxxxx| 韩日精品视频一区| 国产精品麻豆网站| 欧美日韩亚洲综合| 久久99国产精品久久99 | 欧美在线色视频| 日本亚洲一区二区| 久久亚洲私人国产精品va媚药| 大尺度一区二区| 亚洲最大成人综合| 精品国产人成亚洲区| 精品国产3级a| 国产精品中文字幕一区二区三区| 国产农村妇女毛片精品久久麻豆| 99国产精品久久久久久久久久久| 亚洲成人在线网站| 久久久久久久综合日本| 日本韩国欧美一区二区三区| 免费看日韩a级影片| 国产精品沙发午睡系列990531| 欧美日韩综合一区| 国产传媒久久文化传媒| 午夜精品一区二区三区免费视频| 日本一区二区三区国色天香| 欧美日韩国产系列| 成人精品电影在线观看| 香港成人在线视频| 日韩一区欧美小说| 久久久久久久久久久久电影 | 69堂国产成人免费视频| 成人午夜看片网址| 日本v片在线高清不卡在线观看| 国产欧美一区二区在线观看| 91精品国模一区二区三区| 91视频免费看| 国产精品一区二区三区网站| 免费看欧美女人艹b| 亚洲午夜一二三区视频| 1区2区3区欧美| 欧美激情一区二区三区在线| 日韩三级视频在线观看| 欧美喷水一区二区| 欧美性大战久久久久久久| 成人黄色国产精品网站大全在线免费观看 | av成人老司机| 国产精品1024| 狠狠狠色丁香婷婷综合激情| 日本在线不卡一区| 亚洲国产精品精华液网站| 怡红院av一区二区三区| 国产精品的网站| 中文一区二区在线观看 | 成人精品国产福利| 风间由美一区二区三区在线观看 | 国产欧美一区二区三区鸳鸯浴| 日韩三级电影网址| 日韩欧美激情四射| 日韩欧美在线影院| 欧美一级xxx| 日韩免费观看2025年上映的电影| 欧美一区二区三区色| 日韩欧美国产综合| 日韩免费看的电影| 久久嫩草精品久久久精品一| 久久综合九色综合97婷婷女人| 精品国产乱码久久久久久闺蜜| 日韩一区二区三区四区| 精品国产乱码久久久久久老虎| 欧美精品一区二区三区四区 | 婷婷夜色潮精品综合在线| 性感美女久久精品| 青娱乐精品视频在线| 国产最新精品免费| 国产a视频精品免费观看| 99久免费精品视频在线观看| 色哟哟欧美精品| 欧美福利电影网| 日韩欧美在线观看一区二区三区| 欧美精品一区二区三区视频| 国产精品三级av| 夜色激情一区二区| 免费三级欧美电影| 国产福利一区二区三区在线视频| 99re6这里只有精品视频在线观看| 一道本成人在线| 91精品国产综合久久久蜜臀图片| 精品福利一区二区三区免费视频| 国产精品嫩草影院av蜜臀| 亚洲综合色网站| 精品一区二区三区欧美| 不卡大黄网站免费看| 欧美精选午夜久久久乱码6080| 精品国产污网站| 一区二区三区四区精品在线视频 | 国产精品网站在线播放| 亚洲福利一区二区三区| 国产一区二区主播在线| 精品视频色一区| 国产女同互慰高潮91漫画| 亚洲成人黄色小说| 成av人片一区二区| 欧美成人精品1314www| 一区二区三区四区在线播放| 免费的成人av| 91精彩视频在线|