Vixay,
Great script!!!
I'm new to this stuff, so I'm quite happy to have found yours. I changed a few things, like a more specific window name for ifwinactive. (not sure how well this will translate to other comps)
I also added a bunch of stuff that prevents Magicks that the user hasn't found from being cast by hotkeys. If the user hasn't manually cast Conflagration at least once, then any combo or hotkey that uses it will skip it. My way is probably a bit messy. Spacebar has to be pressed twice instead of once for any Magicks. Maybe there is a better way?
Code:
#SingleInstance force
#NoEnv
Process,Priority,qmagicka,High
;This works!!! for using send
SetKeyDelay , 25, 75
SetMouseDelay, 50
;this is necessary because magicka expects keys to be pressed for a specific time, this is the smallest interval that works reliably, you can experment more if you want. It seems like you can do it slightly faster when doing it manually
;SetKeyDelay , 0, 65, Play
;http://www.autohotkey.com/forum/viewtopic.php?p=418841#418841
;Fix for Win7 with UAC
if not A_IsAdmin ;if code does not have admin rerun it with them
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}
;settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Default keybindings - you can modify these if you have changed your settings
aoekey = RButton ;for use with shift for aoe effect use on own for standard cast
selfcastkey = MButton
shiftkey = LShift ;for use with aoe expression for aoe effect
water = q
heal = w
shield = e
cold = r
lightning = a
arcane = s
earth = d
fire = f
; the {@ 2} adds a delay that allows the combo to succeed as it needs a slightly longer delay
; not tested yet
ice = qr{@ 2}
steam = qf{@ 2}
;;spells
;From http://www.magickapedia.net/index.php?title=Magicks
;Using default keyboard shortcuts
;you must have the corresponding magick for it to work, they are gained as described below
; also I've modified some combinations in here to make them work in game, because the delay timings weren't working out exactly. So if you change the delay timings or you computer behaves slightly differently you might have to rever to original combo for those spells.
;another good way I found to add a delay is to append a useless key sequence like so: {p 20}
GreaseInt := false ;Variable for whether the spell is active in the hotleys
Grease = qdw ;Chapter 1: Found across the lake, shortly after hearing someone scream. Freeze the lake to get across. Covers the floor with slippery grease. Burns longer than normal fire when lit.
ReviveInt := false
Revive = wa ;Chapter 1: Obtained at the end of the tutorial. Revives human players.
HasteInt := false
Haste = asf ;Chapter 1: Required to complete the tutorial. Found on a bookshelf. Increases the wizards's movement speed.
MeteorShowerInt := false
MeteorShower = fdqfdf ;Chapter 1: Obtained at the start of the ;Chapter. This magick is a DLC bonus for all purchases made before January 31st, 2011. Conjures several meteors that impact random locations on the screen.
NullifyInt := false
Nullify = se ;Chapter 2: Found beside the altar where a goblin shaman is fought. Removes status effects from the caster. In addition, this spell cancels some (but not all) spells and magicks cast by other players and creatures. Most notably, the "mirror image" cast by Grimnír after the mind duel.
RainInt := false
Rain = qqqf ;Chapter 2: Found in the first cave you come across that is guarded by goblins. Causes it to rain, wetting all units on the screen except those with an active shield.
ThunderBoltInt := false
ThunderBolt = fqasaa ;Chapter 3: Found in a henge. Conjures a bolt that damages the most elevated unit heavily.
TornadoInt := false
Tornado = dqfqqqf ;Chapter 4: Before entering the city on the left of the main path in the trees by a shipwrecked boat. Summons a large tornado that flings everyone nearby up into the air, causing damage
ConflagrationInt := false
Conflagration = qffffffqfffq ;Chapter 4: Inside a burning building you are forced to detour through. Heat wave that deals 600 damage and sets on fire.
TimeWarpInt := false
TimeWarp = re ;Chapter 5: Head west immediately after leaving the camp. Slows time down for everyone - including the caster, although possibly by a slightly smaller degree - allowing you to react faster. Doesn't affect M60.
BlizzardInt := false
Blizzard = rrrqr ;Chapter 6: At the beginning of the ;Chapter, go east to the small lake. Use to get across the water. Summons a mighty blizzard, chilling everyone - including the caster! - for as long as it lasts (roughly 10 seconds?).
TeleportInt := false
Teleport = asa ;Chapter 7: On the broken walkway, after being transported by Vlad. There's also a way to get this Magick, as early as ;Chapter 1. To do this, you must first place Arcane/Fire mines ( ) near the base of the walkway. Make sure you place them whilst facing away from it. Then, walk over them to get blown up into the air. Some trial and error is to be expected in order for this to work. For further instructions, please see this video of the exploit. Instantly teleports the caster a short distance forward.
SummonPhoenixInt := false
SummonPhoenix = waf ;Chapter 8: After fighting the waves of Goblins and Trolls on a large bridge, keep heading right. Summons a Phoenix at the casters location, dealing fire damage to everyone nearby and reviving all fallen wizards.
ThunderstormInt := false
Thunderstorm = fqfqasaa ;Chapter 8: Just before the mines, after the first stone bridge (where you talk to Vlad) in a cave (hidden from view). Thunderbolt, now with 900% more glorious carnage! Effectively a mix of Rain and Thunderbolt, it will begin to rain both water and thunder from the skies, striking at random positions on the battlefield. Use with caution.
RaiseDeadInt := false
RaiseDead = qrdsr ;Chapter 9: After defeating the necromancers in the run-down church. Summons a few undead ghouls to fight for the caster.
FearInt := false
Fear = rse ;Chapter 9: Found in the first room of the Count's castle on the left sitting on a bookshelf. Every enemie nearby is scared witless, running in random directions away from the caster for approximately 3 seconds.
CharmInt := false
Charm = wed ;Chapter 9: Found in the first room of the Count's castle on the right leaning on the wooden furniture next to the couches. The targeted creature temporarily becomes your ally, attacking your enemies.
SummonDeathInt := false
SummonDeath = srrqrs ;Chapter 10: Given to the player after defeating Death. Summons Death, who will proceed to instantly kill the nearest player or creature with the lowest amount of health remaining.
SummonElementalInt := false
SummonElemental = sedqfs ;Chapter 11: After defeating the small detachment of dwarves in the second room of the cathedral, go northwest over the narrow bridge. Open the door, and the book will be on a pedestal. Summons an inactive elemental. To activate the elemental, simply attack it with any element. The elemental will take the form of whichever element touches it first, and will subsequently be healed by that same element.
CorporealizeInt := false
Corporealize = sqfaes ;Chapter 11: Given to the player after defeating Fafnir. Used when fighting Assatur. Also causes any ethereal daemons to materialize and become corporeal.
InvisibilityInt := false
Invisibility = seqfs ;Chapter 11: In the first area, head south along the cliff you find to the east instead of entering the fortress. Makes the caster invisible. Enemies will no longer actively attack the caster, although arrows, charging enemies and other AoE attacks will still hit the caster. Invisibility ends after casting, attacking, taking damage or colliding with a foe.
VortexInt := false
Vortex = qrsqreqr ;Chapter 12: Given to you after defeating the final boss. Summons a large vortex that sucks in and crushes anyone careless enough to wander close.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;attack/defence combos
;http://www.magickapedia.net/index.php?title=Spell_Combinations
; you can define them using keys or names;
; eg. surge_c = qqqqq or surge_c := water water water water water
; note the ':' before the equal in the second definition using names, thats to force it to evalue it as an expression
superwetsteamlightning_c = sfqfqfqar
supersteamlightning_c = sfqfqaa
surge_c = qqqqq
blizzardball_c = dqrqrqrqr
coldquake_c = drddd
barrierrock_c = edddd
barrierice_c = eqwd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;other init
WinWait, Magicka,
IfWinNotActive, Magicka, , WinActivate, Magicka,
WinWaitActive, Magicka,
;selfcast(heal heal)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;KeyStrings to activate Magicks:
;;These are the elemental combos that activate the Magicks. Users will have to press Space twice to use these, but after used once, the shortcuts will work for them.
::qdw::
GreaseInt := true
return
::wa::
ReviveInt := true
return
::asf::
HasteInt := true
return
::fdqfdf::
MeteorShowerInt := true
return
::se::
NullifyInt := true
return
::qqf::
RainInt := true
return
::qfasa::
ThunderBoltInt := true
return
::fqasa::
ThunderBoltInt := true
return
::dqfqqf::
TornadoInt := true
return
::dfqqqf::
TornadoInt := true
return
::fqffqffq::
ConflagrationInt := true
return
::qfffqffq::
ConflagrationInt := true
return
::re::
TimeWarpInt := true
return
::rrrqr::
BlizzardInt := true
return
::asa::
TeleportInt := true
return
::waf::
SummonPhoenixInt := true
return
::fqfqasa::
ThunderstormInt := true
return
::qfqfasa::
ThunderstormInt := true
return
::fqqfasa::
ThunderstormInt := true
return
::qffqasa::
ThunderstormInt := true
return
::qrdsr::
RaiseDeadInt := true
return
::rqdsr::
RaiseDeadInt := true
return
::rse::
FearInt := true
return
::wed::
CharmInt := true
return
::srrqrs::
SummonDeathInt := true
return
::sedqfs::
SummonElementalInt := true
return
::sedfqs::
SummonElementalInt := true
return
::sqfaes::
CorporealizeInt := true
return
::sfqaes::
CorporealizeInt := true
return
::seqfs::
InvisibilityInt := true
return
::rqsrqerq::
VortexInt := true
return
::qrsqreqr::
VortexInt := true
return
::qrsrqeqr::
VortexInt := true
return
::qrsrqerq::
VortexInt := true
return
::rqsqreqr::
VortexInt := true
return
::rqsrqeqr::
VortexInt := true
return
::qrsqreqr::
VortexInt := true
return
::qrsqrerq::
VortexInt := true
return
;;Shortcuts
#IfWinActive, ahk_class WindowsForms10.Window.8.app.0.33c0d9d
;;;combinations of various actions
; delays are necessary in combos, otherwise they don't work correctly, i've tested these and tweaked the delays a bit
fastmode_combo(){
spellcast(TimeWarp,TimewarpInt)
spellcast(Haste,HasteInt)
}
;any other ideas for good combos?
F1:: ;defense_combo() {
selfcast(heal heal,100)
;selfcast(shield,100)
selfcast(water shield,100)
spellcast(Haste,HasteInt,500)
;spellcast(TimeWarp,TimeWarpInt,500)
selfcast(barrierrock_c,200)
;loadcombo(superwetsteamlightning_c)
forcebeam(blizzardball_c)
return
F2:: ;freeze_combo() {
aoe(steam steam steam steam steam,100) ;wet
aoe(cold cold cold cold cold,100) ;freeze
aoe(superwetsteamlightning_c) ;destroy
return
F3:: ;freezeall_combo() ; have a shield on!
selfcast(water shield,100)
spellcast(Rain,RainInt,2500)
selfcast(water shield, 100)
spellcast(Blizzard,BlizzardInt,500)
return
F4:: ;thunder_combo() ;your own awesome thunderstorm!! hold down to continue using it! must have shield on before using it
selfcast(water shield,100)
spellcast(Rain,RainInt,2000)
spellcast(ThunderBolt,ThunderBoltInt,500)
;continue casting spell as long as key is held down,
; your own thunderstorm!! without the self gibbing!
While GetKeyState(A_ThisHotkey, "P")
{
spellcast(ThunderBolt,ThunderBoltInt,500)
}
return
F5::spellcast(Conflagration,ConflagrationInt)
F6::spellcast(Blizzard,BlizzardInt)
F7::spellcast(Tornado,TornadoInt)
F8::spellcast(Invisibility,InvisibilityInt)
F9::spellcast(Fear,FearInt)
F10::spellcast(Charm,CharmInt)
F12::run Z:\Games\Magicka\Magicka.exe
!^r::Reload
;Spells/Magicks
1::spellcast(Haste,HasteInt)
2::spellcast(TimeWarp,TimeWarpInt)
3::selfcast(water shieldInt)
4::spellcast(Rain,RainInt)
5::spellcast(ThunderBolt,ThunderBoltInt)
6::spellcast(Teleport,TeleportInt)
7::spellcast(SummonElemental,SummonElementalInt)
8::spellcast(Corporealize,CorporealizeInt)
9::spellcast(RaiseDead,RaiseDeadInt)
0::spellcast(Vortex,VortexInt)
;attack/defence combos
z::forcebeam(supersteamlightning_c)
x::aoe(supersteamlightning_c)
c::selfcast(shield)
v::selfcast(heal heal)
b::forcebeam(blizzardball_c)
n::loadcombo(superwetsteamlightning_c)
m::forcebeam("sar")
,::resetkeys()
g::selfcast(barrierrock_c)
h::selfcast(barrierice_c)
j::aoe(surge_c)
k::aoe(coldquake_c)
; from j-Factor @ http://www.reddit.com/r/magicka/comments/fcvi5/macroing_with_autohotkey_dont_do_this_unless_you/
; use with loadcombo
; Melee - mouse button 4
XButton1::
If GetKeyState("LButton", "P")
SendEvent {Click up}
While GetKeyState("XButton1", "P")
{
SendEvent +{Click}
}
If GetKeyState("LButton", "P")
SendEvent {Click down}
Return
; AOE - mouse button 5
XButton2::
SendEvent {Shift down}{Click down right}
While GetKeyState("XButton2", "P")
{
}
SendEvent {Shift up}{Click up right}
Return
#IfWinActive
;;;typesofattack - utility functions
resetkeys(){
send {LShift up}{Rbutton up}{Lbutton up}{Mbutton up}
}
;no clicks - use with xbutton1(melee) or xbutton2(aoe) or right click
loadcombo(str){
send %str%
}
;right click
forcebeam(str, delay = 0){
send %str%{Rbutton down}
sleep delay
}
;shift right click
aoe(str, delay = 25){
send %str%{LShift down}{Rbutton down}
sleep 65 ;the sleeps should no longer be necessary if setmousedelay works correctly
send {Rbutton up}{Lshift up}
sleep delay
}
;middle click
selfcast(str, delay = 25){
send %str%{Mbutton down}
sleep 65
send {Mbutton up}
sleep delay
}
;shift left click
imbueweapon(str, delay = 25){
send %str%{LShift down}{Lbutton down}
sleep 65
send {Lbutton up}{Lshift up}
sleep delay
}
;space
spellcast(str, active, delay = 25){
if active
{
send %str%{Space down}
sleep 65
send {Space up}
sleep delay
}
}
;;;;;;
;;; End script