月度归档:2019年03月

暗黑3宏

AHK宏,AHK下载地址:https://www.autohotkey.com/

使用方法:

  • 安装程序
  • 下载.ahk代码 (推荐zip,如果复制源码,需要保存为UTF8-BOM格式
  • 双击.ahk运行
  • 只适用于暗黑3,64位
  • 如想暂停,在任务栏右下角找到绿色H图标,右键,停止宏。
  • 本地调整修改之后,同样找到H图标,右键,重新载入宏。

散黑奥宏:

https://bideyuanli.com/wp-content/themes/d3/ahk/bideyuanli_aoyun_v1.1.ahk.zip

#SingleInstance force
#IfWinActive, ahk_class D3 Main Window Class

Hotkey, F4, ToggleOff, ; 总开关
Hotkey, F5, MatchCoe, On ; 手动对齐元素戒,0秒应该在奥元素内
Hotkey, r, ToggleAuto, On ; 自动模式开关

DianxingKey := 1 ;电刑按键
YindaoKey := "RButton" ;引导按键
HeidongKey := "LButton" ;黑洞按键
YuanliboKey := 2 ;原力波按键
YunshiKey := 3 ;陨石按键
HeirenKey := 4 ;黑人按键

YidongKey := "d" ;强制移动按键,强制移动期间不会发技能(除了黑人)
ZhanliKey := "Shift" ;强制站立键,只会在用左键是使用

DuboKey := "e" ;赌博按键,按住狂点右键

CoeCircle := 32000 ;元素戒周期


Init()
return

InitProfile() {
  global
  StopAll()
  Skills := []
  Skills.push( new CoeDisplay() )
  SKills.push( new CrazyClick(DuboKey, "RButton") )

  if (Profile = WIZ) {
    ; 0秒变身
    SKills.push( new Skill(HeirenKey, 0, 500, false) )
    ; 黑人期间打1维持勾玉
    SKills.push( new Skill(1, 500, 19000, false, true) )
    
    
    ; 第一发陨石
    SKills.push( new Skill(DianxingKey, 20000, 2200) )
    SKills.push( new Skill(HeidongKey, 22360, 400) )
    SKills.push( new Skill(YuanliboKey, 22930, 400) )
    SKills.push( new Skill(DianxingKey, 23500, 1100) )
    SKills.push( new Skill(YunshiKey, 24760, 500) )
    SKills.push( new Skill(DianxingKey, 25310, 500) )
    SKills.push( new Skill(YindaoKey, 25960, 300) )
    
    SKills.push( new Skill(DianxingKey, 26550, 400) )
    
    ; 第二发陨石,这个黑洞不知道能不能覆盖陨石。
    SKills.push( new Skill(HeidongKey, 27200, 400) )
    SKills.push( new Skill(YuanliboKey, 27780, 400) )
    ; 间歇时间,可以按强制移动找圈
    SKills.push( new Skill(DianxingKey, 28400, 1800) )
    ; 重要!第二发陨石的发起时间
    SKills.push( new Skill(YunshiKey, 30700, 200) )
    SKills.push( new Skill(DianxingKey, 30970, 400) )
    SKills.push( new Skill(YindaoKey, 31900, 50) )
  }
  
  return
}

Init() {
  global

  ; 每20ms执行一次,减少可以增加准确率,但是提高cpu负担。
  INTERVAL := 20
  
  ; enum values
  RIFT := 100
  AUTO := RIFT + 1
  RBUTTON := RIFT + 2
  
  PROFILE_START := 200
  WIZ := PROFILE_START
  ;MONK := PROFILE_START + 1
  ;BARB := PROFILE_START + 2
  PROFILE_END := PROFILE_START + 10
  
  OFF := false
  InAuto := false
  InRift := false
  RButtonDown := false
  MoveDown := false
  CurrentTime := 0
  CoeStartTime := 0
  Skills := []
  Profiles := [WIZ]
  Profile := WIZ

  WinGetPos, , , Width, Height, ahk_class D3 Main Window Class
  InfoTextX := Floor(0.4 * Width)
  InfoTextY := Floor(0.2 * Height)
  ResetX := Floor(0.504 * Width)
  ResetY := Floor(0.679 * Height)
  OkX := Floor(0.426 * Width)
  OkY := Floor(0.755 * Height)

  InitProfile()
  ShowInfo("Start !!!!!!!!!!!!!!!!!")
  SetTimer, MainRun, %INTERVAL%
}

SwitchProfile:
{
  Profile++
  while (not Profile in Profiles) {
    Profile++
    if (Profile = PROFILE_END) {
      Profile := PROFILE_START
    }
  }
  InitProfile()
  return
}


class Skill {
  key := 1
  start := 0
  end := 0
  mode := AUTO
  started := false
  stopOnMove := true
  isClick := false

  __New(keyIn, startIn, time, stopOnMoveIn = true, isClickIn = false) {
    this.key := keyIn
    this.start := startIn
    this.end := startIn + time
    this.stopOnMove := stopOnMoveIn
    this.isClick := isClickIn
  }
  
  ShouldRun() {
    global
    if (OFF = true) {
      return false
    }
    if (this.mode = RBUTTON) {
      return RButtonDown
    } else if (this.mode = RIFT) {
      return InRift
    } else if (this.mode = AUTO) {
      return InAuto
    }
    return true
  }
  
  Hit() {
    shouldRun := this.CheckStatus()
	if (this.isClick && shouldRun) {
	  key := this.key
	  Send, %key%
	  return
	}
    if (this.started && !shouldRun) {
      this.EndSkill()
    } else if (!this.started && shouldRun) {
      this.StartSkill()
    }
  }
  
  CheckStatus() {
    global MoveDown, CurrentTime
    
    if (!this.ShouldRun()) {
      return false
    }
    if (this.stopOnMove && MoveDown) {
      return false
    }
    
    time := CurrentTime
    if (time < this.start || time > this.end) {
      return false
    }

    return true
  }
  
  StartSkill() {
    global
	  this.started := true
    if (this.key == "LButton") {
      Send {%ZhanliKey% Down}
    }
    key := this.key
    Send {%key% down}
  }
  
  EndSkill() {
    global
	  this.started := false
    if (this.key == "LButton") {
      Send {%ZhanliKey% Up}
    }
	  key := this.key
    Send {%key% up}
  }
}

class CrazyClick {
  triggerKey := ""
  sendKey := ""
  __New(triggerKey, sendKey) {
    this.triggerKey := triggerKey
    this.sendKey := sendKey
  }
  
  Hit() {
    global OFF
    if (OFF = true) {
      return
    }
    if GetKeyState(this.triggerKey,"P")
    {
	    key := this.sendKey
      Send {%key%}
    }
  }
}

class CoeDisplay {
  time := 0
  Hit() {
    global CurrentTime
    if (OFF = true) {
      return
    }
    time := Floor(CurrentTime / 1000)
    if (this.time != time) {
      ShowInfo(time)
      this.time := time
    }
  }
}


MainRun:
{
  if (OFF = true) {
    return
  }
  if !WinActive("ahk_class D3 Main Window Class") {
    return
  }

  CurrentTime := Mod(A_TickCount - CoeStartTime, CoeCircle)
  RButtonDown := GetKeyState("RButton", "P")
  MoveDown := GetKeyState(YidongKey, "P")
  For index, skill in Skills {
    skill.Hit()
  }
  return
}


StopAll() {
  For index, skill in Skills {
    skill.EndSkill()
  }
}

ToggleOff:
{
  OFF := !OFF
  InAuto := false
  InRift := false
  if (OFF) {
    StopAll()
    ShowInfo("OFF")
  } else {
    ShowInfo("ON")
  }
  return
}


ToggleRift:
{
  InRift := !InRift
  if (InRift) {
    ShowInfo("In rift now!")
  } else {
    ShowInfo("leave rift")
  }
  return
}


ToggleAuto:
{
  InAuto := !InAuto
  if (InAuto) {
    ShowInfo("Auto mode now!")
  } else {
    ShowInfo("leave auto mode")
  }
  return
}


MatchCoe:
{
  CoeStartTime := A_TickCount
  ShowInfo("Match")
  return
}


ClearInfo()
{
	global
	
  if (InfoTime < A_TickCount - 1000) {
	GuiControl,,InfoText,
  }
  return
}

ShowInfo(text)
{
  global
  InfoTime := A_TickCount
  if WinExist("ahk_class AutoHotkeyGUI") {
    GuiControl,,InfoText,%text%
    return
  }
  CustomColor = 000000
  Placeholder := "         "
  Gui +LastFound +E0x0000008 -Caption +E0x8000000 +E0x00080000 +Disabled
  	Gui, Color, %CustomColor%
  Gui, Font, s48
  Gui, Add, Text, vInfoText cLime Center , %Placeholder%%text%%Placeholder%
  WinSet, TransColor, %CustomColor% 150
  Gui, Show, xCenter y%InfoTextY%
  SetTimer, ClearInfo, 400
  return
}