GetTriggerUnit-
DogEntrepreneur
- Reaction score
- 129
No, I meant. When I open the map by the site, and press test map, it won't open. I just wanted to make sure we can play it.
You need to save the map first, and make sure Jasshelper saves also, then it should work
How do i do that ???? :S
EDIT: Btw, nobody knows if you can change the name of a spoiler ?? (As asked in another post here in the thread)
// Tazo's Instance Maximum is the number of periods you can have
// which is greater or equal to the Period Threshold. This may be
// removed completely in later versions.
private constant integer TAZO_INSTANCEMAX=64
//==============================================================================
// TT -- TIMER TICKER SYSTEM BY COHADAR -- v4.0
//==============================================================================
//
// PURPOUSE OF TT:
// * Passing data to timers
// * Avoiding direct use of timer handles
//
// PROS:
// * It is easier than using attaching
// * It is optimized to use only one timer on default high frequency
// * GetData method is the same for all timer frequencies
//
// CONS:
// * You must remember to always return true from your function
// when you want to stop timer, even if it is of one-shot type.
// (otherwise it will leak)
//
// START FUNCTIONS:
// * TT_Start(userFunc, struct)
// * TT_StartEx(userFunc, struct, period)
// * TT_Once(userFunc, struct, timeout)
// * TT_StartTimerDialog(userFunc, struct, timeout) -> timerdialog
//
// * userFunc is a user function that takes nothing and returns boolean
// it will be periodically called by the system until it returns true.
//
// GET FUNCTIONS:
// * TT_GetData() -> struct
// * TT_GetTimerDialog() -> timerdialog
//
// * These functions can only be called from inside userFunc
// TT_GetData() will return struct passed to any of the start functions
// TT_GetTimerDialog() returns timerdialog created by TT_StartTimerDialog
//
// DETAILS:
// * On default frequency all user functions are stored in an array.
// Timer will call all those functions each period.
//
// * While user function returns false timer will continue to call it each period
// Once user function returns true it will be removed from system
//
// * TT is using smart timer preloading and simple hash
// When colliding timer handle is found that timer is simply discarded
//
// REQUIREMENTS:
// * NewGen v4c and above (there might be some problems with older NewGen's)
//
// HOW TO IMPORT:
// * Just create a trigger named TT
// * convert it to text and replace the whole trigger text with this one
//
//==============================================================================
library TT initializer Init
//==============================================================================
// Configuration
//==============================================================================
globals
// List of recommended periods for high-frequency timer:
// 0.04 = 25 calls per second
// 0.03125 = 32 calls per second
// 0.025 = 40 calls per second
// 0.02 = 50 calls per second
public constant real PERIOD = 0.03125
// how many low-frequency timers to preload
// system can safely extend beyond this limit
private constant integer PRELOAD = 32
endglobals
//==============================================================================
// End of Configuration
//==============================================================================
//==============================================================================
globals
// "frames per second" of high-frequency timer
public constant integer FPS = R2I(1.0/PERIOD)
// globals for passing data to userFunc
private integer Data
private timerdialog timerDialog
// One Timer to rule them all, One Timer to find them,
// One Timer to call them all and in the jass bind them
// In the land of warcraft where the desyncs lie.
private timer HF_Timer = CreateTimer()
private integer HF_Counter = 0
private trigger array HF_Triggz
private integer array HF_Dataz
// we can safely use dummy hashing here because timers are preloaded
private constant integer LF_HASH = 8191
private integer array LF_Dataz
private trigger array LF_Triggz
private timer array LF_Timerz
private timerdialog array LF_Dialogz
// recycling
private integer array LF_Indexz
private integer LF_Counter = PRELOAD
endglobals
//==============================================================================
private constant function H2I takes handle h returns integer
return h
return 0
endfunction
//==============================================================================
// note how colliding timer handles are discarded
// so TT would work properly even after preload limit break
//==============================================================================
private function NewIndex takes nothing returns integer
local integer i
local timer t
if (LF_Counter==0) then
loop
debug call BJDebugMsg("WARNING: TT reached preloaded timer limit!")
set t = CreateTimer()
set i = H2I(t)
set i = i - (i / LF_HASH) * LF_HASH // dummy modulo hash
if LF_Timerz<i> == null then
set LF_Timerz<i> = t
set LF_Triggz<i> = CreateTrigger()
return i
endif
endloop
endif
set LF_Counter = LF_Counter - 1
return LF_Indexz[LF_Counter]
endfunction
//==============================================================================
private function HF_Handler takes nothing returns nothing
local trigger swap
local integer i = HF_Counter
loop
exitwhen i<=0
set Data = HF_Dataz<i>
if TriggerEvaluate(HF_Triggz<i>) then
set swap = HF_Triggz<i>
call TriggerClearConditions(swap)
set HF_Triggz<i> = HF_Triggz[HF_Counter]
set HF_Triggz[HF_Counter] = swap
set HF_Dataz<i> = HF_Dataz[HF_Counter]
set HF_Counter = HF_Counter - 1
endif
set i = i - 1
endloop
// who can guess why am I not nulling swap here?
endfunction
//==============================================================================
private function LF_Handler takes nothing returns nothing
local integer i = H2I(GetExpiredTimer())
set i = i - (i / LF_HASH) * LF_HASH // dummy modulo hash
set Data = LF_Dataz<i>
if TriggerEvaluate(LF_Triggz<i>) then
// recycle the trigger and timer
call TriggerClearConditions(LF_Triggz<i>)
call PauseTimer(LF_Timerz<i>)
set LF_Indexz[LF_Counter] = i
set LF_Counter = LF_Counter + 1
endif
endfunction
//==============================================================================
// Periodic timer that runs on TT_PERIOD
//==============================================================================
public function Start takes code userFunc, integer data returns nothing
debug if userFunc == null then
debug call BJDebugMsg("ERROR: TT_Start - null userFunc")
debug return
debug endif
set HF_Counter = HF_Counter + 1
if HF_Triggz[HF_Counter] == null then
set HF_Triggz[HF_Counter] = CreateTrigger()
endif
set HF_Dataz[HF_Counter] = data
call TriggerAddCondition(HF_Triggz[HF_Counter], Condition(userFunc))
endfunction
//==============================================================================
// Periodic timer with custom period
//==============================================================================
public function StartEx takes code userFunc, integer data, real period returns nothing
local integer i
debug if userFunc == null then
debug call BJDebugMsg("ERROR: TT_StartEx - null userFunc")
debug return
debug endif
set i = NewIndex()
call TriggerAddCondition(LF_Triggz<i>, Condition(userFunc))
set LF_Dataz<i> = data
call TimerStart(LF_Timerz<i>, period, true, function LF_Handler)
endfunction
//==============================================================================
// One shot timer, remember to return true in userFunc
//==============================================================================
public function Once takes code userFunc, integer data, real timeout returns nothing
local integer i
debug if userFunc == null then
debug call BJDebugMsg("ERROR: TT_Once - null userFunc")
debug return
debug endif
set i = NewIndex()
call TriggerAddCondition(LF_Triggz<i>, Condition(userFunc))
set LF_Dataz<i> = data
call TimerStart(LF_Timerz<i>, timeout, false, function LF_Handler)
endfunction
//==============================================================================
public function StartTimerDialog takes code userFunc, integer data, real timeout returns timerdialog
local integer i
debug if userFunc == null then
debug call BJDebugMsg("ERROR: TT_StartTimerDialog - null userFunc")
debug return null
debug endif
set i = NewIndex()
call TriggerAddCondition(LF_Triggz<i>, Condition(userFunc))
set LF_Dataz<i> = data
call TimerStart(LF_Timerz<i>, timeout, false, function LF_Handler)
set bj_lastCreatedTimerDialog = CreateTimerDialog(LF_Timerz<i>)
set LF_Dialogz<i> = bj_lastCreatedTimerDialog
return bj_lastCreatedTimerDialog
endfunction
//==============================================================================
// Call this function only inside the userFunc
//==============================================================================
public function GetData takes nothing returns integer
return Data
endfunction
//==============================================================================
// Call this function only inside the userFunc
//==============================================================================
public function GetTimerDialog takes nothing returns timerdialog
local integer i = H2I(GetExpiredTimer())
set i = i - (i / LF_HASH) * LF_HASH // dummy modulo hash
return LF_Dialogz<i>
endfunction
//==============================================================================
// Preload LF timers and start HF timer.
//==============================================================================
private function Init takes nothing returns nothing
local integer i
local timer t
local integer j = 0
loop
exitwhen j>=PRELOAD
set t = CreateTimer()
set i = H2I(t)
set i = i - (i / LF_HASH) * LF_HASH // dummy modulo hash
if LF_Timerz<i> == null then
set LF_Timerz<i> = t
set LF_Triggz<i> = CreateTrigger()
set LF_Indexz[j] = i
set j = j + 1
endif
endloop
call TimerStart(HF_Timer, PERIOD, true, function HF_Handler)
endfunction
endlibrary
//==============================================================================
// END OF TIMER TICKER SYSTEM
//==============================================================================
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
scope Dummy initializer init
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//***********************************************************************************************************//
//@@////////////////////////////////////Burning Hell, Made By Komaqtion////////////////////////////////////@@//
//@@ @@//
//@@ How to import: @@//
//@@ @@//
//@@ ¤ First copy the ability "Burning Hell" and the unit "Dummy" and change the ID's in the @@//
//@@ constants below to the new ones. Then you need to import Vexorian's dummy.mdx file from @@//
//@@ this map, or another, and change "Dummy" unit's model to this one. Then, of course, you @@//
//@@ need to import the triggers, which are in the categories "The Spell" and @@//
//@@ "Required Systems". Then you're free to change any of the given global constants to suit @@//
//@@ your needs. @@//
//@@ @@//
//@@ Requirements: @@//
//@@ ¤ This spell, of course ! @@//
//@@ ¤ Key Timers 2, made by Jesus4Lyf <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> @@//
//@@ ¤ The library made especially for this spell, EAE, made by kingkingyyk3!!! @@//
//@@ ¤ Vexorians, dummy.mdx ! @@//
//@@ @@//
//@@ ¤ Credits to: @@//
//@@ * Vexorian, for the dummy.mdx file @@//
//@@ * Jesus4Lyf, for KeyTimers 2 @@//
//@@ * TriggerHappy187, for TimedHandles (Even if this spell doesn't use it anymore XD) @@//
//@@ * Kingkingyyk3, for his wonderfull help on this spell, and for making EAE ! @@//
//@@ @@//
//@@ so, many thanks to all of the many helpfull people at TheHelper.net who has helped get @@//
//@@ is spell working! (kingkingyyk3 and WolfieNoCT especially <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />) @@//
//@@ @@//
//@@ @@//
//@@ Note: This is my very first fully working, and quite good, spell made completely in JASS. @@//
//@@ So much feedback, and suggestions are very much welcome, and maybe some tips to make it @@//
//@@ even better would be nice <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> @@//
//@@ @@//
//***********************************************************************************************************//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
globals
// Effects! Change as you'd like <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" />\\
private constant string EFFECT_C = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" // Effect on the caster!
private constant string EFFECT_1 = "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl" // Effect 200 range from the caster!
private constant string EFFECT_2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" // Effect at the end!
private constant string DUMMY_EFFECT = "Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl" // Effect on the moving dummy!
// ID's! Change to the ID's on your map <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />\\
private constant integer SPELL_ID = 039;0000039; // ID of the spell!
private constant integer DUMMY_ID = 039;h000039; // ID of the dummy unit!
private constant integer LOCUST = 039;Aloc039; // ID of the "Locust" ability! (Might not need changing)
private constant integer BUFF_ID = 039;BTLF039; // ID of the expiration buff on the dummy!
// Other constant integers! Change at will <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />\\
private constant real DAMAGE_FACTOR = 1.
private constant real RANGE_FACTOR = 15.
private constant integer ANGLES = 16 // The number of agles the effects will show at! (360/ANGLES)
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL // Explains itself i think XD
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL // Same here <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />
private constant real SLIDE_SPEED = 10 // How much the dummy effect moves each 0.05 seconds!
endglobals
globals
// Globals! Simply DON'T CHANGE!\\
private integer TempStructIndex
private group Temp = CreateGroup()
endglobals
private struct Data
unit array du [ANGLES]
unit cs
real array pointx [ANGLES]
real array pointy [ANGLES]
boolean b
player p
group g
integer lvl
static method create takes unit u returns Data
local Data a = Data.allocate()
set a.cs = u
set a.b = false
set a.p = GetOwningPlayer(u)
set a.g = CreateGroup()
set a.lvl = GetUnitAbilityLevel(a.cs,SPELL_ID)
return a
endmethod
endstruct
// Some more configurables that needed the struct!\\
// Damage functions!\\
private function Damage_Small takes nothing returns real
return DAMAGE_FACTOR * 10
endfunction
private function Damage_Medium takes integer lv returns real
return 50 + lv * DAMAGE_FACTOR * 50
endfunction
private function Damage_High takes integer lv returns real
return lv * DAMAGE_FACTOR * 100
endfunction
// Range functions!\\
private function Range_Small takes nothing returns real
return RANGE_FACTOR * 5
endfunction
private function Range_Medium takes nothing returns real
return RANGE_FACTOR * 10
endfunction
private function Range_High takes nothing returns real
return RANGE_FACTOR * RANGE_FACTOR
endfunction
// End of Configuration!\\
private function Spell_Check takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function GroupEm takes nothing returns boolean
local Data a = TempStructIndex
return GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitEnemy(GetFilterUnit(), a.p) and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitInGroup(GetFilterUnit(),a.g) == false
endfunction
private function Smaller_GroupEm takes nothing returns boolean
local Data a = TempStructIndex
return GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitEnemy(GetFilterUnit(), a.p) and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false
endfunction
private function Callback takes nothing returns nothing
local Data a = EAE_GetData()
local integer i = 1
local unit temp
loop
exitwhen i >=ANGLES
set a.pointx<i> = GetUnitX(a.du<i>)
set a.pointy<i> = GetUnitY(a.du<i>)
call DestroyEffect(AddSpecialEffect(EFFECT_2,a.pointx<i>,a.pointy<i>))
call GroupEnumUnitsInRange(Temp, a.pointx<i>, a.pointy<i>, Range_High(), Condition(function Smaller_GroupEm))
loop
set temp = FirstOfGroup(Temp)
exitwhen temp == null
call UnitDamageTarget(a.cs, temp, Damage_High(a.lvl), true, false, ATTACK_TYPE, DAMAGE_TYPE, null)
call GroupRemoveUnit(Temp,temp)
endloop
call RemoveUnit(a.du<i>)
set i = i+1
endloop
endfunction
private function Move_Dummy takes nothing returns boolean
local Data a = TT_GetData()
local real xd
local real yd
local integer i = 1
local unit temp
loop
exitwhen i>=ANGLES
set xd = GetUnitX(a.du<i>)
set yd = GetUnitY(a.du<i>)
set a.pointx<i> = xd+SLIDE_SPEED*Cos(I2R(i*(360/(ANGLES-1)))*bj_DEGTORAD)
set a.pointy<i> = yd+SLIDE_SPEED*Sin(I2R(i*(360/(ANGLES-1)))*bj_DEGTORAD)
set TempStructIndex = a
call GroupEnumUnitsInRange(Temp, a.pointx<i>, a.pointy<i>, Range_Small(), Condition(function Smaller_GroupEm))
loop
set temp = FirstOfGroup(Temp)
exitwhen temp == null
call UnitDamageTarget(a.cs, temp, Damage_Small(), true, false, ATTACK_TYPE, DAMAGE_TYPE, null)
call GroupAddUnit(a.g,temp)
call GroupRemoveUnit(Temp,temp)
endloop
call SetUnitX(a.du<i>,a.pointx<i>)
call SetUnitY(a.du<i>,a.pointy<i>)
set i = i+1
endloop
return a.b
endfunction
private function Effects takes nothing returns nothing
local Data a = Data.create(GetTriggerUnit())
local real xu = GetUnitX(a.cs)
local real yu = GetUnitY(a.cs)
local integer i = 1
local unit temp
call DestroyEffect(AddSpecialEffect(EFFECT_C,xu,yu))
loop
exitwhen i>=ANGLES
set a.pointx<i> = xu+200*Cos(I2R(i*(360/(ANGLES-1)))*bj_DEGTORAD)
set a.pointy<i> = yu+200*Sin(I2R(i*(360/(ANGLES-1)))*bj_DEGTORAD)
set TempStructIndex = a
call DestroyEffect(AddSpecialEffect(EFFECT_1, a.pointx<i>, a.pointy<i>))
call GroupEnumUnitsInRange(Temp, a.pointx<i>, a.pointy<i>,Range_Medium(), Condition(function GroupEm))
loop
set temp = FirstOfGroup(Temp)
exitwhen temp == null
call UnitDamageTarget(a.cs, temp, Damage_Medium(a.lvl), true, false, ATTACK_TYPE, DAMAGE_TYPE, null)
call GroupAddUnit(a.g,temp)
call GroupRemoveUnit(Temp,temp)
endloop
set a.du<i> = CreateUnit(a.p,DUMMY_ID,xu,yu,bj_RADTODEG*Atan2(a.pointy<i>-yu,a.pointx<i>-xu))
call UnitAddAbility(a.du<i>,LOCUST)
call EAE_Add(AddSpecialEffectTarget(DUMMY_EFFECT,a.du<i>,"origin"),2.5,null,0)
set i = i+1
endloop
call EAE_Add(null, 2.5, function Callback, a)
call TT_StartEx(function Move_Dummy,a,.05)
call TriggerSleepAction(2.5)
set a.b = true
call GroupClear(a.g)
call GroupClear(Temp)
call DestroyGroup(a.g)
call a.destroy()
endfunction
private function init takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function Spell_Check))
call TriggerAddAction(t,function Effects)
endfunction
endscope
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
library EAE requires TT
//A library designed for Burning Hell, By Komaqtion
//by kingking
//How to use?
//function EAE_Add takes effect e, real duration, code callback, integer data
//In order to access the data, Use EAE_GetData() to get the struct index in the callback function.
globals
private integer ReturnIndex
endglobals
private struct Data
effect e
integer data
trigger callback
endstruct
private function Destroy takes nothing returns boolean
local Data d = TT_GetData()
if d.e != null then
call DestroyEffect(d.e)
set d.e = null
endif
if d.callback != null then
set ReturnIndex = d.data
call TriggerExecute(d.callback)
call DestroyTrigger(d.callback)
set d.callback = null
endif
call d.destroy()
return true
endfunction
public function GetData takes nothing returns integer
return ReturnIndex
endfunction
public function Add takes effect e, real duration, code callback, integer data returns nothing
local Data d = Data.create()
if e != null then
set d.e = e
endif
if callback != null then
set d.data = data
set d.callback = CreateTrigger()
call TriggerAddAction(d.callback, callback)
endif
if e != null or callback != null then
call TT_StartEx(function Destroy, d, duration)
endif
endfunction
endlibrary
And there is still one issue, sometimes the dummies just keep going, and they seem to have a higher speed than the other,because they get destroyed after the same time, but moves about twice the distance Any ideas how to fix it ?