Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | GetFaction.mac
- #define CHAN_INFO "/echo"
- #Event Consider "#1# scowls at you, ready to #2# --#*#" | attack
- #Event Consider "#1# glares at you #2# --#*#" | threateningly
- #Event Consider "#1# glowers at you #2# --#*#" | dubiously
- #Event Consider "#1# looks your way #2# --#*#" | apprehensively
- #Event Consider "#1# regards you #2# --#*#" | indifferently
- #Event Consider "#1# judges you #2# --#*#" | amiably
- #Event Consider "#1# kindly considers #2# --#*#" | you
- #Event Consider "#1# looks upon you #2# --#*#" | warmly
- #Event Consider "#1# regards you as an #2# --#*#" | ally
- Sub Main
- /cleanup
- | set to 1 for to show counter, 2 will show counter and npc name/faction, 3 will show a LOT of crap
- /declare DebugLevel int outer 1
- | output file name
- /declare IniFile string local GetFactionResults.ini
- | check that there is some kind of npc in zone.
- /if (!${SpawnCount[npc]}) {
- CHAN_INFO There are no NPCs in this zone.
- /endmacro
- }
- | internal variables, do not edit
- | stop searching the spawn list after 100 more than the span count at macro start.
- | this should get most things in a zone.
- /declare MaxSpawn int local ${Math.Calc[${SpawnCount}+100]}
- | variable to iterate /for loop
- /declare LoopSpawn int local 0
- | time in deciseconds to wait to aquire the target before moving on
- /declare TargetDelay int local 15
- | variable to hold /con results
- /declare FactionLevel string outer NONE
- | variable to know if a faction message was obtained
- /declare FactionReturned int outer 0
- | string version of LoopSpawn
- /declare LoopString string local 0
- | SpawnID of the NearestSpawn to check
- /declare CheckSpawn int local 0
- | Ini Section Name based on zone/class/race/diety
- /declare IniSection string local ${Zone.ShortName}_${Me.Class.ShortName}_${Me.Race}_${Me.Deity}
- | Current Run TimeStamp - using this because the base MQ2 package does not delete ini keys.
- /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}
- CHAN_INFO Begining to check NPC factions compared to you.
- | wipe out the INI section if the MQ2 build supports it.
- /ini "${IniFile}" "${IniSection}"
- | write out the timestamp of the current run
- /ini "${IniFile}" "${IniSection}" "ExecutionTimeStamp" ${ExecutionTimeStamp}
- | iterate through the NearestSpawn object (it always starts at 0 as yourself, no need to start there.)
- /for LoopSpawn 1 to ${MaxSpawn}
- :Delay
- /if (${Spawn[gm].ID}) {
- CHAN_INFO GM detected in zone, waiting.
- /squelch /target clear
- /delay 1m !${Spawn[gm].ID}
- /goto :Delay
- }
- /if (${NearestSpawn[2,pc].Distance3D} > 0 && ${NearestSpawn[2,pc].Distance3D} <= 20) {
- CHAN_INFO Another player detected within 200 units, waiting.
- /squelch /target clear
- /delay 1m (${NearestSpawn[2,pc].Distance3D} > 20)
- /goto :Delay
- }
- /varset CheckSpawn ${NearestSpawn[${LoopSpawn}].ID}
- | check that the spawn is a NPC
- /if (${Spawn[${CheckSpawn}].Type.Equal[NPC]} && ${Spawn[${CheckSpawn}].Class.Name.NotEqual[Destructible Object]} && ${Spawn[${CheckSpawn}].Race.Name.NotEqual[Barrel]}) {
- /if (${DebugLevel}==3) CHAN_INFO ${Spawn[${CheckSpawn}].CleanName} found on spawn id ${CheckSpawn}.
- | attempt to target the spawn
- /target ID ${CheckSpawn}
- /delay ${TargetDelay} ${Target.ID}==${CheckSpawn}
- /if (${DebugLevel}==3) CHAN_INFO successfully targeted ${Spawn[${CheckSpawn}].CleanName}
- /if (${Target.ID}==${CheckSpawn}) {
- /docommand /consider
- /if (${DebugLevel}==3) CHAN_INFO /con sent for ${Spawn[${CheckSpawn}].CleanName}
- | 10 decisecond delay before doevents to give /con message a chance to display
- | without this we are always waiting 1 full delay cycle.
- /delay 10
- /doevents
- /if (${DebugLevel}==3) CHAN_INFO /doevents completed
- /delay ${TargetDelay} ${FactionReturned}==1
- /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
- | check 4 times in case of server lag. too lazy to make it a loop.
- /if (!${FactionReturned}) {
- /doevents
- /if (${DebugLevel}==3) CHAN_INFO /doevents completed second time
- /delay ${TargetDelay} ${FactionReturned}==1
- /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
- }
- /if (!${FactionReturned}) {
- /doevents
- /if (${DebugLevel}==3) CHAN_INFO /doevents completed third time
- /delay ${TargetDelay} ${FactionReturned}==1
- /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
- }
- /if (!${FactionReturned}) {
- /doevents
- /if (${DebugLevel}==3) CHAN_INFO /doevents completed fourth time
- /delay ${TargetDelay} ${FactionReturned}==1
- /if (${DebugLevel}==3) CHAN_INFO /delay completed with FactionReturned of ${FactionReturned}
- }
- /if (${FactionReturned}) {
- /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}"
- /squelch /target clear
- } else {
- CHAN_INFO There was no faction response to a /con request for ${Spawn[${CheckSpawn}].Name} with an id of ${CheckSpawn}
- /squelch /target clear
- }
- } else {
- /if (${DebugLevel}>=2) CHAN_INFO SpawnID ${CheckSpawn}: no target
- /varset FactionLevel NOTARGET
- }
- }
- /varset FactionReturned 0
- /varset FactionLevel NONE
- | provide feedback if debug level set to 1 or higher
- /if (${DebugLevel}>=1) {
- /varset LoopString ${LoopSpawn}
- /if (${LoopString.Right[2].Equal[00]} || ${LoopString.Right[2].Equal[50]}) {
- CHAN_INFO Spawn ID ${LoopSpawn} of ${MaxSpawn} max spawns
- }
- }
- /next LoopSpawn
- CHAN_INFO Completed search of NPCs for their faction text
- /return
- Sub Event_Consider(string message, string npcname, string faction)
- /if (${DebugLevel}>=2) CHAN_INFO /con event triggered for: ${npcname} ${faction}
- /if (${Target.CleanName.Equal[${npcname}]}) {
- /varset FactionLevel ${faction}
- /if (${faction.Equal[attack]}) {
- /varset FactionLevel scowls
- } else {
- /if (${faction.Equal[you]}) {
- /varset FactionLevel scowls
- }
- }
- /varset FactionReturned 1
- | /squelch /target clear
- } else {
- | something got messed up
- /varset FactionReturned 0
- /varset FactionLevel ERROR
- }
- /return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement