How it moves unit and make it increase hight?

simonake

New Member
Reaction score
72
Here's a trigger that i took from dota: tiny toss. I wanted to know how he makes to movement and the high in this trigger.
JASS:

function Trig_Toss_Conditions takes nothing returns boolean
	if(GetSpellAbilityId()!='A0BZ')then
		return false
	endif
	if GetUnitTypeId(GetSpellTargetUnit())=='n00I'or GetUnitTypeId(GetSpellTargetUnit())=='e01H'then
		return false
	endif
	if(GetOwningPlayer(GetSpellTargetUnit())==GetOwningPlayer(GetTriggerUnit()))then
		return false
	endif
	return true
endfunction

function TossFilter takes nothing returns boolean
	if(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT))then
		return false
	endif
	if IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) then
		return false
	elseif IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) then
		return false
	elseif GetFilterUnit()==GetSpellAbilityUnit()then
		return false
	elseif IsUnitDeadBJ(GetFilterUnit())then
		return false
	elseif IsUnitType(GetTriggerUnit(),UNIT_TYPE_ANCIENT) then
		return false
	elseif GetUnitTypeId(GetFilterUnit())=='n00L'then
		return false
	elseif IsUnitType(GetTriggerUnit(),UNIT_TYPE_GIANT) then
		return false
	elseif IsUnitVisible(GetFilterUnit(),GetOwningPlayer(GetSpellAbilityUnit()))==false then
		return false
	elseif GetUnitAbilityLevelSwapped('A04R',GetFilterUnit())!=0 then
		return false
	elseif(GetUnitTypeId(GetFilterUnit())=='H00F'or GetUnitTypeId(GetFilterUnit())=='H00E'or GetUnitTypeId(GetFilterUnit())=='H00G')then
		return false
	endif
	return true
endfunction

function TossDamage takes unit pWho,real pxx,real pyy,real pAOE,real pDamage,integer pSpellId returns nothing
	local group lVictims=CreateGroup()
	local unit lFirst
	local location lTMP
	call GroupEnumUnitsInRange(lVictims,pxx,pyy,pAOE,null)
	loop
		set lFirst=FirstOfGroup(lVictims)
		exitwhen lFirst==null
		if IsUnitEnemy(lFirst,GetOwningPlayer(pWho))and IsUnitDeadBJ(lFirst)==false and GetUnitAbilityLevel(lFirst,'A04R')==0 then
			if(IsUnitType(lFirst,UNIT_TYPE_STRUCTURE)==false)then
				call UnitDamageTargetBJ(pWho,lFirst,pDamage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
			else
				call UnitDamageTargetBJ(pWho,lFirst,pDamage/3,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
			endif
			set lTMP=GetUnitLoc(lFirst)
			call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
			call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
			call DestroyEffect(AddSpellEffectByIdLoc(pSpellId,EFFECT_TYPE_CASTER,lTMP))
			call RemoveLocation(lTMP)
			call GroupRemoveUnit(lVictims,lFirst)
		else
			call GroupRemoveUnit(lVictims,lFirst)
		endif
	endloop
	call GroupClear(lVictims)
	call DestroyGroup(lVictims)
endfunction

function TossMain takes nothing returns nothing
	local timer lMoveTimer=GetExpiredTimer()
	local string lTable=H2Tx(lMoveTimer)
	local integer lCount=GetInteger(lTable,"TossCounter")
	local real lRange=GetReal(lTable,"TossDistance")
	local real lAngle=GetReal(lTable,"TossAngle")
	local location lTarget=GetLocation(lTable,"TossTargetLoc")
	local location lStart=GetLocation(lTable,"TossSourceLoc")
	local unit lCaster=GetUnit(lTable,"Tiny")
	local unit lVictim=GetUnit(lTable,"TossSource")
	local real lHeight=(lCount-25)*(lCount-25)
	local real lSpeedMod=lRange*lCount/50-lRange
	local location lDest=PolarProjectionBJ(lTarget,lSpeedMod,lAngle)
	if(lCount<51)then
		call SetUnitPositionLoc(lVictim,lDest)
		call SetUnitFlyHeight(lVictim,775-lHeight,0)
		set lCount=lCount+1
		if(GetRandomInt(1,4)==2)then
			call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",lVictim,"Abilities\\Spells\\Undead\\Cripple\\CrippleTarget.mdl"))
		endif
	endif
	if(lCount>50)then
		call SetUnitFlyHeight(lVictim,GetUnitDefaultFlyHeight(lVictim),0)
		call PauseUnit(lVictim,false)
		call SetUnitPathing(lVictim,true)
		call TerrainDeformationRippleBJ(.2,true,lTarget,1.,300.,96.,1,64.)
		if IsUnitAlly(lVictim,GetOwningPlayer(lCaster))then
			call UnitDamageTargetBJ(lCaster,lVictim,.2*75*GetUnitAbilityLevel(lCaster,'A0BZ'),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
		else
			call UnitDamageTargetBJ(lCaster,lVictim,(.2+.15*GetUnitAbilityLevel(lCaster,'A0CY'))*75*GetUnitAbilityLevel(lCaster,'A0BZ'),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DEMOLITION)
		endif
		call TossDamage(lCaster,GetLocationX(lTarget),GetLocationY(lTarget),300,75.*I2R(GetUnitAbilityLevelSwapped('A0BZ',lCaster)),'A0BZ')
		call EnumDestructablesInCircleBJ(300,lTarget,function KillDestructableEnum)
		call PauseTimer(GetExpiredTimer())
		call PolledWait(.01)
		call FastFlush(lTable)
		call DestroyTimer(GetExpiredTimer())
		call RemoveLocation(lTarget)
		call RemoveLocation(lStart)
	endif
	call SetInteger(lTable,"TossCounter",lCount)
	call RemoveLocation(lDest)
endfunction

function Trig_Toss_Actions takes nothing returns nothing
	local group lNearCaster=CreateGroup()
	local timer lMoveTimer
	local unit lCaster=GetTriggerUnit()
	local unit lVictim
	local location lTarget
	local location lStart
	local integer lCounter
	local real lRange
	local real lAngle
	local string lf5
	call GroupEnumUnitsInRange(lNearCaster,GetUnitX(lCaster),GetUnitY(lCaster),275,Condition(function TossFilter))
	set lVictim=GroupPickRandomUnit(lNearCaster)
	call DestroyGroup(lNearCaster)
	set lTarget=GetUnitLoc(GetSpellTargetUnit())
	set lStart=GetUnitLoc(lVictim)
	set lCounter=1
	set lRange=DistanceBetweenPoints(lStart,lTarget)
	set lAngle=AngleBetweenPoints(lStart,lTarget)
	if(lVictim!=null and GetUnitTypeId(lVictim)!='n00I'and GetUnitTypeId(lVictim)!='e01H'and GetOwningPlayer(GetSpellTargetUnit())!=GetOwningPlayer(lCaster))then
		call SetUnitAnimationByIndex(lCaster,4)
		call PauseUnit(lVictim,true)
		call SetUnitPathing(lVictim,false)
		call UnitAddAbility(lVictim,'AEme')
		call UnitRemoveAbility(lVictim,'AEme')
		set lMoveTimer=CreateTimer()
		set lf5=H2Tx(lMoveTimer)
		call SetHandle(lf5,"Tiny",lCaster)
		call SetHandle(lf5,"TossSource",lVictim)
		call SetHandle(lf5,"TossTargetLoc",lTarget)
		call SetHandle(lf5,"TossSourceLoc",lStart)
		call SetInteger(lf5,"TossCounter",lCounter)
		call SetReal(lf5,"TossDistance",lRange)
		call SetReal(lf5,"TossAngle",lAngle)
		call TimerStart(lMoveTimer,.02,true,function TossMain)
	endif
endfunction

function StartTrigger_Toss takes nothing returns nothing
	set gg_trg_Toss=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Toss,EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Toss,Condition(function Trig_Toss_Conditions))
	call TriggerAddAction(gg_trg_Toss,function Trig_Toss_Actions)
endfunction
 

GooS

Azrael
Reaction score
154
You change height by adding Crow Form to the tossed unit and setting flying height periodically.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top