How to create a Spell like Berserker's Call in DotA?

Rainther

I guess I should write something of value here...
Reaction score
61
Sure, please answer my question first: Do you only have one of these heroes?
 

joohen

New Member
Reaction score
20
Yes. I had the hero which has the Taunt abitity.

EDIT: Oh, sorry my bad. I had only one hero with that ability.
 

TideOfChaos

New Member
Reaction score
25
There is no need for unit groups.
Just every 0.03 (or what have you) seconds of game time, pick every unit that has taunter buff (unit that casts gets the buff) and then pick all units in X units around them and order them to attack the taunter.
 

Rainther

I guess I should write something of value here...
Reaction score
61
You fail you answe my question. If there's only one hero of this kind with this ability it should be as simple as this:
Trigger:
  • Taunter
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Triggering unit) has buff Taunted) Equal to True
    • Actions
      • Set TempGroup= (Units of type Taunter)
      • Unit - Order (Triggering unit) to Attack (Random unit from TempGroup)
      • Custom script: call DestroyGroup(udg_TempGroup)
Hope it solves the problem.

There is no need for unit groups.
Just every 0.03 (or what have you) seconds of game time, pick every unit that has taunter buff (unit that casts gets the buff) and then pick all units in X units around them and order them to attack the taunter.

I believe even if the intervall is as short as 0.03 you still have time to activate windwalk and berserk.
 

joohen

New Member
Reaction score
20
uhh... well, it ALMOST worked. It was like, my hero is hitting him, and i was trying to test whether it can run away anot but a there was a surprise for me.My warcraft epicly crash or closed without any fatal error at all. Tried twice, crash twice, what happened? :confused:
 

Kikac_NNGK

Well-Known Member
Reaction score
33
i had the same problem. Try using the action "Turn off this trigger" at the first place in actions and then put the action "Turn on this trigger" at the end of the trigger
 

Rainther

I guess I should write something of value here...
Reaction score
61
Oh yeah. Forgot about it :p thanks Kikac. The trigger gives itself an everlasting loop which I forgot about.

Use this instead:
Trigger:
  • Taunter
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Triggering unit) has buff Taunted) Equal to True
    • Actions
      • Set TempGroup= (Units of type Human Footman)
      • Trigger - Turn off (This trigger)
      • Unit - Order (Triggering unit) to Attack (Random unit from TempGroup)
      • Trigger - Turn on (This trigger)
      • Custom script: call DestroyGroup(udg_TempGroup)

This makes the event to not trigger itself.
 

ShadourazeR

New Member
Reaction score
0
then order them every 0.1 seconds :rolleyes:

Don't put it 0.5 seconds, or 0.1 seconds, both of them would make units unable to attack the calling unit...

It's not exactly like dota, but its efficient to order units to attack once and then just loop an action to unselect them.
 

ShadourazeR

New Member
Reaction score
0
Oh yeah. Forgot about it :p thanks Kikac. The trigger gives itself an everlasting loop which I forgot about.

Use this instead:
Trigger:
  • Taunter
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • ((Triggering unit) has buff Taunted) Equal to True
    • Actions
      • Set TempGroup= (Units of type Human Footman)
      • Trigger - Turn off (This trigger)
      • Unit - Order (Triggering unit) to Attack (Random unit from TempGroup)
      • Trigger - Turn on (This trigger)
      • Custom script: call DestroyGroup(udg_TempGroup)

This makes the event to not trigger itself.

Note that if it is a custom hero map, the TempGroup must be set before it, and also needs to be an array, making a Tempgroup for each player in the game, and the ability also needs to give a buff to the caster, so the trigger can recognize who is casting it and who is not.
 

Rainther

I guess I should write something of value here...
Reaction score
61
I asked him 2 times if he planned on using the hero more the once. If only used once most of the problems dissapear, however I never received an answer.
 

pneric

New Member
Reaction score
1
This thread makes me want to start a "How did they do that spell in DotA?"; just a simple thread where people can ask a skill in DotA and how it was made, fundamentals etc. I tried replicating Berserker's Call myself but was not successful until i read this thread.
 

Kuberr24

Well-Known Member
Reaction score
28
this trigger is already complex in jass, requiring hashtables (or local hande vars) to pass data effciciently without the use of global variable arrays (one for every player or unit)

Problems you'll have in GUI:
If the unit has berserk call buff, how will you know which unit it must be ordered to attack?
what if two units use berserker call at the same time?
you will order a unit group to do something every 0.05 sec. better make it perfectly leakless... (although this needs to be done in JASS too)

To make it in GUI, you'd need alot of "clunky" code. If this is some kind of rpg, where the hero is always available and only 1 player has the hero, then I'd say go for it.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
What do you mean complex in jass. Im new to jass and ill code it easily
 

Rainther

I guess I should write something of value here...
Reaction score
61
It's more the step over to Jass that prevents people to join the Jass side. :p

People don't wanna leave the GUI side since it feels cozy and believes that joining the Jass side wouldn't give much in return, so come on over. Join the Jass side of the force! We got cookies... :D
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Cookies it is. But who were you saying that too?
 

Kuberr24

Well-Known Member
Reaction score
28
Code it easily? Right...

JASS:
function Trig_Berserker_Call_Conditions takes nothing returns boolean
	if(not(GetSpellAbilityId()=='A0C7'))then
		return false
	endif
	return true
endfunction

function Berserker_Call_Buff takes nothing returns boolean
	return GetUnitAbilityLevel(GetTriggerUnit(),'BHwe')>0
endfunction

function Berserker_Call_Aim takes nothing returns nothing
	local unit lMy=GetUnit(H2Tx(GetTriggeringTrigger()),"Axe")
	if GetUnitState(lMy,UNIT_STATE_LIFE)>0 then
		call DisableTrigger(GetTriggeringTrigger())
		call IssueTargetOrderById(GetTriggerUnit(),OrderId("attack"),lMy)
		call EnableTrigger(GetTriggeringTrigger())
	endif
endfunction

function Berserker_Call_OrderFilter takes nothing returns boolean
	if(UnitHasBuffBJ(GetFilterUnit(),'BHwe'))then
		if((UnitHasBuffBJ(GetFilterUnit(),'B008')==false)or(UnitHasBuffBJ(GetFilterUnit(),'Bcyc')==false))then
			if IsUnitPaused(GetFilterUnit())==false then
				return true
			endif
		endif
	endif
	return false
endfunction

function Berserker_Call_Caster takes nothing returns nothing
	call IssueTargetOrderById(GetEnumUnit(),OrderId("attack"),udg_u_DTAX_temp)
endfunction

function Berserker_Call_CreepVictim takes nothing returns boolean
	return GetBooleanAnd((UnitHasBuffBJ(GetFilterUnit(),'BHwe')),GetOwningPlayer(GetFilterUnit())==udg_pA_DTAX_SEPlayers[0]or GetOwningPlayer(GetFilterUnit())==udg_pA_DTAX_SCPlayers[0])
endfunction

function Berserker_Call_CreepAttack takes nothing returns nothing
	if(GetOwningPlayer(GetEnumUnit())==udg_pA_DTAX_SEPlayers[0])then
		call UnitRemoveAbility(GetEnumUnit(),'BHwe')
		call IssuePointOrderByIdLoc(GetEnumUnit(),OrderId("attack"),GetRectCenter(gg_rct_TheFrozenThroneRect))
	endif
	if(GetOwningPlayer(GetEnumUnit())==udg_pA_DTAX_SCPlayers[0])then
		call UnitRemoveAbility(GetEnumUnit(),'BHwe')
		call IssuePointOrderByIdLoc(GetEnumUnit(),OrderId("attack"),GetRectCenter(gg_rct_TheWorldTreeRect))
	endif
endfunction

function Trig_Berserker_Call_Actions takes nothing returns nothing
	local location liD=GetUnitLoc(GetTriggerUnit())
	local group lEw
	local trigger ltt=CreateTrigger()
	local unit lrs=GetSpellAbilityUnit()
	call SetHandle(H2Tx(ltt),"Axe",GetTriggerUnit())
	call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
	call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
	call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_UNIT_ISSUED_ORDER)
	call TriggerAddCondition(ltt,Condition(function Berserker_Call_Buff))
	call TriggerAddAction(ltt,function Berserker_Call_Aim)
	call PolledWait(.2)
	call CreateNUnitsAtLocFacingLocBJ(1,'e00E',GetOwningPlayer(GetTriggerUnit()),liD,liD)
	call RemoveLocation(liD)
	call UnitAddAbility(bj_lastCreatedUnit,'A0E1')
	call SetUnitAbilityLevelSwapped('A0E1',bj_lastCreatedUnit,GetUnitAbilityLevel(lrs,'A0C7'))
	call IssueTargetOrderById(bj_lastCreatedUnit,OrderId("innerfire"),GetTriggerUnit())
	set liD=GetUnitLoc(lrs)
	set lEw=GetUnitsInRangeOfLocMatching(550.,liD,Condition(function Berserker_Call_OrderFilter))
	set udg_u_DTAX_temp=lrs
	call ForGroupBJ(lEw,function Berserker_Call_Caster)
	call RemoveLocation(liD)
	call DestroyGroup(lEw)
	call PolledWait(1+.5*GetUnitAbilityLevel(lrs,'A0C7'))
	set lEw=GetUnitsInRectMatching(bj_mapInitialPlayableArea,Condition(function Berserker_Call_CreepVictim))
	call ForGroupBJ(lEw,function Berserker_Call_CreepAttack)
	call DestroyGroup(lEw)
	call FastFlush(H2Tx(ltt))
	call TriggerClearActions(ltt)
	call DestroyTriggerEx(ltt)
endfunction

function StartTrigger_Berserker_Call takes nothing returns nothing
	set gg_trg_Berserker_Call=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Berserker_Call,EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Berserker_Call,Condition(function Trig_Berserker_Call_Conditions))
	call TriggerAddAction(gg_trg_Berserker_Call,function Trig_Berserker_Call_Actions)
endfunction
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Damn that code needs some remakes and i would be using structs tyvm.
 

Rainther

I guess I should write something of value here...
Reaction score
61
That's converted and only confusing. By building a trigger from stratch is the best way to make the trigger more smooth and not this confusing as mentioned.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Yes i would just use KT2 with structs to run a function and order then to attack
 

Kuberr24

Well-Known Member
Reaction score
28
I did not make it, this is copied/pasted directly from dota 6.xx open source.

dota uses local handle vars and dynamic triggers/Timers all the time.


Although it indeed lacks "a clean look" it gets the job done, for over 2 years now :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top