Wake of Gods Forum | Форум Во Имя Богов

Full Version: Ваши вопросы по ERM-скриптам
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
SergOz, и он перестаёт быть командирским?
Ну да - это не отменит его передачу командиру.
Сказалось то, что никогда не играю с командирами - слишком они имбовые, особенно с командирскими артами. В данном случае я вижу два пути: в окне героя заблокировать через !!СМ:R0; действие клика на арте #149, или в начале карты найти все арты #149 и заменить их (если это рандомная карта)
Если передача арта через ПКМ на артефакте в рюкзаке героя, то вопрос из разряда CM:I => HE:A => CM:R0.
Berserker mentioned the bug of losing stack exp with Ctrl + LMB on HD Mod can be fixed by script. But what's a good approach? As I know, the HD mod feature is executed before ERM. Do you suggest turning off HD Ctrl + LMB feature completely, use ERM for it instead?
Did you check it? I thought ERM handler is executed first.
Berserker, no, erm doesn't even notice. HD functions intercept all clicks on themselves
daemon_n, too bad. Awful, I would say.
Здравствуйте..

Не могу никак разобраться с 2-мя проблемами:

1. А возможно ли провести проверку: была ли нажата кнопка «уволить командира»? Меня интересует именно сама проверка, а была ли эта кнопка нажата!
Или это невозможно сделать никак?

S.P. к сожалению не получится произвести проверку на наличие мёртвого или уволенного командира, поскольку командир является не увольняемо бессмертным в моём случае и проверка такая !!CO:D и E просто-напросто не сработает! Bad

2.
Quote:CM:I => HE:A => CM:R0.
- я как раз пытался вчера подобное сделать, но почему то всё запрещать стало передавать командиру! Bad
Мой код
но он запрещает передачу всех артефактов командира в его иконку Bad

Quote:в окне героя заблокировать через !!СМ:R0; действие клика на арте #149,
- сама то беда как раз что я не могу никак определить этот арт. Не вижу нигде ресиверов, которые бы его определили при этом чтобы на нём прошло нажатие левой кнопки мыши! Bad

При открытии окна героя в триггере !?CO2 можно ли провести проверку на нажатие левой кнопкой мыши на артефакте именно 149 (то есть проверить коснулась ли левая кнопка мыши артефакта 149 или нет)?
Возможно ли сделать только один шлем в запрет передачи в иконку?

Заранее благодарен за совет или помощь….

P.S. как всегда если кто-то и пытается чем-то подсказать или помочь не требуя при этом ничего взамен или оплаты, то это всегда только Вы "SergOz". Спасибо..

Давайте тогда так поступим, раз консультировать просто так никто не будет, то сделайте мне этих два кода, но только не те, у которых я в чёрном списке + один обязательный (не совсем простой), который я позже напишу и я заплачу.. но всё надо на классическом ЕРМ
Hi, I'm getting really addicted to fast variables (f, i, t, etc.). How many are there?

Second question:
Just wrote a script by request. Good practice or nah?

Edit: The script is just updated. Now jumps to the next town if a town is with a hero.
The purpose of the script is to prevent taking a town without a fight
fatsawhorse, ERM 1 — это ассемблер. Мне лично тяжело читать и пытаться понять логику, за минуту тут не ответишь. Как не понять и что должны делать команды:
!!FU&y2<>0:E; выход если не щелчок на фоне???

!!VRy9|y4=149/y5=149/y6=149/y7=149/y8=149:S9;
Здесь используется переменная y9, которой ранее не задали значения по умолчанию, например 0.

!!CM&y9=9/y3=12:R0;
!!CM&y9=9/y3=13:R1;

Условия нужно проверять в начале триггера, а не размазывать по коду.
Если щелчок не там-то и там или не левой кнопкой мыши или с доп. кнопками клавиатуры, то выход.

Archer30,
Quick Vars (f..t): f g h i j k l m n o p q r s t

F^FindNextObject^ is not necessary anymore, I already fixed UN:U

Code:
[+] Improved UN:U command. It does not raise error if no more objects are found, but sets x-coordinate to -1 instead. Thus no premature
    objects counting is required. A new syntax with 6 parameters was added to allow using arbitrary integer variables instead of v-variables.
    !!UN:U(objectType)/(objectSubtype)/(direction like -1/-2 or object index)/(x)/(y)/(z).

    Example:
    ; Let's traverse through all map monsters, doubling their quantity

    !#VA(x:y) (y:y) (z:y); define variables to store object coordinates
    !!VR(x):S-1;           setting x-coordinate to -1 will force to start search from scratch

    !!re i; endless loop
      !!UN:U(OBJ_MONSTER)/(ANY_OBJ)/-1/(x)/(y)/(z); find next monster, (x) = -1 on failure
      !!br&(x)<0:;                                  exit loop if nothing found
      !!MO(x)/(y)/(z):Gd*2;                         double monsters quantity
    !!en:;

Suggestions:
-) Name functions using verbs/actions:

"EnsureTownsHaveArmy"
"EnsureNonEmptyTownGarrisons"
"EnsureTownsHaveGuards"
"AddTroopsToEmptyTowns"

-) Prefix your new functions with unique mod/script prefix to protect from same function name usage in different scripts/mods.
!?FU(arch_EnsureTownsHaveGuards)

-) Separate function arguments and any block-controls (if/el/en/re) with empty lines from the rest fo the code to improve readability.

-) Prefer to use local named variables to quick vars, unless it's single level loop with "i"-var. "g" does not tell anything.
(slotInd:y) is better then "g".

-) Try to use br/co as rare as possible and not to jump to outer level. The logics becomes less clear.

-) Use quick vars as rare as possible. Prefer local named variables. (townType:y) is better than "t".

-) Don't comment obvious things like "[define variables to store object coordinates]".
Better leave comment before complex loops or serious of actions, describing what is intended to be done.

-) Declare local arrays before usage on a separate line. Initialize static arrays outside of loops to not repeat the same heavy task in each iteration.

-) Give plural name to arrays. "firstLevelMons" instead of "firstLevelMon".

Educational version:

Final version:

Berserker, amazing work! I just added this post to my bookmark. This has to be read every time I start scripting! 132

A few questions:
1. This is supposed to be a single script mod. Say the mod is called Ensure Towns are Guarded, what do you suggest the main function to be named? prefix "etag", full fucntion name FU(etag_Main)?
2. Somehow I still like my !!co 2 line, I feel the logic is clearer (with comment). 96-copy
I'm confused with your last loop a bit. (SlotInd:y) was fixed in the range (ARMY_SLOT_FIRST) -> (ARMY_SLOT_LAST) from the previous loop, but in the last loop you checked for the condition when SlotInd > (ARMY_SLOT_LAST)
Archer30,

1) Generate random prefix in this case. cc2h_, for instance. It's unique and easy to replace with anything else any time.
2) Ok, if you like co 2.

"for i from 0 to 6 by 1" works in the following way

i = 0

while (i <= 6) do
    ...your code ...
    i = i + 1
end;

So i will become 7 and the loop will end. 7 > 6.



Here is classical linear search algorithm:

Code:
Initialize counters

while (check if we still in physical bounds of array) and (check if current item does not match our demands)
  Increase counter (go to the next counter)
end;

To check, if search succeeded, use the same physical bounds condition. If we still in array bounds, then something was found.
Example in ERM: search for number 999 in local array.

Very helpful example, Berserker JC_snack
Just wrote the script requested by Elmore.

Is the structure better?

Circular Mobile Darkness.erm

Question: In what scenario would you prefer variables to be announced at the beginning of a function?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
Reference URL's