SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | - | const uint checkCampInterval=80; //how often to check for camping (gameticks) |
2 | + | Punish campers xd! v1.1 |
3 | ||
4 | changes: | |
5 | -had to recreate the onPlayer function, because it wouldn't work for clients :S | |
6 | -moved a message out of isInCampArea() | |
7 | -killed player with .kill() instead of .health=0 (thx cooba) | |
8 | ||
9 | improvements needed: | |
10 | -show time remaining in campspot (could be achieved with the timer functions, I assume) | |
11 | -don't kill players if the game is stopped (the AngelScript implementation needs a new bool) | |
12 | -the chat is sent as teamchat if the player last used teamchat | |
13 | - | {{29,12}, {40,12}, {500}}, //camparea #0: on top of seek pu |
13 | + | -you regain health if you die on purpose with flag xd |
14 | - | {{64,05}, {101,19}, {500}} //camparea #1: the rf area |
14 | + | */ |
15 | ||
16 | /** script settings **/ | |
17 | const uint checkCampInterval=70; //how often to check for camping (gameticks) 70 = one second | |
18 | /*********************/ | |
19 | ||
20 | - | "in the rf area" //camparea #1 |
20 | + | |
21 | array<array<array<int>>> campArea = { | |
22 | /* A camparea is a rectangle referred to by its top left and bottom right corner | |
23 | x,y ----------- | |
24 | | | | |
25 | | | | |
26 | ----------- a,b */ | |
27 | // camparea(x,y) camparea(a,b) allowed camp time(gameticks) | |
28 | {{29,12}, {40,12}, {250}}, //camparea #0: on top of seek pu | |
29 | {{64,05}, {101,19}, {500}}, //camparea #1: the rf area | |
30 | {{30,49}, {64,56}, {250}}, //at carrot | |
31 | {{30,14}, {41,19}, {250}} //in the seek box | |
32 | }; | |
33 | //it doesn't seem like you can have mixed arrays in AS | |
34 | //so we just put the strings in a separatr array | |
35 | array<string> campAreaName = { | |
36 | "above seeks", //camparea #0 | |
37 | "in the rf area", //camparea #1 | |
38 | "at carrot", | |
39 | "in the seek box" | |
40 | }; | |
41 | /******** end of level settings ********/ | |
42 | ||
43 | /** script globals **/ | |
44 | const uint campAreas = campArea.length(); //save the number of campAreas for easy reference | |
45 | - | campTime[camparea] += checkCampInterval; |
45 | + | |
46 | /********************/ | |
47 | - | jjPlayers[player].showText("You are camping " + campAreaName[camparea]); //display text (looks stupid if |
47 | + | |
48 | ||
49 | /** This function checks if a player is in a certain camparea **/ | |
50 | /** and returns two bools: 1) whether the player is in the camp area **/ | |
51 | /** and 2) whether they have been there for too long **/ | |
52 | - | else campTime[camparea] = 0; //player not camping -> reset timer |
52 | + | |
53 | array<bool> returnThis = {false, false}; //we assume that the player is not camping | |
54 | // (and not for too long) | |
55 | int maxCamp = campArea[camparea][2][0]; //store a bunch of information in temporary | |
56 | int xCamp = campArea[camparea][0][0]; //variables for easier reading | |
57 | - | /** You guys know what this one does already! **/ |
57 | + | |
58 | - | void onPlayer() { |
58 | + | |
59 | - | if (jjGameTicks % checkCampInterval == 0) { //(thanks Artem/Foly) |
59 | + | |
60 | - | for (uint i=0; i < campAreas;i++) { //loop through all camp areas |
60 | + | |
61 | int yPos = jjPlayers[player].yPos / 32; | |
62 | - | array<bool> isCamping = isInCampArea(p.localPlayerID, i); //check player and area, store result |
62 | + | |
63 | - | if (isCamping[0]) { //is current player in camparea #1? |
63 | + | |
64 | - | if (isCamping[1]) { //has current player been there for too long? |
64 | + | campTime[camparea] += checkCampInterval; //update camptime |
65 | returnThis[0] = true; //set bool is camping | |
66 | - | p.health = 0; //kill the player |
66 | + | |
67 | - | campTime[i] = 0; //reset timer |
67 | + | |
68 | } | |
69 | } | |
70 | else { | |
71 | campTime[camparea] = 0; //player not camping -> reset timer | |
72 | } | |
73 | ||
74 | ||
75 | ||
76 | return returnThis; //return the (possibly altered) bool | |
77 | } | |
78 | ||
79 | /** onPlayer wouldn't work for me ;S **/ | |
80 | void realOnPlayer(int pID) { | |
81 | if (jjGameTicks % checkCampInterval == 0) { //(thanks Artem/Foly) | |
82 | for (uint i=0; i < campAreas;i++) { //loop through all camp areas | |
83 | //^uint to avoid warning "Signed/Unsigned mismatch" | |
84 | array<bool> isCamping = isInCampArea(pID, i); //check player and area, store result | |
85 | if (isCamping[0]) { //is current player in camparea #1? | |
86 | jjPlayers[pID].showText("You are camping " + campAreaName[i]); //display text (looks stupid if | |
87 | if (isCamping[1]) { //has current player been there for too long? | |
88 | ||
89 | /** WHAT SHOULD HAPPEN IF THE PLAYER CAMPS FOR TOO LONG??? **/ | |
90 | jjChat("I camped for too long " + campAreaName[i] + ". Now I die :c"); | |
91 | jjPlayers[pID].kill(); //kill the player | |
92 | campTime[i] = 0; //reset timer | |
93 | /** ^-^ **/ | |
94 | ||
95 | } | |
96 | } | |
97 | } | |
98 | } | |
99 | } | |
100 | void onMain() { | |
101 | /** emulating onPlayer **/ | |
102 | for (uint i=0; i < 32;i++) { | |
103 | if ((jjPlayers[i].isActive)&&(jjPlayers[i].isLocal)) realOnPlayer(i); | |
104 | } | |
105 | /************************/ | |
106 | } |