• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Spell help - DotAs Axes

Status
Not open for further replies.
Level 2
Joined
Nov 7, 2007
Messages
8
Hi, ok i get the Axes code from Dota and i want to use this spell using the handle vars or cs_cache , tables. Can anyone help me with this? please

JASS:
// A0O1 = Wild Axes
function Trig_Beastmaster_Spell_WildAxes_Conditions takes nothing returns boolean
	if(GetSpellAbilityId()=='A0O1')then
		return true
	endif
	return false
endfunction

function kdkd takes nothing returns nothing
	call KillDestructable(GetEnumDestructable())
endfunction

// A04R = Marker
// A0O1 = Wild Axes
function kDkD takes unit Emm,real x,real y,group kee returns nothing
	local group fAA=CreateGroup()
	local unit fzz
	local rect kEE=Rect(x-150,y-150,x+150,y+150)
	call GroupEnumUnitsInRange(fAA,x,y,150,null)
	loop
		set fzz=FirstOfGroup(fAA)
		exitwhen fzz==null
		if(IsUnitInGroup(fzz,kee)==false and IsUnitEnemy(fzz,GetOwningPlayer(Emm)) and IsUnitVisible(fzz,GetOwningPlayer(Emm)))then
			if(GetUnitAbilityLevel(fzz,'A04R')!=1 and GetUnitState(fzz,UNIT_STATE_LIFE)>0 and IsUnitType(fzz,UNIT_TYPE_STRUCTURE)==false)then
				call GroupAddUnit(kee,fzz)
				call UnitDamageTarget(Emm,fzz,60+GetUnitAbilityLevel(Emm,'A0O1')*30,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_HEAVY_SLICE)
				call AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",fzz,"overhead")
			endif
		endif
		call GroupRemoveUnit(fAA,fzz)
	endloop
	call EnumDestructablesInRect(kEE,null,function kdkd)
	call RemoveRect(kEE)
	call DestroyGroup(fAA)
endfunction

function kfkf takes nothing returns nothing
	local string fTT=H2S(GetExpiredTimer())
	local unit kFF=GetStoredDTAXUnit(fTT,"Axe")
	local unit fyy=GetStoredDTAXUnit(fTT,"Hero")
	local real Axx=GetStoredDTAXReal(fTT,"Ax")
	local real Ayy=GetStoredDTAXReal(fTT,"Ay")
	local real Cxx=GetStoredDTAXReal(fTT,"Cx")
	local real Cyy=GetStoredDTAXReal(fTT,"Cy")
	local real Bxx=GetStoredDTAXReal(fTT,"Bx")
	local real Byy=GetStoredDTAXReal(fTT,"By")
	local real a=GetStoredDTAXReal(fTT,"a")
	local real b=1-a
	local boolean kgg=GetStoredDTAXBoolean(fTT,"FirstPass")
	local group kee=GetStoredDTAXGroup(fTT,"AlreadyDamaged")
	call SetUnitX(kFF,IsXInPlayeableArea(Axx*a*a+Bxx*2*a*b+Cxx*b*b))
	call SetUnitY(kFF,IsYInPlayeableArea(Ayy*a*a+Byy*2*a*b+Cyy*b*b))
	call kDkD(fyy,GetUnitX(kFF),GetUnitY(kFF),kee)
	if(kgg)then
		call StoreDTAXReal(fTT,"a",a-.02)
	else
		call StoreDTAXReal(fTT,"a",a+.02)
		call StoreDTAXReal(fTT,"Ax",GetUnitX(fyy))
		call StoreDTAXReal(fTT,"Ay",GetUnitY(fyy))
	endif
	if(a<0 and kgg)then
		call StoreDTAXBoolean(fTT,"FirstPass",false)
		call StoreDTAXReal(fTT,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)+GetStoredDTAXReal(fTT,"AngleOffset")))
		call StoreDTAXReal(fTT,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)+GetStoredDTAXReal(fTT,"AngleOffset")))
	endif
	if(a>1 and kgg==false)then
		call PauseTimer(GetExpiredTimer())
		call DestroyGroup(kee)
		call FlushStoredMissionShell(fTT)
		call RemoveUnit(kFF)
		call PolledWait(.1)
		call DestroyTimer(GetExpiredTimer())
	endif
endfunction

// e01T = Boomerang
// Amrf = Crow Form
function Trig_Beastmaster_Spell_WildAxes_Actions takes nothing returns nothing
	local unit Emm=GetTriggerUnit()
	local real Axx=GetUnitX(Emm)
	local real Ayy=GetUnitY(Emm)
	local real Cxx=GetLocationX(GetSpellTargetLoc())
	local real Cyy=GetLocationY(GetSpellTargetLoc())
	local unit khh=CreateUnit(GetOwningPlayer(Emm),'e01T',Axx,Ayy,270.)
	local unit kHH=CreateUnit(GetOwningPlayer(Emm),'e01T',Axx,Ayy,270.)
	local string kii
	local string kII
	local timer kjj=CreateTimer()
	local timer kJJ=CreateTimer()
	call UnitAddAbility(khh,'Amrf')
	call UnitRemoveAbility(khh,'Amrf')
	call SetUnitFlyHeight(khh,150,0)
	call UnitAddAbility(kHH,'Amrf')
	call UnitRemoveAbility(kHH,'Amrf')
	call SetUnitFlyHeight(kHH,150,0)
	set kii=H2S(kjj)
	call StoreDTAXObject(kii,"Hero",Emm)
	call StoreDTAXObject(kii,"Axe",khh)
	call StoreDTAXObject(kii,"AlreadyDamaged",CreateGroup())
	call StoreDTAXReal(kii,"Ax",Axx)
	call StoreDTAXReal(kii,"Ay",Ayy)
	call StoreDTAXReal(kii,"Cx",Cxx)
	call StoreDTAXReal(kii,"Cy",Cyy)
	call StoreDTAXReal(kii,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)+45))
	call StoreDTAXReal(kii,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)+45))
	call StoreDTAXReal(kii,"a",1)
	call StoreDTAXReal(kii,"AngleOffset",-45)
	call StoreDTAXBoolean(kii,"FirstPass",true)
	set kII=H2S(kJJ)
	call StoreDTAXObject(kII,"Hero",Emm)
	call StoreDTAXObject(kII,"Axe",kHH)
	call StoreDTAXObject(kII,"AlreadyDamaged",CreateGroup())
	call StoreDTAXReal(kII,"Ax",Axx)
	call StoreDTAXReal(kII,"Ay",Ayy)
	call StoreDTAXReal(kII,"Cx",Cxx)
	call StoreDTAXReal(kII,"Cy",Cyy)
	call StoreDTAXReal(kII,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)-45))
	call StoreDTAXReal(kII,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)-45))
	call StoreDTAXReal(kII,"a",1)
	call StoreDTAXReal(kII,"AngleOffset",45)
	call StoreDTAXBoolean(kII,"FirstPass",true)
	call TimerStart(kjj,.035,true,function kfkf)
	call TimerStart(kJJ,.035,true,function kfkf)
endfunction

function StartTrigger_Beastmaster_Spell_WildAxes takes nothing returns nothing
	set gg_trg_Beastmaster_Spell_WildAxes=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Beastmaster_Spell_WildAxes,EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Beastmaster_Spell_WildAxes,Condition(function Trig_Beastmaster_Spell_WildAxes_Conditions))
	call TriggerAddAction(gg_trg_Beastmaster_Spell_WildAxes,function Trig_Beastmaster_Spell_WildAxes_Actions)
endfunction

function InitTrig_Beastmaster_Spell_WildAxes takes nothing returns nothing
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
This one's syntax:

StoreDTAX<Type>
GetStoredDTAX<Type>

(Handle is called Object here)

Handle vars syntax:

SetHandle<Type>
GetHandle<Type>

(Handle is called Handle)

CSCache syntax:

Attach<Type>
GetAttached<Type>

(Handle is called Object)


Flushing syntaxes --

This:

FlushStoredMissionShell

Handle Vars:

FlushHandleLocals

CSCache:

CleanAttachedVars



Basically, start renaming ;)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
JASS:
// A0O1 = Wild Axes
function Trig_Beastmaster_Spell_WildAxes_Conditions takes nothing returns boolean
	return GetSpellAbilityId()=='A0O1'
endfunction

function kdkd takes nothing returns nothing
	call KillDestructable(GetEnumDestructable())
endfunction

// A04R = Marker
// A0O1 = Wild Axes
function kDkD takes unit Emm,real x,real y,group kee returns nothing
	local group fAA=CreateGroup()
	local unit fzz
	local rect kEE=Rect(x-150,y-150,x+150,y+150)
	call GroupEnumUnitsInRange(fAA,x,y,150,null)
	loop
		set fzz=FirstOfGroup(fAA)
		exitwhen fzz==null
		if(IsUnitInGroup(fzz,kee)==false and IsUnitEnemy(fzz,GetOwningPlayer(Emm)) and IsUnitVisible(fzz,GetOwningPlayer(Emm)))then
			if(GetUnitAbilityLevel(fzz,'A04R')!=1 and GetUnitState(fzz,UNIT_STATE_LIFE)>0 and IsUnitType(fzz,UNIT_TYPE_STRUCTURE)==false)then
				call GroupAddUnit(kee,fzz)
				call UnitDamageTarget(Emm,fzz,60+GetUnitAbilityLevel(Emm,'A0O1')*30,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_HEAVY_SLICE)
				call AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",fzz,"overhead")
			endif
		endif
		call GroupRemoveUnit(fAA,fzz)
	endloop
	call EnumDestructablesInRect(kEE,null,function kdkd)
	call RemoveRect(kEE)
	call DestroyGroup(fAA)
	set fAA = null
	set kEE = null
endfunction

function kfkf takes nothing returns nothing
    local timer t = GetExpiredTimer()
	local unit kFF=GetHandleUnit(t,"Axe")
	local unit fyy=GetHandleUnit(t,"Hero")
	local real Axx=GetHandleReal(t,"Ax")
	local real Ayy=GetHandleReal(t,"Ay")
	local real Cxx=GetHandleReal(t,"Cx")
	local real Cyy=GetHandleReal(t,"Cy")
	local real Bxx=GetHandleReal(t,"Bx")
	local real Byy=GetHandleReal(t,"By")
	local real a=GetHandleReal(t,"a")
	local real b=1-a
	local boolean kgg=GetHandleBoolean(t,"FirstPass")
	local group kee=GetHandleGroup(t,"AlreadyDamaged")
	call SetUnitX(kFF,IsXInPlayeableArea(Axx*a*a+Bxx*2*a*b+Cxx*b*b))
	call SetUnitY(kFF,IsYInPlayeableArea(Ayy*a*a+Byy*2*a*b+Cyy*b*b))
	call kDkD(fyy,GetUnitX(kFF),GetUnitY(kFF),kee)
	if(kgg)then
		call SetHandleReal(t,"a",a-.02)
	else
		call SetHandleReal(t,"a",a+.02)
		call SetHandleReal(t,"Ax",GetUnitX(fyy))
		call SetHandleReal(t,"Ay",GetUnitY(fyy))
	endif
	if(a<0 and kgg)then
		call SetHandleBoolean(t,"FirstPass",false)
		call SetHandleReal(t,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)+GetHandleReal(t,"AngleOffset")))
		call SetHandleReal(t,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)+GetHandleReal(t,"AngleOffset")))
	endif
	if(a>1 and kgg==false)then
		call PauseTimer(GetExpiredTimer())
		call DestroyGroup(kee)
		call FlushHandleLocals(t)
		call RemoveUnit(kFF)
		call PolledWait(.1)
		call DestroyTimer(GetExpiredTimer())
    endif
    set t = null
    set kFF = null
    set fyy = null
    set kee = null
endfunction

// e01T = Boomerang
// Amrf = Crow Form
function Trig_Beastmaster_Spell_WildAxes_Actions takes nothing returns nothing
	local unit Emm=GetTriggerUnit()
	local real Axx=GetUnitX(Emm)
	local real Ayy=GetUnitY(Emm)
	local location l = GetSpellTargetLoc()
	local real Cxx=GetLocationX(l)
	local real Cyy=GetLocationY(l)
	local unit khh=CreateUnit(GetOwningPlayer(Emm),'e01T',Axx,Ayy,270.)
	local unit kHH=CreateUnit(GetOwningPlayer(Emm),'e01T',Axx,Ayy,270.)
	local timer kjj=CreateTimer()
	local timer kJJ=CreateTimer()
	call RemoveLocation(l)
	call UnitAddAbility(khh,'Amrf')
	call UnitRemoveAbility(khh,'Amrf')
	call SetUnitFlyHeight(khh,150,0)
	call UnitAddAbility(kHH,'Amrf')
	call UnitRemoveAbility(kHH,'Amrf')
	call SetUnitFlyHeight(kHH,150,0)
	call SetHandleHandle(kjj,"Hero",Emm)
	call SetHandleHandle(kjj,"Axe",khh)
	call SetHandleHandle(kjj,"AlreadyDamaged",CreateGroup())
	call SetHandleReal(kjj,"Ax",Axx)
	call SetHandleReal(kjj,"Ay",Ayy)
	call SetHandleReal(kjj,"Cx",Cxx)
	call SetHandleReal(kjj,"Cy",Cyy)
	call SetHandleReal(kjj,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)+45))
	call SetHandleReal(kjj,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)+45))
	call SetHandleReal(kjj,"a",1)
	call SetHandleReal(kjj,"AngleOffset",-45)
	call SetHandleBoolean(kjj,"FirstPass",true)
	
	call SetHandleHandle(kJJ,"Hero",Emm)
	call SetHandleHandle(kJJ,"Axe",kHH)
	call SetHandleHandle(kJJ,"AlreadyDamaged",CreateGroup())
	call SetHandleReal(kJJ,"Ax",Axx)
	call SetHandleReal(kJJ,"Ay",Ayy)
	call SetHandleReal(kJJ,"Cx",Cxx)
	call SetHandleReal(kJJ,"Cy",Cyy)
	call SetHandleReal(kJJ,"Bx",Axx+300*Cos(Atan2(Cyy-Ayy,Cxx-Axx)-45))
	call SetHandleReal(kJJ,"By",Ayy+300*Sin(Atan2(Cyy-Ayy,Cxx-Axx)-45))
	call SetHandleReal(kJJ,"a",1)
	call SetHandleReal(kJJ,"AngleOffset",45)
	call SetHandleBoolean(kJJ,"FirstPass",true)
	call TimerStart(kjj,.035,true,function kfkf)
	call TimerStart(kJJ,.035,true,function kfkf)
	
	set Emm = null
	set l = null
	set khh = null
	set kHH = null
	set kjj = null
	set kJJ = null
endfunction

function StartTrigger_Beastmaster_Spell_WildAxes takes nothing returns nothing
	set gg_trg_Beastmaster_Spell_WildAxes=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Beastmaster_Spell_WildAxes,EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Beastmaster_Spell_WildAxes,Condition(function Trig_Beastmaster_Spell_WildAxes_Conditions))
	call TriggerAddAction(gg_trg_Beastmaster_Spell_WildAxes,function Trig_Beastmaster_Spell_WildAxes_Actions)
endfunction

function InitTrig_Beastmaster_Spell_WildAxes takes nothing returns nothing
endfunction

You know, PurplePoot isn't the only jasser here.

Make sure you got Handle vars implemented.

Also fixed some retarded leaks and some other retarded stuff. Spells shouldn't have leaks!!! Especially in the most popular AOS!!!

EDIT: Screw you Pooty!

Anyways, listen to me, not Pooty, his way is not completely right.

Object > Handle (in handle vars)

And he also forgot to say that you should put timers instead of strings in those functions' arguments, otherwise you would get errors. You should get rid of those strings (well, now you don't have to do anything since I wrote you the code, you just have to implement handle vars).

You thought you could get away with it, huh Pooty?? He's trying to sabotage you LucentLain, he's evil.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
What is retarded/smart about it?
Retarded because it doesn't take a timer <because that's what people are used to>, but it's not really. It's actually smart, because H2I is slow.

What do you mean? They have timers converted to strings and they use those strings as arguments.
The storing functions actually take a timer - I didn't take too long to look at the grabbing functions too.

EDIT: Ah, nevermind, it always uses strings... those variable names are really confusing.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
I don't know why they name their vars that way, and the code has few leaks...... that's really retarded.

I noticed they don't null their locals.......ever, how come that's not a leak? It should by all means be a leak, but no DotA player was complaining about massive lags in the late game.......
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Why do people null locals if even dota doesn't with their tons of non-nulled locals?

I believe that that location leak (GetSpellTargetLoc()) is bad, far worse than non-nulled locals. And it also leaks twice. But the game still doesn't lag......
 
Status
Not open for further replies.
Top