Random Infantry Facing.fscript 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // FinalAlert2:YR Script file
  2. // Name: Change Infantry Facing
  3. // Written By: Matthias Wagner
  4. // Last Change: August 21, 2001
  5. // Be careful when editing scripts, they may cause damage to maps if used improperly
  6. AllowDelete("Necessary for changing infantry");
  7. AllowAdd("Necessary for changing infantry");
  8. Is("%DeleteAllowed%","=","0","%NoDelete%");
  9. Print("Deletion must be allowed for this script to run!","%NoDelete%");
  10. Cancel("%NoDelete%");
  11. Is("%AddAllowed%","=","0","%NoAdd%");
  12. Print("Adding must be allowed for this script to run!","%NoAdd%");
  13. Cancel("%NoAdd%");
  14. Ask("%specified%","Do you want to limit random infantry facing to a specific house?","Limit Random Infantry facing to house");
  15. SetVariable("%House%","");
  16. UInputGetHouse("%House%","House:","%specified%");
  17. SetAutoUpdate("FALSE"); // no screen flickering...
  18. Is("%InfantryCount%","=","0","%Abort%");
  19. Cancel("%Abort%");
  20. SetVariable("%TCounter%","%InfantryCount%");
  21. // LOOP BEGIN
  22. :Loop:
  23. SetVariable("%pos%","%TCounter%");
  24. Substract("%pos%","1");
  25. IsInfantryDeleted("%deleted?%","%pos%");
  26. Is("%deleted?%","=","0","%existing%");
  27. GetInfantry("%data%","%pos%");
  28. SetVariable("%Differ%","0");
  29. GetParam("%param%", "%data%", "0", "%specified%");
  30. Is("%param%","!=","%House%","%Differ%","%specified%");
  31. Substract("%TCounter%","1", "%Differ%");
  32. And("%cancelloop%","%Differ%", "%TCounter%");
  33. JumpTo("Loop", "%cancelloop%");
  34. // if we are here, and Differ is set to TRUE, TCounter must be 0, so cancel script.
  35. Cancel("%Differ%");
  36. DeleteInfantry("%pos%","%existing%");
  37. GetRandom("%Facing%");
  38. // convert random (0-32767) to 8 directions
  39. Divide("%Facing%","4096");
  40. // convert 8 directions to degrees
  41. Multi("%Facing%","32");
  42. Print("%Facing%");
  43. SetParam("%data%","7","%Facing%","%existing%");
  44. AddInfantry("%data%","%existing%");
  45. Substract("%TCounter%", "1", "%TCounter%"); // only substract if >=0, else infinite loop!
  46. JumpTo("Loop","%TCounter%");