Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. void StopCombat(object oPC, object oEnemy, int nRounds, int bAll = FALSE)
  2. {
  3. float fTime = RoundsToSeconds(nRounds);
  4.  
  5. int x = 1; // iterations of combatant loop
  6. int y = 0; // iterations of pc loop
  7. int z; // iterations of associate type
  8. int max = x+50; // maximum combatants of each character to neutralize
  9.  
  10. object oNPC; // associates of oPC
  11. object oCombatant; // additional enemies of oPC or oNPC
  12.  
  13. while (GetIsObjectValid(oPC))
  14. {
  15. // targeted enemy of PC
  16. SetCommandable(TRUE, oPC);
  17. SetCommandable(TRUE, oEnemy);
  18. AssignCommand(oPC, ClearAllActions(TRUE));
  19. SetIsTemporaryFriend(oEnemy, oPC, TRUE, fTime);
  20. AssignCommand(oEnemy, ClearAllActions(TRUE));
  21. SetIsTemporaryFriend(oPC, oEnemy, TRUE, fTime);
  22. if (bAll)
  23. {
  24. // next loop through all remaining enemies of oPC
  25. x = 1;
  26. oCombatant = GetNearestEnemy(oPC, x);
  27. while (GetIsObjectValid(oCombatant))
  28. {
  29. SetCommandable(TRUE, oCombatant);
  30. AssignCommand(oCombatant, ClearAllActions(TRUE));
  31. SetIsTemporaryFriend(oPC, oCombatant, TRUE, fTime);
  32. SetIsTemporaryFriend(oCombatant, oPC, TRUE, fTime);
  33.  
  34. if (++x==max) break;
  35. oCombatant = GetNearestEnemy(oPC, x);
  36. }
  37. }
  38.  
  39. // loop through all Associates of oPC
  40. for (z = 1; z <= 5; z ++)
  41. {
  42. int w = 1;
  43. oNPC = GetAssociate(z, oPC, w);
  44. while (GetIsObjectValid(oNPC))
  45. {
  46. // first enemy of NPC
  47. SetCommandable(TRUE, oNPC);
  48. AssignCommand(oNPC, ClearAllActions(TRUE));
  49. SetIsTemporaryFriend(oEnemy, oNPC, TRUE, fTime);
  50. AssignCommand(oEnemy, ClearAllActions(TRUE));
  51. SetIsTemporaryFriend(oNPC, oEnemy, TRUE, fTime);
  52. if(bAll)
  53. { // next loop through all remaining enemies of NPC
  54. x = 1;
  55. oCombatant = GetNearestEnemy(oNPC, x);
  56. while (GetIsObjectValid(oCombatant))
  57. {
  58. if (x==max) break;
  59. SetCommandable(TRUE, oCombatant);
  60. AssignCommand(oNPC, ClearAllActions(TRUE));
  61. SetIsTemporaryFriend(oCombatant, oNPC, TRUE, fTime);
  62. AssignCommand(oCombatant, ClearAllActions(TRUE));
  63. SetIsTemporaryFriend(oNPC, oCombatant, TRUE, fTime);
  64. oCombatant = GetNearestEnemy(oNPC, ++x);
  65. }
  66. }
  67. oNPC = GetAssociate(z, oPC, ++w);
  68. }
  69. }
  70.  
  71. // only continue loop in multiplayer games
  72. if(!MULTIPLAYER)
  73. break;
  74. else
  75. {
  76. // loop through PC party members
  77. if (++y==1)
  78. oPC = GetFirstFactionMember(oPC);
  79. else
  80. oPC = GetNextFactionMember(oPC);
  81. }
  82. } // loop through PC party members
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement