Добавлен Chosen2
private constant real MaxHeightStart = ( 200.00 + ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_ArcaneMageHero, true)) * 10.00 ) )
Может быть такое что ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_ArcaneMageHero, true)) * 10.00 ) не получает значение стата и возвращает 0?
Принятый ответ
в кат убери этот код, пол страницы забрал)
ты понимаешь вообще для чего константа? ты по коду никак не сможешь её изменить, только при объявлении задать значение, и всё
повторюсь, убери нафиг константу, при выборе героя из таверны задай нужное значение этой переменной
вот такая формулировка:
ты понимаешь вообще для чего константа? ты по коду никак не сможешь её изменить, только при объявлении задать значение, и всё
повторюсь, убери нафиг константу, при выборе героя из таверны задай нужное значение этой переменной
вот такая формулировка:
globals
unit u
private constant integer r = GetHeroInt( u )
endglobals
function dfgdfg takes nothing returns nothing
set u = CreateUnit( )
endfunction
вообще невозможна, переменная не возьмёт сама по себе значение героя когда он появится, ты ей задаёшь значение только при объявлении, а при объявлении этого героя нет
вот это
вот это
globals
unit u = CreateUnit( )
private constant integer r = GetHeroInt( u )
endglobals
тоже невозможно, потому что юнита таким образом создать нельзя, можешь сам проверить
поэтому возвращаемся к первому комменту
поэтому возвращаемся к первому комменту
library mylib initializer init
globals
unit u
private real r
endglobals
private function init takes nothing returns nothing
set u = CreateUnit( ... )
set r = GetHeroInt( u, true )
endfunction
endlibrary
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован rsfghd
Отредактирован Chosen2
То как я его могу обратиться к нему внутри вот такого кода например.
Хочу MinHeightStart сделать зависимой от интеллекта и ( 200.00 + ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_ArcaneMageHero, true)) * 10.00 ) ) как будто не видит переменную udg_ArcaneMageHero.
globals
private constant integer SpellID = 'A00Z' Returns the rawcode of the spell. To get a spell's rawcode, press Ctrl+D in the Object Editor.
private constant real SpellAoEStart = 200.0 Returns the initial area in which the enemied units are affected by this spell.
private constant real SpellAoEIncreasement = 50.0 Returns the increasement per level of the previous area.
private constant real MinHeightStart = 100.00 Returns the initial minimal reachable height.
private constant real MinHeightIncreasement = 100.0 Returns the increasement of the minimal reachable height per level.
private constant real MaxHeightStart = 200.00 Returns the initial maximal reachable height.
private constant real MaxHeightIncreasement = 200.0 Returns the increasement of the maximal reachable height per level.
private constant real Speed = 1.45 Returns the time in seconds in which the affected units are in the air.
private constant real SpeedVariationPerc = 0.20 Returns the percentage of the variation between each unit's lifting speed. Default is 0.20 which means 20% variation.
private constant string LiftSFX = "Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl" Returns the path of the special effect displayed periodically at the chest of the lifted targets.
private constant real LiftSFXTimer = 0.30 Returns the interval in seconds in which the previous effect is displayed.
private constant string StartSFX = "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl" Returns the path of the special effect displayed at the targets upon casting this spell.
private constant string ImpactSFX = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" Returns the path of the special effect displayed upon impact on earth.
private constant real HDmgInPercStart = 0.08 Returns the percentage of the height dealt in damage. Default is 0.08 for 8% height dealt in damage to the lifted unit upon impact.
private constant real HDmgInPercIncreasement = 0.02 Returns increasement per level of the previous value. Default is 0.02 for 2% increasement per level.
private constant real ImpactDmgStart = 20.0 Returns the direct damage dealt to the target upon impact.
private constant real ImpactDmgIncreasement = 20.0 Returns increasement per level of the previous value.
private constant attacktype AttackType = ATTACK_TYPE_NORMAL Returns the attack type in which the damage is dealt. There's actually no need to adjust this value.
private constant damagetype DamageType = DAMAGE_TYPE_NORMAL Returns the damage type in which the damage is dealt. There's actually no need to adjust this value.
private constant weapontype WeaponType = WEAPON_TYPE_ROCK_HEAVY_BASH Returns the weapon type with which the damage is dealt. There's actually no need to adjust this value, replace it with 'null' to remove the corresponding sound.
private constant boolean Pause = true Returns whether the flying unit should be paused.
endglobals
********************************END OF THE SETTINGS**************************
Do not modify anything below this line unless you know what you are doing
*****************************************************************************
globals Declaring the global variables.
private group Fgroup = CreateGroup()
private group FlyG = CreateGroup()
private boolexpr filter = null
private integer i = 0
private unit tempU
private player tempP
endglobals
! General functions used
private function GetFilter takes nothing returns boolean Filters the targetable units.
return GetWidgetLife(GetFilterUnit()) > 0 and IsUnitEnemy(GetFilterUnit(),tempP) and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false
endfunction
private function TeleCondition takes nothing returns boolean Checks the SpellID in order to trigger this spell, and no other, upon casting.
return GetSpellAbilityId() == SpellID
endfunction
private struct Spell Declaring the struct variables.
unit c
unit t
real int
real maxH
real LsfxT
real speed
integer l
static Spell array indx
static integer counter = 0
static timer time = CreateTimer()
static method TeleLift takes nothing returns nothing Lifting the targets and handleing all the impact stuff.
local real x
local real y
local Spell d
set i = 0
loop
exitwhen i >= Spell.counter
set d = Spell.indx[i]
if d.int < 180 then
set d.int = d.int + d.speed
set d.LsfxT = d.LsfxT + 0.01
call SetUnitFlyHeight(d.t,(Sin(d.int*bj_DEGTORAD)*d.maxH)+GetUnitDefaultFlyHeight(d.t),0)
if d.LsfxT >= LiftSFXTimer then
call DestroyEffect(AddSpecialEffectTarget(LiftSFX,d.t,"chest"))
set d.LsfxT = 0
endif
else
set tempP = GetOwningPlayer(d.c)
set x = GetUnitX(d.t)
set y = GetUnitY(d.t)
call GroupRemoveUnit (FlyG,d.t)
call DestroyEffect(AddSpecialEffect(ImpactSFX,x,y))
call UnitDamageTarget(d.c,d.t,(d.maxH*(HDmgInPercStart+(d.l-1)*HDmgInPercIncreasement))+(ImpactDmgStart+(d.l-1)*ImpactDmgIncreasement),true,true,AttackType,DamageType,WeaponType)
if Pause == true then
call PauseUnit(d.t,false)
endif
call SetUnitFlyHeight(d.t,GetUnitDefaultFlyHeight(d.t),0)
set d.c = null
set d.t = null
call d.destroy()
set Spell.counter = Spell.counter - 1
set Spell.indx[i] = d.indx[Spell.counter]
set i = i - 1
if Spell.counter == 0 then
call PauseTimer(Spell.time)
endif
endif
set i = i + 1
endloop
set i = 0
endmethod
static method GetValues takes unit c, unit t, integer l returns nothing Applies the spell values into the struct system.
local Spell d = Spell.allocate()
set d.c = c
set d.t = t
set d.l = l
set d.int = 0
set d.LsfxT = 0
set d.maxH = GetRandomReal(MinHeightStart+(l-1)*MinHeightIncreasement,MaxHeightStart+(l-1)*MaxHeightIncreasement)
set d.speed = 1.8/GetRandomReal(Speed*(1+SpeedVariationPerc),Speed*(1-SpeedVariationPerc))
if Spell.counter == 0 then
call TimerStart(Spell.time,0.01,true, function Spell.TeleLift)
endif
set Spell.indx[Spell.counter] = d
set Spell.counter = Spell.counter + 1
endmethod
endstruct
! Casting the spell
private function TeleInput takes nothing returns nothing Gets and initializes the storage of all the spell values.
local unit caster = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(caster,SpellID)
local location loc = GetSpellTargetLoc()
set tempP = GetOwningPlayer(caster)
call GroupEnumUnitsInRange(Fgroup,GetLocationX(loc),GetLocationY(loc),SpellAoEStart+SpellAoEIncreasement*(level-1),filter)
loop
set tempU = FirstOfGroup(Fgroup)
exitwhen tempU == null
if IsUnitInGroup (tempU,FlyG) == false then
call Spell.GetValues(caster,tempU,GetUnitAbilityLevel(caster,SpellID))
call GroupAddUnit (FlyG,tempU)
call UnitAddAbility(tempU,'Amrf')
call UnitRemoveAbility(tempU,'Amrf')
call DestroyEffect(AddSpecialEffect(StartSFX,GetUnitX(tempU),GetUnitY(tempU)))
if Pause == true then
call PauseUnit(tempU,true)
endif
endif
call GroupRemoveUnit(Fgroup,tempU)
endloop
call RemoveLocation(loc)
set loc = null
set caster = null
endfunction
private function GetStarted takes nothing returns nothing Preloads effects, adds actions and conditions to the spell's trigger.
local trigger TeleTrig = CreateTrigger()
set filter = Condition(function GetFilter)
loop
call TriggerRegisterPlayerUnitEvent(TeleTrig, Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
set i = 0
call TriggerAddCondition(TeleTrig, Condition(function TeleCondition))
call TriggerAddAction(TeleTrig, function TeleInput)
call Preload(LiftSFX)
call Preload(StartSFX)
call Preload(ImpactSFX)
call PreloadStart()
endfunction
endscope
Отредактирован rsfghd
ты понимаешь вообще для чего константа? ты по коду никак не сможешь её изменить, только при объявлении задать значение, и всё
повторюсь, убери нафиг константу, при выборе героя из таверны задай нужное значение этой переменной
вот такая формулировка:
вот это
поэтому возвращаемся к первому комменту
У тебя нет выбора как делать его изменяемой обычной переменной без constant , и регистрировать туда значение юнита в постинициализации или время её, после того как udg_ArcaneMageHero присваивает себе юнита.
Я почему то решил что константа объявляется в этом триггере в момент его исполнения каждый раз заново.
Только начал осваивать джасс
Короче принцип по факту такой же как и во всех ООП, я понял, обьявляешь переменные/константы, пишешь код функций, пишешь код спела, в конце вызываешь эти функции.