Arx Libertatis Bug Tracker
star_faded.png
Please log in to bookmark issues
enhancement_small.png
OPEN  Enhancement #501  -  Damage of explosion
Posted Jun 03, 2013 - updated Jul 13, 2013   Shortlink: http://arx.vg/501
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
Issue details
  • Type of issue
    Enhancement
  • Status
     
    New
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Dimoks
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Category
    Not determined
  • Priority
    Not determined
  • Targetted for
    icon_milestones.png Not determined
  • OS
    icon_customdatatype.png Not determined
  • Architecture
    icon_customdatatype.png Not determined
  • Fixed in
    icon_customdatatype.png Not determined
Issue description
In the explosion damage formula in the function "bool DoSphericDamage" of the file: "src\game\Damage.cpp", we have such a place:

  1. for(size_t i = 0; i < entities.size(); i++) { // for all objects on level?
  2. Entity * ioo = entities[i];
  3.  
  4. if ((ioo) && (long(i) != numsource) && (ioo->obj))
  5. {
  6. if ((i != 0) && (numsource != 0)
  7. && validsource && (HaveCommonGroup(ioo, entities[numsource])))
  8. continue;
  9.  
  10. if ((ioo->ioflags & IO_CAMERA) || (ioo->ioflags & IO_MARKER)) continue;
  11.  
  12. long count = 0;
  13. long count2 = 0;
  14. float mindist = std::numeric_limits<float>::max();
  15.  
  16. for (size_t k = 0; k < ioo->obj->vertexlist.size(); k += 1)
  17. { // for all vertexes of the object
  18. if (ioo->obj->vertexlist.size() < 120)
  19. { // if the number of vertexes of the object less then 120
  20. for (size_t kk = 0; kk < ioo->obj->vertexlist.size(); kk += 1)
  21. { // for all others vertexes of the object
  22. if (kk != k)
  23. {
  24. Vec3f posi = (entities[i]->obj->vertexlist3[k].v
  25. + entities[i]->obj->vertexlist3[kk].v) * 0.5f; // is sought the midpoint between the two vertexes
  26. float dist = fdist(*pos, posi); // and measured its distance to the center of the explosion
  27. if(dist <= radius) { // if distance less then radius of explosion
  28. count2++;
  29. if (dist < mindist) mindist = dist;
  30. }
  31. }
  32. }
  33. }
  34.  
  35. {
  36. float dist = fdist(*pos, entities[i]->obj->vertexlist3[k].v); // measured distance from vertex to the center of the explosion
  37.  
  38. if (dist <= radius)
  39. { // if distance less then radius of explosion
  40. count++;
  41.  
  42. if (dist < mindist) mindist = dist;
  43. }
  44. }
  45. }
  46.  
  47. float ratio = ((float)count / ((float)ioo->obj->vertexlist.size() * ( 1.0f / 2 ))); // "* ( 1.0f / 2 )" are increases the ratio
  48.  
  49. if (count2 > count)
  50. ratio = ((float)count2 / ((float)ioo->obj->vertexlist.size() * ( 1.0f / 2 ))); // "* ( 1.0f / 2 )" are increases the ratio
  51.  
  52. if (ratio > 2.f) ratio = 2.f;
  53.  
  54. ...
  55. }
  56. ...
  57. }
  58. ...
  59. }


Perhaps it would be correct to do so:

  1. for (size_t k = 0; k < ioo->obj->vertexlist.size(); k += 1)
  2. {
  3. if (ioo->obj->vertexlist.size() < 120)
  4. {
  5. for (size_t kk = 0; kk < ioo->obj->vertexlist.size(); kk += 1)
  6. {
  7. if (kk != k)
  8. {
  9. Vec3f posi = (entities[i]->obj->vertexlist3[k].v
  10. + entities[i]->obj->vertexlist3[kk].v) * 0.5f;
  11. float dist = fdist(*pos, posi);
  12. if(dist <= radius) {
  13. count2++;
  14. if (dist < mindist) mindist = dist;
  15. }
  16. }
  17. }
  18. }
  19. else // reduces the number of measurements
  20. {
  21. float dist = fdist(*pos, entities[i]->obj->vertexlist3[k].v);
  22.  
  23. if (dist <= radius)
  24. {
  25. count++;
  26.  
  27. if (dist < mindist) mindist = dist;
  28. }
  29. }
  30. }
  31.  
  32. float ratio = ((float)count / ((float)ioo->obj->vertexlist.size() * ( 1.0f / 2 )));
  33.  
  34. if (count2 > count)
  35. ratio = ((float)count2 / ((float)ioo->obj->vertexlist.size() * ( 1.0f / 2 )));
  36.  
  37. if (ratio > 2.f) ratio = 2.f;


Or even so:

  1. for (size_t k = 0; k < ioo->obj->vertexlist.size(); k += 1)
  2. {
  3. if (ioo->obj->vertexlist.size() < 120)
  4. {
  5. for (size_t kk = 0; kk < ioo->obj->vertexlist.size(); kk += 1)
  6. {
  7. if (kk != k)
  8. {
  9. Vec3f posi = (entities[i]->obj->vertexlist3[k].v
  10. + entities[i]->obj->vertexlist3[kk].v) * 0.5f;
  11. float dist = fdist(*pos, posi);
  12. if(dist <= radius) {
  13. count2++;
  14. if (dist < mindist) mindist = dist;
  15. }
  16. }
  17. }
  18. }
  19. else
  20. {
  21. float dist = fdist(*pos, entities[i]->obj->vertexlist3[k].v);
  22.  
  23. if (dist <= radius)
  24. {
  25. count++;
  26.  
  27. if (dist < mindist) mindist = dist;
  28. }
  29. }
  30. }
  31.  
  32. float ratio = ((float)count / (float)ioo->obj->vertexlist.size()); // The less counter, the less damage from the explosion
  33.  
  34. if (count2 > count)
  35. ratio = ((float)count2 / (float)ioo->obj->vertexlist.size()); // The less counter, the less damage from the explosion
  36.  
  37. if (ratio > 2.f) ratio = 2.f;


Perhaps we should review the entire internal cycle. Is there access to polygons of objects?

#5
icon_reply.pngReply
Comment posted by
 Guest user
Jul 12, 15:32
Maybe some comments about the changes?