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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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