inevit4ble
Well-Known Member
- Reaction score
- 38
Hi Every1,
Ok, the desired effect of this spell is to:
Pause Trigger Unit
Lock camera for owning player to unit
Disable control for player
Create SFX
Display Text
Start Timer for 6 sec
Upon Timer end it is meant to:
Reset camera
Enable control
Destroy SFX
Set Unit HP to 100%
Reset Cooldowns for unit
Display Text
Unpause Unit
Also it needs to check if any enemies are in range, if more than 1 then no effects occur
And if unit has taken damage within the last 20sec, if true then no effects occur
So far:
Casting spell triggers script
Unit is paused
SFX is created
Text is displayed
Main Problem == Timer doesn't seem to end/run its handler so I don't know if the second half of the stuff works or not
Other Problems:
How do I order a unit to "stop"?
How do I pan/lock camera to unit?
How do I Enable/Disable Control for Player?
Is there anything else I am doing wrong?
I've tried what I can but wrapped them in " /* " " */ " when I couldn't get it
Thanks a lot!
Ok, the desired effect of this spell is to:
Pause Trigger Unit
Lock camera for owning player to unit
Disable control for player
Create SFX
Display Text
Start Timer for 6 sec
Upon Timer end it is meant to:
Reset camera
Enable control
Destroy SFX
Set Unit HP to 100%
Reset Cooldowns for unit
Display Text
Unpause Unit
Also it needs to check if any enemies are in range, if more than 1 then no effects occur
And if unit has taken damage within the last 20sec, if true then no effects occur
I haven't started on the damage check yet, I wanted to get the rest of the stuff to work first
So far:
Casting spell triggers script
Unit is paused
SFX is created
Text is displayed
Main Problem == Timer doesn't seem to end/run its handler so I don't know if the second half of the stuff works or not
Other Problems:
How do I order a unit to "stop"?
How do I pan/lock camera to unit?
How do I Enable/Disable Control for Player?
Is there anything else I am doing wrong?
I've tried what I can but wrapped them in " /* " " */ " when I couldn't get it
Thanks a lot!
JASS:
scope Rest initializer Init
//========================================================
//====================SET UP==============================
globals
private constant integer rest = 039;A02E039;
private constant string ZZZsfx = "Abilities\\Spells\\Other\\CreepSleep\\CreepSleepTarget.mdl"
private constant integer dmy = 039;h00C039;
endglobals
//========================================================
//====================END UP==============================
//========================================================
globals
private effect array zzz
private timer array dur
private group g
private unit array char
private boolexpr b
endglobals
//========================================================
private function RestAoE takes unit u returns boolean
return (GetWidgetLife(u) > 0.405)
endfunction
private function pick takes nothing returns boolean
return RestAoE(GetFilterUnit())
endfunction
//========================================================
private function UnitHpAdd takes unit u returns real
local real max
local real cur
set max = GetUnitState(u, UNIT_STATE_MAX_LIFE)
set cur = GetUnitState(u, UNIT_STATE_LIFE)
return max - cur
endfunction
private function restEnd takes nothing returns nothing
local integer i
local integer i2 = 1
local real add
//finds which player is ending rest
loop
exitwhen i2 == 5 //Only 4 possible timers
if GetExpiredTimer() == dur[i2] then
set i = i2
endif
set i2 = i2 + 1
endloop
//Null Timer
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
//Rest Camera
//Destroy SFX
call DestroyEffect(zzz<i>)
//Reset HP
set add = UnitHpAdd(char<i>)
call SetUnitState(char<i>, UNIT_STATE_LIFE, GetUnitState(char<i>, UNIT_STATE_LIFE) + add)
//Reset Cooldowns
call UnitResetCooldown(char<i>)
//Screen Print "Done Resting!"
call DisplayTextToPlayer(GetOwningPlayer(char<i>), 0, 0, "Done Resting!")
//Unpause TriggerUnit()
call PauseUnit(char<i>, false)
set char <i> = null
endfunction
//========================================================
private function check takes nothing returns boolean
return GetSpellAbilityId() == rest
endfunction
//========================================================
private function actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local integer e = 0
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local unit f
call GroupEnumUnitsInRange(g, x, y, 1500., b)
loop
set f = FirstOfGroup(g)
exitwhen f == null
call GroupRemoveUnit(g, f)
if (IsUnitEnemy(f, GetOwningPlayer(u)) == true) then
set e = e + 1
endif
endloop
if e == 0 then
set char[GetPlayerId(p)] = u
//Stops endless loop bug I had in GUI
//call IssueTargetOrder(u, "stop", nothing)
//Pause Unit
call PauseUnit(u, true)
//Lock camera for player to unit
/*if (GetLocalPlayer() == p) then
call CameraSetupApplyForceDuration( lock, false, 0.)
endif*/
//Create ZZZ SFX on Trigger Unit Head
set zzz[GetPlayerId(p)] = AddSpecialEffectTarget(ZZZsfx, u, "overhead")
//Screen Print "Resting..."
call DisplayTimedTextToPlayer(p, 0., 0., 5.95, "Resting...")
//Starts Timer to End Resting
set dur[GetPlayerId(p)] = CreateTimer()
call TimerStart(dur[GetPlayerId(p)], 6., false, function restEnd )
else
call DisplayTimedTextToPlayer(p, 0., 0., 5., "You cannot rest nearby enemies!")
endif
call DestroyGroup(g)
set g = null
set u = null
set p = null
endfunction
//========================================================
private function Init takes nothing returns nothing
local trigger t
local integer i = 0
set t = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function check))
call TriggerAddAction( t, function actions )
//Globals
set g = CreateGroup()
set b = Condition(function pick)
//Preloads
call Preload(ZZZsfx)
set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), dmy, 0, 0, 0)
call UnitAddAbility(bj_lastCreatedUnit, rest)
call KillUnit(bj_lastCreatedUnit)
endfunction
endscope</i></i></i></i></i></i></i></i>