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
`
ОЖИДАНИЕ РЕКЛАМЫ...
0
19
2 года назад
0
Похожие вопросы:

ответ
Написать return false
ответ
Farrien, попробуй скопировать функции в отдельную карту и глянь будет ли там работать
и зачем ты написал udg_ перед 2 переменными?
ответ
Нумерация с 0 начинается.
ответ
На хайве получил ответ, надо было писать evaluate
ответ
Независимо от того SaveReal там или SaveUnitHandle, ты записываешь значения в одну и ту же таблицу.
Ты просто SaveReal(h, id, 0, x_c) перезаписываешь этим - SaveUnitHandle(h, id, 0, u_c) и этим - SaveEffectHandle(h, id, 0, e)

0
27
2 года назад
Отредактирован rsfghd
0
я же тебе уже отвечал по этому поводу

убираешь нафиг константу и делаешь следующее
library mylib initializer init
globals
    unit u
    private real r
endglobals

private function init takes nothing returns nothing
    set u = CreateUnit( ... )
    set r = 200.00 + GetHeroInt( u, true )
endfunction

endlibrary

сама функция вернёт 0 в нескольких случаях, если юнита нет, если юнит не герой и если у юнита стат нулевой
0
29
2 года назад
0
Ответ прост:
  1. Не записан юнит-герой в переменную udg_ArcaneMageHero т.е. равна null
или
  1. Переменная udg_ArcaneMageHero содержит юнита, который не является героем, и у него все характеристик по нулям по умолчанию.
2
10
2 года назад
Отредактирован Chosen2
2
Так, окей, а если у меня уже есть переменная и в ней уже записан юнит, который записался туда после выбора из таверны.
То как я его могу обратиться к нему внутри вот такого кода например.
Должен ли я что то обьявить в глобалах ниже, или все переменные уже доступны?
Хочу MinHeightStart сделать зависимой от интеллекта и ( 200.00 + ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_ArcaneMageHero, true)) * 10.00 ) ) как будто не видит переменную udg_ArcaneMageHero.
Код
scope Telekinesis initializer GetStarted
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
! The spell itself
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
! Preloading and setting
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
0
27
2 года назад
Отредактирован rsfghd
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
Принятый ответ
0
29
2 года назад
0
Chosen2, ну он и будет возвращать 0.0, потому что константа берёт значение из несуществующего юнита при инициализации переменных во время загрузки карты.
У тебя нет выбора как делать его изменяемой обычной переменной без constant , и регистрировать туда значение юнита в постинициализации или время её, после того как udg_ArcaneMageHero присваивает себе юнита.
0
10
2 года назад
0
Господи точно, она же и называется по этому КОНСТАНТА, дико извиняюсь.
Я почему то решил что константа объявляется в этом триггере в момент его исполнения каждый раз заново.
Сейчас попробую)
Только начал осваивать джасс
0
27
2 года назад
0
Chosen2, так это не джасс, а вджасс, вот манул xgm.guru/p/wc3/vjassmanual
Загруженные файлы
0
10
2 года назад
0
Все получилось!!! Спасибо огромнейшее.
Короче принцип по факту такой же как и во всех ООП, я понял, обьявляешь переменные/константы, пишешь код функций, пишешь код спела, в конце вызываешь эти функции.
Надо понять теперь че такое private и вообще всю остальную структуру и синтаксис, пошел изучать, спасибо еще раз
Чтобы оставить комментарий, пожалуйста, войдите на сайт.