Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. init()
  2. {
  3. // level.destructableFX = loadfx("breakables/exp_wall_cinderblock_96");
  4.  
  5. ents = getentarray("destructable", "targetname");
  6.  
  7. if (getdvar("scr_destructables") == "0")
  8. {
  9. for (i = 0; i < ents.size; i++)
  10. ents[i] delete();
  11. }
  12. else
  13. {
  14. for (i = 0; i < ents.size; i++)
  15. {
  16. ents[i] thread destructable_think();
  17. }
  18. }
  19. }
  20.  
  21. destructable_think()
  22. {
  23. accumulate = 40;
  24. threshold = 0;
  25.  
  26. if (isdefined(self.script_accumulate))
  27. accumulate = self.script_accumulate;
  28. if (isdefined(self.script_threshold))
  29. threshold = self.script_threshold;
  30.  
  31. if (isdefined(self.script_destructable_area)) {
  32. areas = strtok(self.script_destructable_area, " ");
  33. for (i = 0; i < areas.size; i++)
  34. self blockArea(areas[i]);
  35. }
  36.  
  37. if ( isdefined( self.script_fxid ) )
  38. self.fx = loadfx( self.script_fxid );
  39.  
  40. dmg = 0;
  41.  
  42. self setcandamage(true);
  43. while(1)
  44. {
  45. self waittill("damage", amount, other);
  46. if (amount >= threshold)
  47. {
  48. dmg += amount;
  49. if (dmg >= accumulate)
  50. {
  51. self thread destructable_destruct();
  52. return;
  53. }
  54. }
  55. }
  56. }
  57.  
  58. destructable_destruct()
  59. {
  60. ent = self;
  61. if (isdefined(self.script_destructable_area)) {
  62. areas = strtok(self.script_destructable_area, " ");
  63. for (i = 0; i < areas.size; i++)
  64. self unblockArea(areas[i]);
  65. }
  66. if ( isdefined( ent.fx ) )
  67. playfx( ent.fx, ent.origin + (0,0,6) );
  68. ent delete();
  69. }
  70.  
  71. blockArea(area)
  72. {
  73. spawns = getentarray("mp_tdm_spawn", "classname");
  74. blockEntsInArea(spawns, area);
  75. spawns = getentarray("mp_dm_spawn", "classname");
  76. blockEntsInArea(spawns, area);
  77. }
  78. blockEntsInArea(ents, area)
  79. {
  80. for (i = 0; i < ents.size; i++) {
  81. if (!isdefined(ents[i].script_destructable_area) || ents[i].script_destructable_area != area)
  82. continue;
  83. ents[i].blockedoff = true;
  84. }
  85. }
  86. unblockArea(area)
  87. {
  88. spawns = getentarray("mp_tdm_spawn", "classname");
  89. unblockEntsInArea(spawns, area);
  90. spawns = getentarray("mp_dm_spawn", "classname");
  91. unblockEntsInArea(spawns, area);
  92. }
  93. unblockEntsInArea(ents, area)
  94. {
  95. for (i = 0; i < ents.size; i++) {
  96. if (!isdefined(ents[i].script_destructable_area) || ents[i].script_destructable_area != area)
  97. continue;
  98. ents[i].blockedoff = false;
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement