viewing paste Poring Ball Main | Athena

Posted on the
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 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
//===== rAthena Script =======================================
//= Poring Ball
//===== Template By: =========================================
//= Saruka
//===== Revised By: ==========================================
//= Mysterious
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena SVN
//===== Description: =========================================
//= Football game made for Ragnarok Online, with a poring
//= as a ball.
//= The red team is on the east of the field
//= The blue team is on the west of the field
//===== Additional Comments: =================================
//= v1.0 - First release [Saruka]
//= v1.1 - Just fixed credits [Mysterious]
//= v1.2 - Revised a little bit [Mysterious]
//===== Prerequisites: =======================================
//= The Football Field: ball2
//= Red and Blue palettes: 78 & 79
//= red palette : $paletteRed
//= blue palette : $paletteBlue
//============================================================
quiz_02,349,390,4       script  Organizer#orga_ball     869,{
 
        //cutin "lhz_diguts02",2;
        set @palette, getlook(7);
        if ($@state_match == 1) goto OnConfirmation;
        if ($@state_match >= 2) goto OnMatchinplay;
 
Showgamerules:
        mes "[ ^BF0073Organizer^000000 ]";
        mes "Poring Ball is quite a simple game.";
        mes "You have to send the poring into your adversary's goal.";
        mes "The team that makes the most goals will win the match.";
        next;
        mes "[ ^BF0073Organizer^000000 ]";
        mes "However, before going onto the field, 2 teams must be made.";
        mes "All the members of one team have to be in the same group.";
        mes "Then a person of each group will go subscribe to one of the assistants.";
        mes "When 2 teams are subscribed, you will have to give them your confirmation.";
        mes "Once the teams are confirmed, all the players must come see me to be sent to the trainers.";
        mes "The trainers will send you on the field, the match will not wait for you so hurry!";
        next;
        mes "[ ^BF0073Organizer^000000 ]";
        mes "If no teams subscribe, room will be made for new teams.";
        goto OnClose;
 
// OnSubscriptionteam called by the assistants during the subscription of each team
OnSubscriptionteam:
        // if the 2 teams are subscribed
 
        if (($@redteamID!=0) && ($@blueteamID!=0) && (getpartyname($@redteamID)!="null") && (getpartyname($@blueteamID)!="null")) {
                announce "Organizer : The 2 teams are ready : "+getpartyname($@blueteamID)+" and "+getpartyname($@redteamID)+".",bc_yellow|bc_map;
                announce "Organizer : You have 1 minute so that a member of each team can come confirm the subscription.",bc_yellow|bc_map;
                if ($@state_match!=1) {
                        set $@state_match, 1;
                        stopnpctimer;
                        initnpctimer;
                }
        }
        end;
 
OnConfirmation:
        if ((getcharid(1)!=$@redteamID) && (getcharid(1)!=$@blueteamID)) {
                // if the player isn't in one of the teams send him back to the game rules.
                goto Showgamerules;
        }
 
        if (getcharid(1)==$@redteamID) {
                // Confirm if the player is part of the Red Team
                mes "[ ^BF0073Organizer^000000 ]";
                mes "Thank you for confirming with the Red Team.";
                if ($@redconfirmation==1) goto OnClose; // if we have already confirmed, no need to go further.
                set $@redconfirmation, 1;
                close2;
        }
        // else
        if (getcharid(1)==$@blueteamID) {
                // Confirm if player is part of the Blue Team
                mes "[ ^BF0073Organizer^000000 ]";
                mes "Thank you for confirming with the Blue Team.";
                if ($@blueconfirmation==1) goto OnClose; // if we have already confirmed, no need to go further.
                set $@blueconfirmation, 1;
                close2;
        }
 
        // verify that the groups haven't been sorted
        if ((getpartyname($@redteamID)=="null") || (getpartyname($@blueteamID)=="null")) {
                announce "Organizer : The teams are not valid anymore, the match has been cancelled.",bc_yellow|bc_map;
                stopnpctimer;
                callsub OnMatchcancellation;
                goto OnClose;
                end;
        }
 
        if (($@state_match!=2) && ($@blueconfirmation==1) && ($@redconfirmation==1)) {
                stopnpctimer;
                announce "Organizer : The match will begin soon! ALL the players must contact me to be transferred on to the field.",bc_yellow|bc_map;
                set $@state_match, 2;
                donpcevent "TimerInitMatch::OnStart";
        }
        cutin "",255;
        end;
 
OnTimer60000:
        announce "Organizer : The delay of the confirmation has passed, the match is cancelled...",bc_npc|bc_map;
        callsub OnMatchcancellation;
        end;
 
OnMatchcancellation:
        set $@state_match, 0;
        set $@blueteamID, 0;
        set $@redteamID, 0;
        set $@redconfirmation, 0;
        set $@blueconfirmation, 0;
        set $@isballonfield, 0;
        set $@teampossessingballID, 0;
        return;
 
OnMatchinplay:
        if (getcharid(1)==$@redteamID) { // if the player is from the red team
                mes "[ ^BF0073Organizer^000000 ]";
                mes "Ready to play?";
                switch (select("I want to go on the field.","I want to cancel the match.")) {
                        case 1:
                                // Test actual palette
                                if (@palette != $paletteRed) {
                                        if (@palette != $paletteBlue) {
                                                // The player isn't wearing a suit, you need to save his suit at the lockers, to give it back after
                                                set savePalette, @palette;
                                        }
                                        setlook 7, $paletteRed;
                                }
 
                                savepoint "quiz_02",335,345;
                                percentheal 100,100;
                                warp "quiz_02",335,345;
                                goto OnClose;
                        case 2:
                                cutin "",255;
                                cutin "lhz_diguts07",2;
                                set $@redconfirmation,2;
                                announce "Organizer : "+strcharinfo(0)+" of the Red Team asks for a match cancellation.",bc_npc|bc_map;
                }
        } else if (getcharid(1)==$@blueteamID) { // if the player is from the blue team
                mes "[ ^BF0073Organizer^000000 ]";
                mes "Ready to play?";
                switch (select("- Go to field","- Cancel the Match")) {
                        case 1:
                                // Test actual palette
                                if (@palette != $paletteBlue) {
                                        if (@palette != $paletteRed) {
                                                // The player isn't wearing a suit, you need to save his suit at the lockers, to give it back after
                                                set savePalette, @palette;
                                        }
                                        setlook 7, $paletteBlue;
                                }
 
                                savepoint "quiz_02",364,345;
                                percentheal 100,100;
                                warp "quiz_02",364,345;
                                goto OnClose;
                        case 2:
                                cutin "",255;
                                cutin "lhz_diguts07",2;
                                set $@blueconfirmation,2;
                                announce "Organizer : "+strcharinfo(0)+" of the Blue Team asks for a match cancellation.",bc_npc|bc_map;
                }
        } else {
                // if the player isn't in one of the teams send him back to the game rules.
                goto Showgamerules;
        }
        if (($@blueconfirmation==2) && ($@redconfirmation==2)) {
                announce "Organizer : Match has been cancelled.",bc_npc|bc_map;
                callsub OnMatchcancellation;
                donpcevent "TimerMatchcancellation::OnMatchcancellation";
                end;
        }
        goto OnClose;
 
// At the start of map server :
OnInit:
        set $paletteRed, 79;
        set $paletteBlue, 78;
        // Warp all the players from map ball2 near the Organizer.
        callsub OnMatchcancellation;
        end;
 
OnClose:
        close2;
        cutin "",255;
        end;
}
 
 
quiz_02,363,365,4       script  Red Assistant#coach_R   911,{
 
        // If a match is in play
        if ($@state_match >= 2) {
                mes "[Red Assistant]";
                mes "The subscriptions are currently unavailable because a match is in progress. Don't hesitate to try again in a few minutes!";
                close;
        }
 
        // Does the player belong to a group?
        if (getcharid(1)==0) {
                mes "[Red Assistant]";
                mes "The subscriptions are for groups, and you're not in a group. Come back with your friends!";
                close;
        }
 
        // Isn't the group of the player subscribed as the blue team?
        if (getcharid(1)==$@blueteamID) {
                mes "[Red Assistant]";
                mes "Hey! A player from the opposing team! Get ready to face off one of the best teams!";
                mes "The formidable Red Team!";
                close;
        }
 
        // If a team is already subscribed, and that team still exists
        if (($@redteamID!=0) && (getpartyname($@redteamID)!="null")) {
 
                // if the player belongs to that team that's already subscribed
                if ($@redteamID==getcharid(1)) {
                        mes "[Red Assistant]";
                        mes "Do you wish to unsubscribe your team?";
                        next;
                        if (select("Yes, we want to stop the match.","No, we're staying.")==2) close;
                        // if the player wishes to unsubscribe their team
                        announce "Team "+getpartyname($@redteamID)+" has disbanded. There is no more Red Team!",bc_yellow|bc_map;
                        set $@redteamID, 0;
                        close;
                }
                mes "[Red Assistant]";
                mes "A team is already subscribed! It's Team "+getpartyname($@redteamID)+".";
                close;
        }
 
        // if there are no teams subscribed and that the subscriptions are open
        mes "[Red Assistant]";
        mes "Do you wish to subscribe your team?";
        next;
        if (select("Yes, we want to subscribe.","No.")==2) close;
 
        // Team subscription
        if ($@redteamID==0 || (getpartyname($@redteamID)=="null")) {
                set $@redteamID, getcharid(1);
                mes "[Red Assistant]";
                mes "Your team is now subscribed, good luck!";
                announce ""+getpartyname($@redteamID)+" Team has subscribed as the Red Team!",bc_yellow|bc_map;
                close2;
                doevent "Organizer#orga_ball::OnSubscriptionteam";
        } else {
                mes "[Red Assistant]";
                mes "I'm sorry! Another team has subscribed before you...";
                close2;
        }
        end;
 
}
 
quiz_02,336,365,4       script  Blue Assistant#coach_B  912,{
 
        // If a match is in play
        if ($@state_match >= 2) {
                mes "[Blue Assistant]";
                mes "The subscriptions are currently unavailable because a match is in progress. Don't hesitate to try again in a few minutes!";
                close;
        }
 
        // Does the player belong to a group?
        if (getcharid(1)==0) {
                mes "[Blue Assistant]";
                mes "The subscriptions are for groups, and you're not in a group. Come back with your friends!";
                close;
        }
 
        // Isn't the group of the player subscribed as the red team?
        if (getcharid(1)==$@redteamID) {
                mes "[Blue Assistant]";
                mes "Hey! A player from the opposing team! Get ready to face off one of the best teams!";
                mes "The formidable Blue Team!";
                close;
        }
 
        // If a team is already subscribed, and that team still exists
        if (($@blueteamID!=0) && (getpartyname($@blueteamID)!="null")) {
                // if the player belongs to that team that's already subscribed
                if ($@blueteamID==getcharid(1)) {
                        mes "[Blue Assistant]";
                        mes "Do you wish to unsubscribe your team?";
                        next;
                        if (select("Yes, we want to stop the match.","No, we're staying.")==2) close;
                        // if the player wishes to unsubscribe their team
                        announce "Team "+getpartyname($@blueteamID)+" has disbanded. There is no more Blue Team!",bc_yellow|bc_map;
                        set $@blueteamID, 0;
                        close;
                }
                mes "[Blue Assistant]";
                mes "A team is already subscribed! It's Team "+getpartyname($@blueteamID)+".";
                close;
        }
 
        // if there are no teams subscribed and that the subscriptions are open
        mes "[Blue Assistant]";
        mes "Do you wish to subscribe your team?";
        next;
        if (select("Yes, we want to subscribe.","No.")==2) close;
 
        // Team subscription
        if ($@blueteamID==0 || (getpartyname($@blueteamID)=="null")) {
                set $@blueteamID, getcharid(1);
                mes "[Blue Assistant]";
                mes "Your team is now subscribed, good luck!";
                announce ""+getpartyname($@blueteamID)+" Team has subscribed as the Blue Team!",bc_yellow|bc_map;
                close2;
                doevent "Organizer#orga_ball::OnSubscriptionteam";
        } else {
                mes "[Blue Assistant]";
                mes "I'm sorry! Another team has subscribed before you...";
                close2;
        }
        end;
}
 
 
quiz_02,326,336,4       script  Red Coach#coach_R       911,{
 
        mes "[Red Coach]";
        if (getcharid(1)!=$@redteamID) {
                mes "It looks like you got nothing to do here...";
                close2;
                goto OnLeave;
        }
 
        mes "Hello, I am the Coach of the Red Team!";
        next;
        percentheal 100,20;
        switch(select("Go on the field","Leave","Cancel")) {
                case 1:
                        // If the match begins, warp immediately,
                        if ($@state_match==2) goto OnReadyformatch;
                        // otherwise, determine waiting time before being rewarped on the field
                        set @waiting_time, 5000;
                        if ($@state_match==3) {
                                mes "[Red Coach]";
                                mes "You will be sent on the field in "+(@waiting_time/1000)+ " seconds, be ready!";
                                close2;
                                addtimer @waiting_time, "Red Coach#coach_R::OnReadyformatch";
                        }
                        break;
                case 2:
                        goto OnLeave;
                        break;
                case 3:
                        break;
        }
        close;
 
OnLeave:
        warp "quiz_02",350,374;
        close;
 
// Warp on the field
OnReadyformatch:
        set @poringBallAura, 0;
        warp "ball2",66,56;
        end;
}
 
 
quiz_02,373,336,4       script  Blue Coach#coach_B      912,{
 
        mes "[Blue Coach]";
        if (getcharid(1)!=$@blueteamID) {
                mes "It looks like you got nothing to do here...";
                close2;
                goto OnLeave;
        }
        mes "Hello, I am the coach of the Blue Team!";
        next;
        percentheal 100,20;
        switch(select("Go on the field","Leave","Cancel")) {
                case 1:
                        // If the match begins, warp immediately,
                        if ($@state_match==2) goto OnReadyformatch;
                        // otherwise, determine waiting time before being rewarped on the field
                        else if ($@state_match==3) {
                                set @waiting_time, 5000;
                                mes "[Blue Coach]";
                                mes "You will be sent on the field in "+(@waiting_time/1000)+ " seconds, be ready!";
                                close2;
                                addtimer @waiting_time, "Blue Coach#coach_B::OnReadyformatch";
                        }
                        break;
                case 2:
                        goto OnLeave;
                        break;
                case 3:
                        break;
        }
        close;
 
OnLeave:
        warp "quiz_02",350,374;
        close;
 
// Warp on the field
OnReadyformatch:
        set @poringBallAura, 0;
        warp "ball2",54,56;
        close;
}
 
 
ball2,0,0,0     script  TimerInitMatch  -1,{
 
OnStart:
        // countdown before the match begins
        set $@teampossessingballID, 0;
        set $@score_blue_match, 0;
        set $@score_red_match, 0;
        stopnpctimer; // normally pointless, but seeing the consequences of a npc timer, we won't take a chance.
        initnpctimer;
        announce "Match will begin in 30 seconds.",bc_npc|bc_map;
        //doevent "Ball::OnReturntomiddle";
        end;
OnTimer5000:
        announce "Match will begin in 25 seconds.",bc_npc|bc_map;
        end;
OnTimer10000:
        announce "Match will begin in 20 seconds.",bc_npc|bc_map;
        end;
OnTimer15000:
        announce "Match will begin in 15 seconds.",bc_npc|bc_map;
        end;
OnTimer20000:
        announce "Match will begin in 10 seconds.",bc_npc|bc_map;
        end;
OnTimer25000:
        announce "Match will begin in 5 seconds.",bc_npc|bc_map;
        end;
OnTimer30000:
        announce "The match has begun!",bc_npc|bc_map;
        stopnpctimer;
        donpcevent "TimerMatch::OnStartMatch";
        pvpon "ball2";
        end;
}
 
 
ball2,0,0,0     script  TimerMatch      -1,{
 
OnStartMatch:
        stopnpctimer; // normally pointless, but seeing the consequences of a npc timer, we won't take a chance.
        initnpctimer;
        set $@state_match,3;
        end;
OnTimer180000:
        mapannounce "ball2", "Halftime! Score is currently "+$@score_blue_match+" (Blue) / "+$@score_red_match+" (Red)",bc_map;
        end;
OnTimer360000:
        mapannounce "ball2", "The match is over! Scores end with "+$@score_blue_match+" (Blue) / "+$@score_red_match+" (Red)",bc_map;
        set $@state_match,4;
        pvpoff "ball2";
        end;
 
OnTimer362000:
        if ($@score_blue_match<$@score_red_match)
                mapannounce "ball2", "Congratulations to the Red Team!!",bc_map;
        else if ($@score_blue_match>$@score_red_match)
                mapannounce "ball2", "Congratulations to the Blue Team!!",bc_map;
        else mapannounce "ball2", "It's a tie!!",bc_map;
        donpcevent "Ball::OnReturntomiddle";
        end;
 
OnTimer420000:
        mapwarp "ball2","quiz_02",350,374;
        set $@state_match,0;
        set $@blueteamID, 0;
        set $@redteamID, 0;
        set $@redconfirmation, 0;
        set $@blueconfirmation, 0;
        set $@teampossessingballID, 0;
        end;
}
 
 
ball2,0,0,0     script  TimerMatchcancellation  -1,{
 
OnMatchcancellation:
        set $@state_match, 4;
        mapannounce "ball2", "Score is currently "+$@score_blue_match+" (Blue) / "+$@score_red_match+" (Red)",bc_map;
        mapannounce "ball2", "The match has been cancelled to a team or coach's request!",bc_map;
        donpcevent "Ball::OnReturntomiddle";
        stopnpctimer;
        initnpctimer;
        end;
 
OnTimer4000:
        stopnpctimer;
        mapwarp "ball2","quiz_02",350,374;
        set $@state_match,0;
        end;
}
 
 
ball2,60,56,4   script  Ball    1002,{
 
// Kicking the ball allows it to move from many squares,
// however its location is determined square by square.
// The ball draws its course by moving forward from a square every 150 ms.
// Every time it lands on a square it makes some tests to determine if a goal has been made,
// if it came out of the field, etc.
// If that is the case it returns to its place on its own (middle of the field, corners, etc.)
 
        if ($@state_match!=3) {
                // If there are no matches in progress ( hasn't started yet, just finished, etc.)
                npctalk "No match! Don't touch!";
                end;
        }
 
        if ($@destinationType>0) {
                end;
        }
 
        // If the player isn't in one of the 2 subscribed teams :
        if ((getcharid(1) == 0) || ((getcharid(1) != $@redteamID)  && (getcharid(1) != $@blueteamID))) {
                npctalk "A trespasser!! Get out "+strcharinfo(0)+" !";
                warp "quiz_02",350,374;
                end;
        }
 
        set $@Activeplayers$, strcharinfo(0);
        set $@ActiveteamID, getcharid(1);
 
        // Player and ball coordinates at the time of the shot
        getmapxy $@mapname$,$@mapxNPC,$@mapyNPC,1;
        getmapxy $@mapname$,$@mapxPC,$@mapyPC,0;
 
        // verification of the player's distance / ball : the player must be 1 square from the ball.
        if (distance($@mapxNPC,$@mapyNPC,$@mapxPC,$@mapyPC)>2) {
                dispbottom "You cannot shoot the Poring Ball at distance.";
                end;
        }
 
        // Watch out for the position of the stopnpctimer, some tests must be made beforehand (has the player really hit the ball?)
        stopnpctimer;
 
        specialeffect 26;
        specialeffect 44;
        npcspeed 98;
 
        // Research of the distance the ball will travel
        // (still for now)
        set $@distance,4;
 
        // Research of the position of the ball X
        if ($@mapxPC<$@mapxNPC) set $@movementX, 1;
        else if ($@mapxPC>$@mapxNPC) set $@movementX, -1;
        else set $@movementX, 0;
 
        // Research of the position of the ball Y
        if ($@mapyPC<$@mapyNPC) set $@movementY, 1;
        else if ($@mapyPC>$@mapyNPC) set $@movementY, -1;
        else set $@movementY, 0;
 
        // If the ball is already out of the field, it cannot be moved further away from the field
        if ($@isballonfield==1) {
                if ((23>=$@mapyNPC+$@movementY)||($@mapyNPC+$@movementY>=89)||(12>=$@mapxNPC+$@movementX)||($@mapxNPC+$@movementX>=108)) end;
        }
 
        // Check if the ball is in a team's possession (for example after the ball's been kicked out of the field by a team,
        // only the other team has the right to give the first hit to the ball)
        if ($@teampossessingballID != 0) && ($@ActiveteamID != $@teampossessingballID) {
                dispbottom "The other team gets the Poring.";
                end;
        }
        else set $@teampossessingballID, 0;
 
        // start of the ball's movement
 
        set $@mapxNPC, $@mapxNPC+$@movementX;
        set $@mapyNPC, $@mapyNPC+$@movementY;
 
        npcwalkto $@mapxNPC,$@mapyNPC;
        //npctalk "npcwalkto A "+$@mapxNPC+" "+$@mapyNPC;
        goto Whereistheball;
        end;
 
OnTimer150:
        stopnpctimer;
        getmapxy $@mapname$,$@mapxNPC,$@mapyNPC,1;
        //npctalk "getmapxy "+$@mapxNPC+" "+$@mapyNPC;
 
        // Research of the direction if the ball already has one
        if ($@destinationType>0) {
                switch($@destinationType) {
                        case 0: break;
                        case 1: // Go to the middle of the field
                                set $@destinationX, 60;
                                set $@destinationY, 56;
                                break;
                        case 2: // Go to the North West corner
                                set $@destinationX, 15;
                                set $@destinationY, 86;
                                break;
                        case 3: // Go to the North East corner
                                set $@destinationX, 105;
                                set $@destinationY, 86;
                                break;
                        case 4: // Go to the South West corner
                                set $@destinationX, 15;
                                set $@destinationY, 26;
                                break;
                        case 5: // Go to the South East corner
                                set $@destinationX, 105;
                                set $@destinationY, 26;
                                break;
                        case 6: // Go to the West Goal
                                set $@destinationX, 19;
                                set $@destinationY, 56;
                                break;
                        case 7: // Go to the East Goal
                                set $@destinationX, 101;
                                set $@destinationY, 56;
                                break;
                }
 
                // Research of the movement X of the ball to get closer to destination
                if ($@destinationX<$@mapxNPC) set $@movementX, -1;
                else if ($@destinationX>$@mapxNPC) set $@movementX, 1;
                else set $@movementX, 0;
 
                // Research of the movement Y of the ball to get closer to destination
                if ($@destinationY<$@mapyNPC) set $@movementY, -1;
                else if ($@destinationY>$@mapyNPC) set $@movementY, 1;
                else set $@movementY, 0;
 
                // Movement of the ball
                npcwalkto $@mapxNPC+$@movementX,$@mapyNPC+$@movementY;
                getmapxy $@mapname$,$@mapxNPC,$@mapyNPC,1;
 
                // if the ball still hasn't reached its destination, restart the timer
                if (($@mapxNPC==$@destinationX) && ($@mapyNPC==$@destinationY)) set $@destinationType,0;
                else {
                        stopnpctimer;
                        initnpctimer;
                }
                end;
        }      
 
        // save the coordinates " before movement " (to delete the players from the minimaps)
        //set $@mapxNPCold, $@mapxNPC;
        //set $@mapyNPCold, $@mapyNPC;
 
        // If the ball doesn't have a precise destination, it continues its previous movement
        set $@mapxNPC, $@mapxNPC+$@movementX;
        set $@mapyNPC, $@mapyNPC+$@movementY;
 
        npcwalkto $@mapxNPC,$@mapyNPC;
        //npctalk "npcwalkto B "+$@mapxNPC+" "+$@mapyNPC;
 
        // Update the movement of the Poring on the minimap
 
        // for every player on the map
                // affects rid with a thing like : getcharid(3)
                //attachrid($@thingmabob_rid);
                // delete old save point
                // draw new save point
 
        goto Whereistheball;
        end;
 
OnReturntomiddle:
        set $@destinationType, 1;
        stopnpctimer;
        initnpctimer;
        end;
 
Whereistheball:
        // Note :
        // the command "getmapxy $@mapname$,$@mapxNPC,$@mapyNPC,1;" previously used here
        // wasn't allowing enough time for the ball to move, and often gave its coordinated to the movement
        // so instead I update the coordinates of the ball manually when it is being moved. This means that we work with
        // the " supposed " coordinates of the ball.
        // If the supposed coordinates ever didn't fit with the real coordinates, there would be a need to think
        // a way to give the ball the time to move, before doing the getmapxy.
 
        //If the ball was out, test if it came back on the field
        if ($@isballonfield==1) {
                if (((23<$@mapyNPC)&&($@mapyNPC<89))&&((12<$@mapxNPC)&&($@mapxNPC<108))) {
                        mapannounce "ball2", "The Poring is back on the field.",bc_blue;
                        set $@isballonfield,0;
                }
 
        } else {
 
                if ($@mapxNPC>=108) {
                // T h e    b a l l    i s    o n    t h e    e a s t    s i d e
 
                        // Check if we are in the right-side goal
                        if ((53<=$@mapyNPC)&&($@mapyNPC<=59)) {
 
                                mapannounce "ball2", " "+$@Activeplayers$+" has scored a goal for the Blue Team!",bc_blue;
                                npctalk "Goal! I'll return to the middle of the field.";
                                set $@score_blue_match, $@score_blue_match+1;
                                set $@destinationType, 1;
                                set $@teampossessingballID, $@redteamID;
                                stopnpctimer;
                                initnpctimer;
                                end;
                        }
                        // if we are not in the goal,
                        mapannounce "ball2",  " "+$@Activeplayers$+" has sent the Poring Ball out of the field!",0xFF0000;
                        //set isballonfield,1;
 
                        if ($@ActiveteamID==$@redteamID) {
                                // If the ball gets kicked by a player from the defending team, send the ball in the right corner :
                                if ($@mapyNPC<=56) {
                                        npctalk "Out of the field! I am going to the corner.";
                                        set $@destinationType, 5; // Destination South East
                                } else {
                                        npctalk "Out of the field! I am going to the corner.";
                                        set $@destinationType, 3; // Destination North West
                                }
                                // It's the blue team (attackers) that now possess the ball:
                                set $@teampossessingballID, $@blueteamID;
 
                        } else if ($@ActiveteamID==$@blueteamID) {
                                // If the ball gets kicked by a player from the attacking team, send the ball in front of the goal
                                npctalk "Out of the field! I am going in front of the Red Team's goal.";
                                set $@destinationType, 7; // Destination East Goal
 
                                // It's the red team (defenders) that now possess the ball:
                                set $@teampossessingballID, $@redteamID;
                        } else end;
                        stopnpctimer;
                        initnpctimer;
                        end;
                } else if ($@mapxNPC<=12) {
                        // T h e    b a l l    i s    o n    t h e    w e s t    s i d e
 
                        // Check if we are in the left-side goal
                        if ((53<=$@mapyNPC)&&($@mapyNPC<=59)) {
 
                                mapannounce "ball2", " "+$@Activeplayers$+" has scored a goal for the Red Team!",bc_blue;
                                npctalk "Goal! I'll return in the middle of the field.";
                                set $@score_red_match, $@score_red_match+1;
                                set $@destinationType, 1; // Destination middle of the field
                                set $@teampossessingballID, $@blueteamID;
                                stopnpctimer;
                                initnpctimer;
                                end;
                        }
 
                        mapannounce "ball2", " "+$@Activeplayers$+" has sent the Poring Ball out of the field!",0xFF0000;
                        //set isballonfield,1;
                        if ($@ActiveteamID==$@blueteamID) {
                                // If the ball gets kicked by a player from the defending team, send the ball in the right corner:
                                if ($@mapyNPC<=56) {
                                        npctalk "Out of the field! I am going to the corner.";
                                        set $@destinationType, 4; // Destination South East
                                } else {
                                        npctalk "Out of the field! I am going to the corner.";
                                        set $@destinationType, 2; // Destination North West
                                }
                                // It's the red team (attackers) that now possess the ball:
                                set $@teampossessingballID, $@redteamID;
 
                        } else if ($@ActiveteamID==$@redteamID) {
                                // If the ball gets kicked by a player from the attacking team, send the ball in front of the goal
                                npctalk "Out of the field! I am going in front of the Blue Team's goal.";
                                set $@destinationType, 6; // Destination West Goal
                                // It's the blue team (defenders) that now possess the ball:
                                set $@teampossessingballID, $@blueteamID;
                        } else end;
                        stopnpctimer;
                        initnpctimer;
                        end;
                } else if (($@mapyNPC>=89)||($@mapyNPC<=23)) {
                        // T h e    b a l l    i s    o n    ( e i t h e r    N o r t h    o r    S o u t h    s i d e )
 
                        mapannounce "ball2", " "+$@Activeplayers$+" has sent the Poring Ball out of the field!",0xFF0000;
 
                        set $@isballonfield,1;
                        if ($@ActiveteamID==$@redteamID) {
                                set $@teampossessingballID, $@blueteamID;
                                npctalk "Poring for the Blue Team.";
                        } else if ($@ActiveteamID==$@blueteamID) {
                                set $@teampossessingballID, $@redteamID;
                                npctalk "Poring for the Red team.";
                        }
                        end;
                }
        }
 
        // Preparation for the next movement
        set $@distance,$@distance-1;
        if ($@distance>0) {
                stopnpctimer;
                initnpctimer;
        }
        end;
}
 
 
// *******************************************************************
//                         Others                 NPCs
// *******************************************************************
 
ball2,108,52,2  script  Red Flag#fred1  722,{
        end;
}
 
ball2,108,60,2  script  Red Flag#fred2  722,{
        end;
}
 
ball2,12,52,6   script  Blue Flag#fblue1        722,{
        end;
}
 
ball2,12,60,6   script  Blue Flag#fblue2        722,{
        end;
}
 
 
ball2,60,17,8   script  Field Assistant 913,{
 
        mes "[Field Assistant]";
        mes "Hi, what do you want?";
        next;
        if (getgmlevel()>79) {
                switch(select("Leave","Cancel","Cancel the match","Give a point to the Red Team","Give a point to the Blue Team","Put the ball back in the middle")) {
                        case 1:
                                goto OnLeave;
                                break;
                        case 2:
                                break;
                        case 3:
                                if ($@state_match == 3) {
                                        set $@blueteamID, 0;
                                        set $@redteamID, 0;
                                        set $@redconfirmation, 0;
                                        set $@blueconfirmation, 0;
                                        set $@state_match, 0;
                                        set $@isballonfield, 0;
                                        set $@teampossessingballID, 0;
                                        donpcevent "TimerMatchcancellation::OnMatchcancellation";
                                } else mes "No match is in progress.";
                                break;
                        case 4:
                                if ($@state_match == 3) {
                                        mapannounce "ball2", " "+strcharinfo(0)+ " has added a point for the Red Team!",bc_blue;
                                        set $@score_match_rouge, $@score_match_rouge+1;
                                } else mes "No match is in progress.";
                                break
                        case 5:
                                if ($@state_match == 3) {
                                        mapannounce "ball2", " "+strcharinfo(0)+ " has added a point for the Blue Team!",bc_blue;
                                        set $@score_blue_match, $@score_blue_match+1;
                                } else mes "No match is in progress.";
                                break;
                        case 6:
                                mes "To be continued.";                        
                                break;                                 
                }
 
        } else {
 
                switch(select("Leave","Cancel")) {
                        case 1:
                                goto OnLeave;
                                break;
                        case 2:
                                break;
                }
        }
        close;
 
OnLeave:
        warp "quiz_02",350,374;
        close;
 
}
 
 
// map football field
ball2   mapflag noicewall
//ball2 mapflag pvp
ball2   mapflag pvp_noguild
ball2   mapflag nomemo
ball2   mapflag noteleport
ball2   mapflag nowarp
ball2   mapflag nosave  SavePoint
ball2   mapflag nopenalty
ball2   mapflag nobranch
ball2   mapflag noexp
 
// map for team constitution
quiz_02 mapflag noskill
quiz_02 mapflag nomemo
quiz_02 mapflag nobranch
quiz_02 mapflag nopenalty
quiz_02 mapflag noexp
Viewed 246 times, submitted by unknown.