XGM Forum
Сайт - Статьи - Проекты - Ресурсы - Блоги

Форуме в режиме ТОЛЬКО ЧТЕНИЕ. Вы можете задать вопросы в Q/A на сайте, либо создать свой проект или ресурс.
Вернуться   XGM Forum > Warcraft> Академия: форум для вопросов> Jass
Ник
Пароль
Войти через VK в один клик
Сайт использует только имя.

Ответ
 
Xoniks

offline
Опыт: 1,858
Активность:
Что у меня тут неправильно?? и есть ли где утечки?
» код
((код jass
function time takes nothing returns nothing
local timer t = GetExpiredTimer( )
local integer tkey = GetHandleId( t )
call FlushChildHashtable(Hash, tkey)
call DestroyTimer(t)
set t=null
endfunction
function Trig_Creep_Actions takes nothing returns nothing
local unit u
local integer i
local integer j = 0
local timer t = CreateTimer( )
loop
exitwhen j == 5
set i = 0
call TimerStart(t, 2., false, function time)
j = j+1
loop
exitwhen i == 2
call CreateNUnitsAtLoc( 1, Creep[1], Player(12), left , 270.00 )
u = GetLastCreatedUnit()
call IssuePointOrderLoc(u, "attack", resp)
call CreateNUnitsAtLoc( 1, Creep[1], Player(12), right , 270.00 )
u = GetLastCreatedUnit()
call IssuePointOrderLoc(u, "attack", resp)
i=i+1
endloop
endloop
set u = null

endfunction
))
мне надо чтобы цикл повторился 5 раз с задержой 2 сек но что то не получается
Старый 27.02.2012, 09:24
Ty3uK

offline
Опыт: 2,469
Активность:
Xoniks, зачем таймер?

Ty3uK добавил:
Xoniks, таймер явно был не нужен, переписал, убрав бж:
» Code
Код:
function Trig_Creep_Actions takes nothing returns nothing
    local unit u
    local integer i = 0
    local integer j = 0
    loop
        exitwhen j == 5 
        loop
        exitwhen i == 2
        set u = CreateUnit(Player(12), Creep[1], GetLocationX(left), GetLocationY(left), 270.)
            call IssuePointOrderById(u, 851983, GetLocationX(resp), GetLocationY(resp))
           set u = CreateUnit(Player(12), Creep[1], GetLocationX(right), GetLocationY(right), 270.)
            call IssuePointOrderById(u, 851983, GetLocationX(resp), GetLocationY(resp))
            set i = i + 1
        endloop
    set i = 0
        set j = j + 1
    endloop
    set u = null
endfunction
Старый 27.02.2012, 09:52
quq_CCCP
Я белый и пушистый!
offline
Опыт: 93,279
Активность:
Xoniks, а откуда ты взял локации Left Right и resp? они неописаны как локальные, и нету udg_
следовательно они не глобальные. Утечки самое собой есть, так как используем бж функции и локации, а это не лучший вариант. Не могу понять нафиг тебе таймер и откуда ты взял хеш-таблицу? и зачем ты очищение её если ты не связал с таймером не одного объекта? Этот кусок кода нечего не делает кроме засорение памяти, вдобавок ты инициализировал хеш таблицу?

Отредактировано quq_CCCP, 27.02.2012 в 10:06.
Старый 27.02.2012, 10:01
Nerevar
I'll be back!
offline
Опыт: 18,352
Активность:
Следовательно они глобальные и созданы в globals\endglobals
Старый 27.02.2012, 10:02
quq_CCCP
Я белый и пушистый!
offline
Опыт: 93,279
Активность:
Nerevar, чёта я Globals endglobals не вижу... возможно именно из за этого ошибки?
Старый 27.02.2012, 10:07
Ty3uK

offline
Опыт: 2,469
Активность:
quq_CCCP, это может быть в кастом коде карты
Старый 27.02.2012, 10:17
Xoniks

offline
Опыт: 1,858
Активность:
quq_CCCP, left, right, resp созданы в отдельном триггере udg там не нужен, а что использовать вместо локаций?
Xoniks добавил:
Ty3uK, таймер нужен что бы цикл внутри цикла повторялся через каждые 2 сек пока j не станет равной 5, и у тебя в коде "attack" записан в виде ID где посмотреть для всех приказов ID?
Xoniks добавил:
» код
((код jass
globals
hashtable Hash = InitHashtable( )

integer array Creep
integer array itemid
integer array itemcount

integer index

location left = Location( -2180, 4777 )
location right = Location( 2180, 4777 )
location resp = Location( 0, -6255 )
endglobals
))
вот глобалки
Старый 27.02.2012, 11:28
Ty3uK

offline
Опыт: 2,469
Активность:
Xoniks, проверить не могу, накатал на коленке:
» Code
Код:
function Trig_Creep_Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer hid = GetHandleId(t)
    local integer count = LoadInteger(Hash, hid, 0)
    local integer i = 0
    local unit u
    if count > 4 then
    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(Hash, hid)
    else
        loop
        exitwhen i > 1
               set u = CreateUnit(Player(12), Creep[1], GetLocationX(left), GetLocationY(left), 270.)
               call IssuePointOrderById(u, 851983, GetLocationX(resp), GetLocationY(resp))
               set u = CreateUnit(Player(12), Creep[1], GetLocationX(right), GetLocationY(right), 270.)
               call IssuePointOrderById(u, 851983, GetLocationX(resp), GetLocationY(resp))
               i = i + 1
        endloop
    call SaveInteger(Hash, hid, 0, count + 1)
    endif
    set u = null
    set t = null
endfunction

function Trig_Creep_Actions takes nothing returns nothing
    call TimerStart(t, 2., true, function Trig_Creep_Timer)
endfunction


Ty3uK добавил:
» ID's
Код:
smart                 = 851971
  stop                  = 851972
  setrally              = 851980
  getitem               = 851981
  attack                = 851983
  attackground          = 851984
  attackonce            = 851985
  move                  = 851986
  AImove                = 851988
  patrol                = 851990
  holdposition          = 851993
  build                 = 851994
  humanbuild            = 851995
  orcbuild              = 851996
  nightelfbuild         = 851997
  undeadbuild           = 851998
  resumebuild           = 851999
  dropitem              = 852001
  detectaoe             = 852015
  resumeharvesting      = 852017
  harvest               = 852018
  returnresources       = 852020
  autoharvestgold       = 852021
  autoharvestlumber     = 852022
  neutraldetectaoe      = 852023
  repair                = 852024
  repairon              = 852025
  repairoff             = 852026
  revive                = 852039
  selfdestruct          = 852040
  selfdestructon        = 852041
  selfdestructoff       = 852042
  board                 = 852043
  forceboard            = 852044
  load                  = 852046
  unload                = 852047
  unloadall             = 852048
  unloadallinstant      = 852049
  loadcorpse            = 852050
  loadcorpseinstant     = 852053
  unloadallcorpses      = 852054
  defend                = 852055
  undefend              = 852056
  dispel                = 852057
  flare                 = 852060
  heal                  = 852063
  healon                = 852064
  healoff               = 852065
  innerfire             = 852066
  innerfireon           = 852067
  innerfireoff          = 852068
  invisibility          = 852069
  militiaconvert        = 852071
  militia               = 852072
  militiaoff            = 852073
  polymorph             = 852074
  slow                  = 852075
  slowon                = 852076
  slowoff               = 852077
  tankdroppilot         = 852079
  tankloadpilot         = 852080
  tankpilot             = 852081
  townbellon            = 852082
  townbelloff           = 852083
  avatar                = 852086
  unavatar              = 852087
  blizzard              = 852089
  divineshield          = 852090
  undivineshield        = 852091
  holybolt              = 852092
  massteleport          = 852093
  resurrection          = 852094
  thunderbolt           = 852095
  thunderclap           = 852096
  waterelemental        = 852097
  battlestations        = 852099
  berserk               = 852100
  bloodlust             = 852101
  bloodluston           = 852102
  bloodlustoff          = 852103
  devour                = 852104
  evileye               = 852105
  ensnare               = 852106
  ensnareon             = 852107
  ensnareoff            = 852108
  healingward           = 852109
  lightningshield       = 852110
  purge                 = 852111
  standdown             = 852113
  stasistrap            = 852114
  chainlightning        = 852119
  earthquake            = 852121
  farsight              = 852122
  mirrorimage           = 852123
  shockwave             = 852125
  spiritwolf            = 852126
  stomp                 = 852127
  whirlwind             = 852128
  windwalk              = 852129
  unwindwalk            = 852130
  ambush                = 852131
  autodispel            = 852132
  autodispelon          = 852133
  autodispeloff         = 852134
  barkskin              = 852135
  barkskinon            = 852136
  barkskinoff           = 852137
  bearform              = 852138
  unbearform            = 852139
  corrosivebreath       = 852140
  loadarcher            = 852142
  mounthippogryph       = 852143
  cyclone               = 852144
  detonate              = 852145
  eattree               = 852146
  entangle              = 852147
  entangleinstant       = 852148
  faeriefire            = 852149
  faeriefireon          = 852150
  faeriefireoff         = 852151
  ravenform             = 852155
  unravenform           = 852156
  recharge              = 852157
  rechargeon            = 852158
  rechargeoff           = 852159
  rejuvination          = 852160
  renew                 = 852161
  renewon               = 852162
  renewoff              = 852163
  roar                  = 852164
  root                  = 852165
  unroot                = 852166
  entanglingroots       = 852171
  flamingarrowstarg     = 852173
  flamingarrows         = 852174
  unflamingarrows       = 852175
  forceofnature         = 852176
  immolation            = 852177
  unimmolation          = 852178
  manaburn              = 852179
  metamorphosis         = 852180
  scout                 = 852181
  sentinel              = 852182
  starfall              = 852183
  tranquility           = 852184
  acolyteharvest        = 852185
  antimagicshell        = 852186
  blight                = 852187
  cannibalize           = 852188
  cripple               = 852189
  curse                 = 852190
  curseon               = 852191
  curseoff              = 852192
  freezingbreath        = 852195
  possession            = 852196
  raisedead             = 852197
  raisedeadon           = 852198
  raisedeadoff          = 852199
  instant               = 852200
  requestsacrifice      = 852201
  restoration           = 852202
  restorationon         = 852203
  restorationoff        = 852204
  sacrifice             = 852205
  stoneform             = 852206
  unstoneform           = 852207
  unholyfrenzy          = 852209
  unsummon              = 852210
  web                   = 852211
  webon                 = 852212
  weboff                = 852213
  wispharvest           = 852214
  auraunholy            = 852215
  auravampiric          = 852216
  animatedead           = 852217
  carrionswarm          = 852218
  darkritual            = 852219
  darksummoning         = 852220
  deathanddecay         = 852221
  deathcoil             = 852222
  deathpact             = 852223
  dreadlordinferno      = 852224
  frostarmor            = 852225
  frostnova             = 852226
  sleep                 = 852227
  darkconversion        = 852228
  darkportal            = 852229
  fingerofdeath         = 852230
  firebolt              = 852231
  inferno               = 852232
  gold2lumber           = 852233
  lumber2gold           = 852234
  spies                 = 852235
  rainofchaos           = 852237
  rainoffire            = 852238
  request_hero          = 852239
  disassociate          = 852240
  revenge               = 852241
  soulpreservation      = 852242
  coldarrowstarg        = 852243
  coldarrows            = 852244
  uncoldarrows          = 852245
  creepanimatedead      = 852246
  creepdevour           = 852247
  creepheal             = 852248
  creephealon           = 852249
  creephealoff          = 852250
  creepthunderbolt      = 852252
  creepthunderclap      = 852253
  poisonarrowstarg      = 852254
  poisonarrows          = 852255
  unpoisonarrows        = 852256
  frostarmoron          = 852458
  frostarmoroff         = 852459
  awaken                = 852466
  nagabuild             = 852467
  mount                 = 852469
  dismount              = 852470
  cloudoffog            = 852473
  controlmagic          = 852474
  magicdefense          = 852478
  magicundefense        = 852479
  magicleash            = 852480
  phoenixfire           = 852481
  phoenixmorph          = 852482
  spellsteal            = 852483
  spellstealon          = 852484
  spellstealoff         = 852485
  banish                = 852486
  drain                 = 852487
  flamestrike           = 852488
  summonphoenix         = 852489
  ancestralspirit       = 852490
  ancestralspirittarget = 852491
  corporealform         = 852493
  uncorporealform       = 852494
  disenchant            = 852495
  etherealform          = 852496
  unetherealform        = 852497
  spiritlink            = 852499
  unstableconcoction    = 852500
  healingwave           = 852501
  hex                   = 852502
  voodoo                = 852503
  ward                  = 852504
  autoentangle          = 852505
  autoentangleinstant   = 852506
  coupletarget          = 852507
  coupleinstant         = 852508
  decouple              = 852509
  grabtree              = 852511
  manaflareon           = 852512
  manaflareoff          = 852513
  phaseshift            = 852514
  phaseshifton          = 852515
  phaseshiftoff         = 852516
  phaseshiftinstant     = 852517
  taunt                 = 852520
  vengeance             = 852521
  vengeanceon           = 852522
  vengeanceoff          = 852523
  vengeanceinstant      = 852524
  blink                 = 852525
  fanofknives           = 852526
  shadowstrike          = 852527
  spiritofvengeance     = 852528
  absorb                = 852529
  avengerform           = 852531
  unavengerform         = 852532
  burrow                = 852533
  unburrow              = 852534
  devourmagic           = 852536
  flamingattacktarg     = 852539
  flamingattack         = 852540
  unflamingattack       = 852541
  replenish             = 852542
  replenishon           = 852543
  replenishoff          = 852544
  replenishlife         = 852545
  replenishlifeon       = 852546
  replenishlifeoff      = 852547
  replenishmana         = 852548
  replenishmanaon       = 852549
  replenishmanaoff      = 852550
  carrionscarabs        = 852551
  carrionscarabson      = 852552
  carrionscarabsoff     = 852553
  carrionscarabsinstant = 852554
  impale                = 852555
  locustswarm           = 852556
  breathoffrost         = 852560
  frenzy                = 852561
  frenzyon              = 852562
  frenzyoff             = 852563
  mechanicalcritter     = 852564
  mindrot               = 852565
  neutralinteract       = 852566
  preservation          = 852568
  sanctuary             = 852569
  shadowsight           = 852570
  spellshield           = 852571
  spellshieldaoe        = 852572
  spirittroll           = 852573
  steal                 = 852574
  attributemodskill     = 852576
  blackarrow            = 852577
  blackarrowon          = 852578
  blackarrowoff         = 852579
  breathoffire          = 852580
  charm                 = 852581
  doom                  = 852583
  drunkenhaze           = 852585
  elementalfury         = 852586
  forkedlightning       = 852587
  howlofterror          = 852588
  manashieldon          = 852589
  manashieldoff         = 852590
  monsoon               = 852591
  silence               = 852592
  stampede              = 852593
  summongrizzly         = 852594
  summonquillbeast      = 852595
  summonwareagle        = 852596
  tornado               = 852597
  wateryminion          = 852598
  battleroar            = 852599
  channel               = 852600
  parasite              = 852601
  parasiteon            = 852602
  parasiteoff           = 852603
  submerge              = 852604
  unsubmerge            = 852605
  neutralspell          = 852630
  militiaunconvert      = 852651
  clusterrockets        = 852652
  robogoblin            = 852656
  unrobogoblin          = 852657
  summonfactory         = 852658
  acidbomb              = 852662
  chemicalrage          = 852663
  healingspray          = 852664
  transmute             = 852665
  lavamonster           = 852667
  soulburn              = 852668
  volcano               = 852669
  incineratearrow       = 852670
  incineratearrowon     = 852671
  incineratearrowoff    = 852672
Старый 27.02.2012, 11:39
Faion
Noblesse Oblige
offline
Опыт: 30,395
Активность:
Я не пойму, координаты использовать религия не позволяет?

// Или опыт работы с jass? © Sc

Отредактировано ScorpioT1000, 27.02.2012 в 13:54.
Старый 27.02.2012, 13:19
Xoniks

offline
Опыт: 1,858
Активность:
Опыт работы, cJass я пока не трогал. vJass на нем понятней мне, а как с координатами сделать не напишешь?
Старый 27.02.2012, 15:35
BuxProf
БухПроф
offline
Опыт: 308
Активность:
Вместо применения локаций (left/right), используй напрямую их координаты.
Для каждой функции, которая требует точку, есть аналог с координатами (За исключением GetLocationZ, но возможно, есть и другие)
//например, вместо
location left = Location( -2180, 4777 ) 
CreateUnitAtLoc(Player(0), 'hfoo', left, 0)

//следует использовать
CreateUnit(Player(0), 'hfoo', -2180, 4777, 0)
Старый 29.02.2012, 17:26
Ответ

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы можете скачивать файлы

BB-коды Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход



Часовой пояс GMT +3, время: 09:14.