Advertisement
sorvani

GetFaction.mac

Sep 10th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.53 KB | None | 0 0
  1. | GetFaction.mac
  2.  
  3. #define CHAN_INFO "/echo"
  4. #Event Consider "#1# scowls at you, ready to #2# --#*#" | attack
  5. #Event Consider "#1# glares at you #2# --#*#" | threateningly
  6. #Event Consider "#1# glowers at you #2# --#*#" | dubiously
  7. #Event Consider "#1# looks your way #2# --#*#" | apprehensively
  8. #Event Consider "#1# regards you #2# --#*#" | indifferently
  9. #Event Consider "#1# judges you #2# --#*#" | amiably
  10. #Event Consider "#1# kindly considers #2# --#*#" | you
  11. #Event Consider "#1# looks upon you #2# --#*#" | warmly
  12. #Event Consider "#1# regards you as an #2# --#*#" | ally
  13.  
  14. Sub Main
  15. /cleanup
  16.  
  17. | set to 1 for to show counter, 2 will show counter and npc name/faction, 3 will show a LOT of crap
  18. /declare DebugLevel int outer 1
  19. | output file name
  20. /declare IniFile string local GetFactionResults.ini
  21.  
  22. | check that there is some kind of npc in zone.
  23. /if (!${SpawnCount[npc]}) {
  24. CHAN_INFO There are no NPCs in this zone.
  25. /endmacro
  26. }
  27. | internal variables, do not edit
  28. | stop searching the spawn list after 100 more than the span count at macro start.
  29. | this should get most things in a zone.
  30. /declare MaxSpawn int local ${Math.Calc[${SpawnCount}+100]}
  31. | variable to iterate /for loop
  32. /declare LoopSpawn int local 0
  33. | time in deciseconds to wait to aquire the target before moving on
  34. /declare TargetDelay int local 15
  35. | variable to hold /con results
  36. /declare FactionLevel string outer NONE
  37. | variable to know if a faction message was obtained
  38. /declare FactionReturned int outer 0
  39. | string version of LoopSpawn
  40. /declare LoopString string local 0
  41. | SpawnID of the NearestSpawn to check
  42. /declare CheckSpawn int local 0
  43. | Ini Section Name based on zone/class/race/diety
  44. /declare IniSection string local ${Zone.ShortName}_${Me.Class.ShortName}_${Me.Race}_${Me.Deity}
  45. | Current Run TimeStamp - using this because the base MQ2 package does not delete ini keys.
  46. /declare ExecutionTimeStamp string local ${Time.Year}${If[${Time.Month}<10,0${Time.Month},${Time.Month}]}${If[${Time.Day}<10,0${Time.Day},${Time.Day}]}_${Time.SecondsSinceMidnight}
  47.  
  48. CHAN_INFO Begining to check NPC factions compared to you.
  49. | wipe out the INI section if the MQ2 build supports it.
  50. /ini "${IniFile}" "${IniSection}"
  51. | write out the timestamp of the current run
  52. /ini "${IniFile}" "${IniSection}" "ExecutionTimeStamp" ${ExecutionTimeStamp}
  53.  
  54. | iterate through the NearestSpawn object (it always starts at 0 as yourself, no need to start there.)
  55. /for LoopSpawn 1 to ${MaxSpawn}
  56. :Delay
  57. /if (${Spawn[gm].ID}) {
  58. CHAN_INFO GM detected in zone, waiting.
  59. /squelch /target clear
  60. /delay 1m !${Spawn[gm].ID}
  61. /goto :Delay
  62. }
  63. /if (${NearestSpawn[2,pc].Distance3D} > 0 && ${NearestSpawn[2,pc].Distance3D} <= 20) {
  64. CHAN_INFO Another player detected within 200 units, waiting.
  65. /squelch /target clear
  66. /delay 1m (${NearestSpawn[2,pc].Distance3D} > 20)
  67. /goto :Delay
  68. }
  69. /varset CheckSpawn ${NearestSpawn[${LoopSpawn}].ID}
  70. | check that the spawn is a NPC
  71. /if (${Spawn[${CheckSpawn}].Type.Equal[NPC]} && ${Spawn[${CheckSpawn}].Class.Name.NotEqual[Destructible Object]} && ${Spawn[${CheckSpawn}].Race.Name.NotEqual[Barrel]}) {
  72. /if (${DebugLevel}==3) CHAN_INFO ${Spawn[${CheckSpawn}].CleanName} found on spawn id ${CheckSpawn}.
  73. | attempt to target the spawn
  74. /target ID ${CheckSpawn}
  75. /delay ${TargetDelay} ${Target.ID}==${CheckSpawn}
  76. /if (${DebugLevel}==3) CHAN_INFO successfully targeted ${Spawn[${CheckSpawn}].CleanName}
  77. /if (${Target.ID}==${CheckSpawn}) {
  78. /docommand /consider
  79. /if (${DebugLevel}==3) CHAN_INFO /con sent for ${Spawn[${CheckSpawn}].CleanName}
  80. | 10 decisecond delay before doevents to give /con message a chance to display
  81. | without this we are always waiting 1 full delay cycle.
  82. /delay 10
  83. /doevents
  84. /if (${DebugLevel}==3) CHAN_INFO /doevents completed
  85. /delay ${TargetDelay} ${FactionReturned}==1
  86. /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
  87. | check 4 times in case of server lag. too lazy to make it a loop.
  88. /if (!${FactionReturned}) {
  89. /doevents
  90. /if (${DebugLevel}==3) CHAN_INFO /doevents completed second time
  91. /delay ${TargetDelay} ${FactionReturned}==1
  92. /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
  93. }
  94. /if (!${FactionReturned}) {
  95. /doevents
  96. /if (${DebugLevel}==3) CHAN_INFO /doevents completed third time
  97. /delay ${TargetDelay} ${FactionReturned}==1
  98. /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
  99. }
  100. /if (!${FactionReturned}) {
  101. /doevents
  102. /if (${DebugLevel}==3) CHAN_INFO /doevents completed fourth time
  103. /delay ${TargetDelay} ${FactionReturned}==1
  104. /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
  105. }
  106. /if (${FactionReturned}) {
  107. /ini "${IniFile}" "${IniSection}" "${Zone.ID}_${CheckSpawn}" ",${ExecutionTimeStamp},${Zone.ID},${Zone.ShortName},${CheckSpawn},${Me.Race},${Me.Race.ID},${Me.Class.ShortName},${Me.Deity},${Spawn[${CheckSpawn}].Name},${Spawn[${CheckSpawn}].Race},${Spawn[${CheckSpawn}].Race.ID},${Spawn[${CheckSpawn}].Class.ShortName},${Spawn[${CheckSpawn}].Deity},${FactionLevel}"
  108. /squelch /target clear
  109. } else {
  110. CHAN_INFO There was no faction response to a /con request for ${Spawn[${CheckSpawn}].Name} with an id of ${CheckSpawn}
  111. /squelch /target clear
  112. }
  113. } else {
  114. /if (${DebugLevel}>=2) CHAN_INFO SpawnID ${CheckSpawn}: no target
  115. /varset FactionLevel NOTARGET
  116. }
  117. }
  118. /varset FactionReturned 0
  119. /varset FactionLevel NONE
  120. | provide feedback if debug level set to 1 or higher
  121. /if (${DebugLevel}>=1) {
  122. /varset LoopString ${LoopSpawn}
  123. /if (${LoopString.Right[2].Equal[00]} || ${LoopString.Right[2].Equal[50]}) {
  124. CHAN_INFO Spawn ID ${LoopSpawn} of ${MaxSpawn} max spawns
  125. }
  126. }
  127. /next LoopSpawn
  128. CHAN_INFO Completed search of NPCs for their faction text
  129. /return
  130.  
  131. Sub Event_Consider(string message, string npcname, string faction)
  132. /if (${DebugLevel}>=2) CHAN_INFO /con event triggered for: ${npcname} ${faction}
  133. /if (${Target.CleanName.Equal[${npcname}]}) {
  134. /varset FactionLevel ${faction}
  135. /if (${faction.Equal[attack]}) {
  136. /varset FactionLevel scowls
  137. } else {
  138. /if (${faction.Equal[you]}) {
  139. /varset FactionLevel scowls
  140. }
  141. }
  142. /varset FactionReturned 1
  143. | /squelch /target clear
  144. } else {
  145. | something got messed up
  146. /varset FactionReturned 0
  147. /varset FactionLevel ERROR
  148. }
  149. /return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement