Advertisement
ijontichy

<stdin>

May 1st, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function int unusedTID(int start, int end)
  2. {
  3. int ret = start - 1;
  4. int tidNum;
  5.  
  6. if (start > end) { start ^= end; end ^= start; start ^= end; } // good ol' XOR swap
  7.  
  8. while (ret++ != end)
  9. {
  10. if (ThingCount(0, ret) == 0)
  11. {
  12. return ret;
  13. }
  14. }
  15.  
  16. return -1;
  17. }
  18.  
  19. function int defaultTID(int def)
  20. {
  21. int tid = ActivatorTID();
  22. int i;
  23.  
  24. if (ThingCount(0, tid) == 1) { return tid; }
  25.  
  26. tid = def;
  27. if (def <= 0)
  28. {
  29. i = random(13, 23);
  30. tid = unusedTID(i*1000, (i+10)*1000);
  31. }
  32.  
  33. Thing_ChangeTID(0, tid);
  34. ACS_ExecuteAlways(DEFAULTTID_SCRIPT, 0, tid,0,0);
  35.  
  36. return tid;
  37. }
  38.  
  39. script DEFAULTTID_SCRIPT (int tid) clientside
  40. {
  41. if (ConsolePlayerNumber() == -1) { terminate; }
  42. Thing_ChangeTID(0, tid);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement