global trigger zone events

Version:

1.0

Added on:

24 Feb 2013 19:33

Tags:

Description:
this script makes all the local trigger zones global. you need to use event ID 255 instead of trigger zone event, but you can change it and use any event. JCS.ini parameters:
|ID:5|on:1|switch:1|hold:1
"hold" is a new parameter i added that will keep trigger enabled (if on is 1) while you are standing on that tile. it will do opposite if on is 0. everything else works the same way as with a normal trigger zone. this could be very useful in co-op levels.
  1. array<int> holder(33, 32);
  2. array<int> holdID(33, 32);
  3. array<int> svHoldID(33, 32);
  4. array<int> svHolder(33, 32);
  5. array<bool> locker(33, false);
  6. array<bool> svLocker(33, false);
  7. //"32" is a default value; it's not player 32 because that would be 31.
  8.  
  9. void onPlayer() {
  10.     for(int i=0;i<32;i++) {
  11.         if(jjEventGet(jjPlayers[i].xPos/32, jjPlayers[i].yPos/32) == 255) { //if you wish, you can change 255 here to any other event. use AREA::TRIGGERZONE or 246 for trigger zone event.
  12.             int triggerID = jjParameterGet(jjPlayers[i].xPos/32, jjPlayers[i].yPos/32, 0, 5);
  13.             int on = jjParameterGet(jjPlayers[i].xPos/32, jjPlayers[i].yPos/32, 5, 1);
  14.             int svitch = jjParameterGet(jjPlayers[i].xPos/32, jjPlayers[i].yPos/32, 6, 1);
  15.             // I used "svitch" instead of "switch" because "switch" would give me an error, because it already exists in angelscript not as a variable.
  16.             int hold = jjParameterGet(jjPlayers[i].xPos/32, jjPlayers[i].yPos/32, 7, 1);
  17.             if(hold == 1) {
  18.                 if(jjTriggers[triggerID] != (on == 1)) {
  19.                     if(locker[triggerID]) if(i != holder[triggerID]) return;
  20.                     if(!jjTriggers[triggerID]) {
  21.                         jjTriggers[triggerID] = true;
  22.                         if(!locker[triggerID]) {
  23.                             locker[triggerID] = true;
  24.                             holder[triggerID] = i;
  25.                             holdID[i] = triggerID;
  26.                         }
  27.                     }
  28.                 }
  29.             } else {
  30.                 if(svitch == 1) {
  31.                     if(!svLocker[triggerID]) {
  32.                         svLocker[triggerID] = true;
  33.                         bool oldState = jjTriggers[triggerID];
  34.                         jjTriggers[triggerID] = (true != oldState);
  35.                         svHolder[triggerID] = i;
  36.                         svHoldID[i] = triggerID;
  37.                     }
  38.                 } else {
  39.                     if(jjTriggers[triggerID] != (on == 1)) jjTriggers[triggerID] = (on == 1);
  40.                 }
  41.             }
  42.         } else {
  43.             for(int j=0;j<32;j++) {
  44.                 if(i == holder[holdID[j]] && holdID[j] != 32) {
  45.                     if(jjTriggers[holdID[j]]) jjTriggers[holdID[j]] = false;
  46.                     if(locker[holdID[j]]) locker[holdID[j]] = false;
  47.                     holder[holdID[j]] = 32; holdID[j] = 32;
  48.                 }
  49.             }
  50.             for(int k=0;k<32;k++) {
  51.                 if(svLocker[svHoldID[k]] && i == svHolder[svHoldID[k]] && svHolder[svHoldID[k]] != 32) {
  52.                     svLocker[svHoldID[k]] = false;
  53.                     svHolder[svHoldID[k]] = 32;
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }