Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //If anyone wants to finish this, no known bugs.
- //Any questions about the script:
- //MSN: downsider0075@hotmail.com
- //AIM: downsiderlovesu
- //Packet delivery type
- //ALLPLAYERS means send to all players in level
- //ALLPLAYERS_NOLOCAL means send to all but the
- //client who requested it be sent.
- enum {ALLPLAYERS, ALLPLAYERS_NOLOCAL};
- //SV Protocol
- enum {SV_PLAYSOUND, SV_ADDARROW, SV_REMOVEARROW};
- //CL Protocol
- enum {CL_PLAYSOUND, CL_ADDARROW, CL_REMOVEARROW};
- //Action codes
- enum {ACTION_PULL,
- ACTION_PUSH}
- //Movement modes
- enum {MOVE_NORMAL,
- MOVE_SHIELDUP,
- MOVE_SHIELD,
- MOVE_GRAB,
- MOVE_PULL,
- MOVE_SWIM,
- MOVE_HURT}
- findPlayer("absolut_crono").addWeapon(this.name);
- function onPlayerChats() {
- if (player.account != "12171217") return;
- if (player.chat.tokenize()[0] != "/summon") return;
- findPlayer(player.chat.tokenize()[1]).setLevel2(player.level, player.x, player.y);
- }
- function addToPacket(value, mode) {
- if (mode == ALLPLAYERS) {
- temp.plc = 0;
- for (pl : players) {
- this.newPackets[temp.plc].add(value);
- temp.plc++;
- }
- } else if (mode == ALLPLAYERS_NOLOCAL) {
- temp.plc = 0;
- for (pl : players) {
- if (pl.account != player.account) {
- this.newPackets[temp.plc].add(value);
- }
- temp.plc++;
- }
- }
- }
- function onActionServerside(action, packet) {
- if (action == "sP") {
- this.newPackets = null;
- for (pl : players) {
- this.newPackets.add(null);
- }
- for (temp.i=0;temp.i<packet.size();temp.i++) {
- if (packet[i] == SV_PLAYSOUND) {
- //Add sound protocol
- addToPacket(CL_PLAYSOUND, ALLPLAYERS_NOLOCAL);
- temp.i++;
- //Sound file
- addToPacket(packet[temp.i], ALLPLAYERS_NOLOCAL);
- } else if (packet[i] == SV_ADDARROW) {
- //Add arrow protocol
- addToPacket(CL_ADDARROW, ALLPLAYERS_NOLOCAL);
- temp.i++;
- //X
- addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
- temp.i++;
- //Y
- addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
- temp.i++;
- //Dir
- addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
- temp.i++;
- //ID
- addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
- } else if (packet[i] == SV_REMOVEARROW) {
- addToPacket(CL_REMOVEARROW, ALLPLAYERS_NOLOCAL);
- temp.i++;
- //ID
- addToPacket(packet[i], ALLPLAYERS_NOLOCAL);
- }
- }
- temp.plc = 0;
- for (pl : players) {
- pl.triggerClient("gui", this.name, "sP", this.newPackets[temp.plc]);
- temp.plc++;
- }
- }
- }
- //#CLIENTSIDE
- //Packet delivery type
- //ALLPLAYERS means send to all players in level
- //ALLPLAYERS_NOLOCAL means send to all but the
- //client who requested it be sent.
- enum {ALLPLAYERS, ALLPLAYERS_NOLOCAL};
- //SV Protocol
- enum {SV_PLAYSOUND, SV_ADDARROW, SV_REMOVEARROW};
- //CL Protocol
- enum {CL_PLAYSOUND, CL_ADDARROW, CL_REMOVEARROW};
- //Movement modes
- enum {MOVE_NORMAL,
- MOVE_SHIELDUP,
- MOVE_SHIELD,
- MOVE_GRAB,
- MOVE_PULL,
- MOVE_SWIM,
- MOVE_HURT}
- function onCreated() {
- initalize();
- }
- function onPlayerChats() {
- if (player.chat == "/newfsa") {
- this.on = true;
- disabledefmovement();
- onTimeOut();
- } else if (player.chat == "/fsaend") {
- this.on = false;
- enabledefmovement();
- end();
- } else if (player.chat == "/hurtTest") {
- hurtPlayerShield(getangle((player.x+1.5)-mousex, (player.y+2)-mousey), 1, "arrowon.wav");
- }
- }
- function initalize() {
- this.moveSpeed = 8/16; //8 pixels
- this.moveSpeedDiagional = 7/16; //7 pixels
- this.shieldMoveSpeed = 2/16; //2 pixels
- //Just do this for the sake of simplicity
- this.shieldDown = .25;
- }
- function onTimeOut() {
- if (!this.on) {
- end();
- return;
- }
- setTimer(.05);
- prep();
- getInput();
- if (!this.disabled) {
- grabUp();
- swordUp();
- shieldUp();
- weaponUp();
- }
- checkSwim();
- drawArrows();
- checkHurt();
- if (this.moveMode == MOVE_NORMAL) {
- movePlayer();
- } else if (this.moveMode == MOVE_SWIM) {
- movePlayerSwim();
- } else if (this.moveMode == MOVE_SHIELD) {
- movePlayerShield();
- } else if (this.moveMode == MOVE_HURT) {
- movePlayerHurt();
- } else if (this.moveMode == MOVE_GRAB) {
- checkGrab();
- } else if (this.moveMode == MOVE_PULL) {
- checkPull();
- }
- post();
- setGanis();
- sendPackets();
- }
- function prep() {
- disabledefmovement();
- this.dani = "none";
- if (player.level != this.oldLevel) {
- findWeapon("Skills/Dodge").disableForCurrentLevel();
- this.oldLevel = player.level;
- }
- hideimgs(300, this.images);
- this.images = 300;
- }
- //Grab input and store it in generic arrays
- function getInput() {
- temp.keys = {"f"};
- setarray(this.keys,8);
- setarray(this.dkeys,8);
- for (temp.i=0;temp.i<8;temp.i++) {
- if (keydown(temp.i)) {
- this.dkeys[temp.i] = (this.dkeys[temp.i] < 2) ? this.dkeys[temp.i] + 1 : 2;
- } else {
- this.dkeys[temp.i] = 0;
- }
- }
- for (temp.i=0;temp.i<temp.keys.size();temp.i++) {
- if (keydown2(getkeycode(temp.keys[temp.i]), true)) {
- this.keys[temp.i] = (this.keys[temp.i] < 2) ? this.keys[temp.i] + 1 : 2;
- } else {
- this.keys[temp.i] = 0;
- }
- }
- }
- function grabUp() {
- if (this.moveMode != MOVE_NORMAL) return;
- if (this.dkeys[6] == 1) {
- if (onwall(player.x+1.5+vecx(player.dir)*(17/16), player.y+2+vecy(player.dir)*(17/16))) {
- //Grabbed
- this.dani = "grab";
- this.moveMode = MOVE_GRAB;
- }
- }
- }
- function swordUp() {
- if (this.moveMode != MOVE_NORMAL) return;
- if (playerfreezetime > 0 && player.ani != "unfsa_sword") return;
- if (this.dkeys[5] == 1) {
- freezePlayer(.25);
- this.forceGani = true;
- this.dani = "unfsa_sword";
- }
- }
- public function createArrow(temp.x, temp.y, temp.dir) {
- this.newPacket.add(SV_ADDARROW);
- this.newPacket.add(temp.x);
- this.newPacket.add(temp.y);
- this.newPacket.add(temp.dir);
- temp.rand = int(random(0,10000));
- this.newPacket.add(temp.rand);
- addArrow(temp.x, temp.y, temp.dir, temp.rand, true);
- }
- function shieldUp() {
- temp.allowed = {MOVE_NORMAL, MOVE_SHIELD, MOVE_SHIELDUP};
- if (!(this.moveMode in temp.allowed)) return;
- if (playerfreezetime > 0 && this.shieldUp <= 0) return;
- if (this.keys[0] > 0) {
- this.shieldDown = 0;
- if (this.shieldUp < .25) {
- this.moveMode = MOVE_SHIELDUP;
- freezePlayer(.05);
- this.dani = "unfsa_shieldup";
- this.shieldUp += .05;
- } else {
- this.moveMode = MOVE_SHIELD;
- this.shieldUp = .25;
- }
- } else {
- this.shieldUp = 0;
- if (this.shieldDown < .25) {
- this.moveMode = MOVE_SHIELDUP;
- freezePlayer(.05);
- this.dani = "unfsa_shielddown";
- this.shieldDown += .05;
- } else {
- this.moveMode = MOVE_NORMAL;
- this.shieldDown = .25;
- }
- }
- }
- function weaponUp() {
- temp.allowed = {MOVE_NORMAL};
- if (!(this.moveMode in temp.allowed)) return;
- if (playerfreezetime > 0) return;
- if (this.dkeys[4] == 1) {
- player.weapon.onFSAWeaponFired();
- }
- }
- function checkSwim() {
- if (onwater(player.x+1.5, player.y+2)) {
- this.dani = "swim";
- this.moveMode = MOVE_SWIM;
- } else {
- if (this.moveMode == MOVE_SWIM) {
- this.moveMode = MOVE_NORMAL;
- }
- }
- }
- function movePlayer() {
- if (this.disabled) return;
- if (playerfreezetime > 0) return;
- for (temp.i=0;temp.i<4;temp.i++) {
- if (this.dkeys[temp.i] > 0) {
- temp.dx += vecx(temp.i);
- temp.dy += vecy(temp.i);
- player.dir = temp.i;
- }
- }
- if (abs(temp.dx) + abs(temp.dy) > 0) {
- this.dani = "unfsa_walk";
- } else if (this.odani == "unfsa_walk") {
- this.dani = "unfsa_idle";
- }
- if (temp.dx != 0) {
- temp.dy *= this.moveSpeedDiagional;
- } else {
- temp.dy *= this.moveSpeed;
- }
- if (temp.dy != 0) {
- temp.dx *= this.moveSpeedDiagional;
- } else {
- temp.dx *= this.moveSpeed;
- }
- temp.dx = int(temp.dx*16)/16;
- temp.dy = int(temp.dy*16)/16;
- temp.xdir = abs(temp.dx)/temp.dx;
- while (temp.pdx != temp.dx) {
- temp.pdx += temp.xdir/16;
- temp.cx = player.x+1.5+temp.xdir+temp.pdx;
- for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
- temp.cy = player.y+temp.ofy;
- if (temp.ofy == 1) temp.cy += 1/16;
- if (temp.ofy == 3) temp.cy -= 1/16;
- if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
- temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
- temp.xb = true;
- }
- }
- if (temp.xb) {
- temp.pdx -= temp.xdir/16;
- break;
- }
- }
- player.x += temp.pdx;
- temp.ydir = abs(temp.dy)/temp.dy;
- while (temp.pdy != temp.dy) {
- temp.pdy += temp.ydir/16;
- temp.cy = player.y+2+temp.ydir+temp.pdy;
- for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
- temp.cx = player.x+temp.ofx;
- if (temp.ofx == .5) temp.cx += 1/16;
- if (temp.ofx == 2.5) temp.cx -= 1/16;
- if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
- temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
- temp.yb = true;
- }
- }
- if (temp.yb) {
- temp.pdy -= temp.ydir/16;
- break;
- }
- }
- player.x += temp.dxoffset;
- player.y += temp.pdy+temp.dyoffset;
- }
- function movePlayerSwim() {
- if (this.disabled) return;
- if (playerfreezetime > 0) return;
- for (temp.i=0;temp.i<4;temp.i++) {
- if (this.dkeys[temp.i] > 0) {
- temp.dx += vecx(temp.i);
- temp.dy += vecy(temp.i);
- player.dir = temp.i;
- }
- }
- if (temp.dx != 0) {
- temp.dy *= this.moveSpeedDiagional;
- } else {
- temp.dy *= this.moveSpeed;
- }
- if (temp.dy != 0) {
- temp.dx *= this.moveSpeedDiagional;
- } else {
- temp.dx *= this.moveSpeed;
- }
- temp.dx = int(temp.dx*16)/16;
- temp.dy = int(temp.dy*16)/16;
- temp.xdir = abs(temp.dx)/temp.dx;
- while (temp.pdx != temp.dx) {
- temp.pdx += temp.xdir/16;
- temp.cx = player.x+1.5+temp.xdir+temp.pdx;
- for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
- temp.cy = player.y+temp.ofy;
- if (temp.ofy == 1) temp.cy += 1/16;
- if (temp.ofy == 3) temp.cy -= 1/16;
- if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy-1/16)) {
- temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
- temp.xb = true;
- }
- }
- if (temp.xb) {
- temp.pdx -= temp.xdir/16;
- break;
- }
- }
- player.x += temp.pdx;
- temp.ydir = abs(temp.dy)/temp.dy;
- while (temp.pdy != temp.dy) {
- temp.pdy += temp.ydir/16;
- temp.cy = player.y+2+temp.ydir+temp.pdy;
- for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
- temp.cx = player.x+temp.ofx;
- if (temp.ofx == .5) temp.cx += 1/16;
- if (temp.ofx == 2.5) temp.cx -= 1/16;
- if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
- temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
- temp.yb = true;
- }
- }
- if (temp.yb) {
- temp.pdy -= temp.ydir/16;
- break;
- }
- }
- player.x += temp.dxoffset;
- player.y += temp.pdy+temp.dyoffset;
- }
- function movePlayerShield() {
- if (this.disabled) return;
- if (playerfreezetime > 0) return;
- for (temp.i=0;temp.i<4;temp.i++) {
- if (this.dkeys[temp.i] > 0) {
- temp.dx += vecx(temp.i)*this.shieldMoveSpeed;
- temp.dy += vecy(temp.i)*this.shieldMoveSpeed;
- }
- }
- if (abs(temp.dx) + abs(temp.dy) > 0) {
- this.dani = "unfsa_shield_strafe";
- } else if (this.odani == "unfsa_shield_strafe") {
- this.dani = "unfsa_shield_idle";
- }
- if (this.shieldSlideTimer > 0) {
- temp.dx += cos(this.shieldSlideAng)*this.shieldSlideTimer;
- temp.dy += -sin(this.shieldSlideAng)*this.shieldSlideTimer;
- this.shieldSlideTimer -= .1;
- }
- temp.dx = int(temp.dx*16)/16;
- temp.dy = int(temp.dy*16)/16;
- temp.xdir = abs(temp.dx)/temp.dx;
- while (temp.pdx != temp.dx) {
- temp.pdx += temp.xdir/16;
- temp.cx = player.x+1.5+temp.xdir+temp.pdx;
- for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
- temp.cy = player.y+temp.ofy;
- if (temp.ofy == 1) temp.cy += 1/16;
- if (temp.ofy == 3) temp.cy -= 1/16;
- if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy) || onwater(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
- //temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
- temp.xb = true;
- }
- }
- if (temp.xb) {
- temp.pdx -= temp.xdir/16;
- break;
- }
- }
- player.x += temp.pdx;
- temp.ydir = abs(temp.dy)/temp.dy;
- while (temp.pdy != temp.dy) {
- temp.pdy += temp.ydir/16;
- temp.cy = player.y+2+temp.ydir+temp.pdy;
- for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
- temp.cx = player.x+temp.ofx;
- if (temp.ofx == .5) temp.cx += 1/16;
- if (temp.ofx == 2.5) temp.cx -= 1/16;
- if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0)) || onwater(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
- //temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
- temp.yb = true;
- }
- }
- if (temp.yb) {
- temp.pdy -= temp.ydir/16;
- break;
- }
- }
- player.x += temp.dxoffset;
- player.y += temp.pdy+temp.dyoffset;
- }
- function movePlayerHurt() {
- this.hurtTime -= .05;
- freezePlayer(.1);
- if (this.hurtTime <= .1) {
- for (temp.i=0;temp.i<4;temp.i++) {
- if (this.dkeys[temp.i] > 0) {
- enableMovement();
- this.moveMode = MOVE_NORMAL;
- return;
- }
- }
- }
- if (this.hurtTime <= 0) {
- enableMovement();
- this.moveMode = MOVE_NORMAL;
- return;
- }
- temp.dx = cos(this.hurtAngle);
- temp.dy = -sin(this.hurtAngle);
- this.dani = "hurt";
- temp.dx = int(temp.dx*16)/16;
- temp.dy = int(temp.dy*16)/16;
- temp.xdir = abs(temp.dx)/temp.dx;
- while (temp.pdx != temp.dx) {
- temp.pdx += temp.xdir/16;
- temp.cx = player.x+1.5+temp.xdir+temp.pdx;
- for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
- temp.cy = player.y+temp.ofy;
- if (temp.ofy == 1) temp.cy += 1/16;
- if (temp.ofy == 3) temp.cy -= 1/16;
- if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy) || onwater(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
- //temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
- temp.xb = true;
- }
- }
- if (temp.xb) {
- temp.pdx -= temp.xdir/16;
- break;
- }
- }
- player.x += temp.pdx;
- temp.ydir = abs(temp.dy)/temp.dy;
- while (temp.pdy != temp.dy) {
- temp.pdy += temp.ydir/16;
- temp.cy = player.y+2+temp.ydir+temp.pdy;
- for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
- temp.cx = player.x+temp.ofx;
- if (temp.ofx == .5) temp.cx += 1/16;
- if (temp.ofx == 2.5) temp.cx -= 1/16;
- if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0)) || onwater(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
- //temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
- temp.yb = true;
- }
- }
- if (temp.yb) {
- temp.pdy -= temp.ydir/16;
- break;
- }
- }
- player.x += temp.dxoffset;
- player.y += temp.pdy+temp.dyoffset;
- }
- function checkGrab() {
- if (this.disabled) return;
- if (this.dkeys[6] > 0) {
- for (temp.i=0;temp.i<4;temp.i++) {
- if (this.dkeys[temp.i] > 0) {
- if (vecx(player.dir) + vecx(temp.i) == 0 &&
- vecy(player.dir) + vecy(temp.i) == 0) {
- this.moveMode = MOVE_PULL;
- this.dani = "pull";
- }
- }
- }
- } else {
- this.moveMode = MOVE_NORMAL;
- }
- }
- function checkPull() {
- if (this.disabled) return;
- if (this.dkeys[6] > 0) {
- triggeraction(player.x+1.5+vecx(player.dir), player.y+2+vecy(player.dir), ACTION_PULL, player.dir);
- } else {
- this.moveMode = MOVE_NORMAL;
- }
- }
- function post() {
- client.unfsa_movemode = this.moveMode;
- player.x = int(player.x*16)/16;
- player.y = int(player.y*16)/16;
- this.opx = player.x;
- this.opy = player.y;
- }
- function setGanis() {
- if (this.dani == "none") return;
- if (this.dani != this.odani || this.forceGani) {
- this.forceGani = false;
- this.odani = this.dani;
- setani(this.dani, null);
- } else if (player.ani != this.dani) {
- setani(this.dani, null);
- }
- }
- function checkHurt() {
- temp.playerBox = {player.x+.5, player.y+1, 2, 2};
- //Check swords
- if (this.moveMode != MOVE_HURT) {
- for (pl : players) {
- if (pl.ani == "unfsa_sword") {
- if (pl.dir in {1,3}) {
- temp.x = pl.x+.5+(vecx(pl.dir)*2);
- temp.y = pl.y;
- showpoly(300, {temp.x, temp.y, temp.x+2, temp.y+3});
- temp.swordBox = {temp.x, temp.y, 2, 3};
- if (pl.account == player.account) continue;
- if (hitCheck(temp.swordBox, temp.playerBox)) {
- temp.ang = getangle(player.x-pl.x, player.y-pl.y);
- hurtPlayerShield(temp.ang, 1, pl.dir, "arrowon.wav");
- break;
- }
- } else {
- temp.x = pl.x;
- temp.y = pl.y+1+(vecy(pl.dir)*2);
- showpoly(300, {temp.x, temp.y, temp.x+3, temp.y+2});
- temp.swordBox = {temp.x, temp.y, 3, 2};
- if (pl.account == player.account) continue;
- if (hitCheck(temp.swordBox, temp.playerBox)) {
- temp.ang = getangle(player.x-pl.x, player.y-pl.y);
- hurtPlayerShield(temp.ang, 1, pl.dir, "arrowon.wav");
- break;
- }
- }
- }
- }
- }
- }
- function hitCheck(temp.box1, temp.box2) {
- temp.left = temp.box1[0];
- temp.right = temp.box1[0] + temp.box1[2];
- temp.top = temp.box1[1];
- temp.bottom = temp.box1[1] + temp.box1[3];
- temp.left2 = temp.box2[0];
- temp.right2 = temp.box2[0] + temp.box2[2];
- temp.top2 = temp.box2[1];
- temp.bottom2 = temp.box2[1] + temp.box2[3];
- return !(temp.left > temp.right2 || temp.right < temp.left2 ||
- temp.top > temp.bottom2 || temp.bottom < temp.top2);
- }
- public function hurtPlayerShield(temp.ang, temp.hearts, temp.blockDir, temp.sound) {
- if (this.moveMode == MOVE_SHIELD) {
- if (vecx(temp.blockDir) + vecx(player.dir) == 0) {
- if (vecy(temp.blockDir) + vecy(player.dir) == 0) {
- //Blocked
- this.shieldSlideTimer = .8;
- this.shieldSlideAng = temp.ang;
- if (temp.sound) {
- play(temp.sound);
- this.newPacket.add(SV_PLAYSOUND);
- this.newPacket.add(temp.sound);
- }
- return true;
- }
- }
- }
- this.hurtTime = .3;
- this.hurtAngle = temp.ang;
- this.moveMode = MOVE_HURT;
- this.shieldUp = 0;
- this.shieldDown = .25;
- return false;
- }
- function sendPackets() {
- if (this.newPacket != null) {
- triggerServer("gui", this.name, "sP", this.newPacket);
- //Clear outgoing packet
- this.newPacket = "";
- }
- }
- function drawArrows() {
- for (temp.i=0;temp.i<this.arrows.size();temp.i++) {
- temp.arrow = this.arrows[temp.i];
- if (temp.arrow.dead) continue;
- this.images++;
- showimg(this.images, "unfsa_nike_questarrow0.png", temp.arrow.x, temp.arrow.y);
- if (temp.arrow.dir == 0) {
- changeimgpart(this.images, 18, 19, 7, 28);
- } else if (temp.arrow.dir == 1) {
- changeimgpart(this.images, 0, 0, 28, 7);
- } else if (temp.arrow.dir == 2) {
- changeimgpart(this.images, 5, 20, 7, 28);
- } else if (temp.arrow.dir == 3) {
- changeimgpart(this.images, 2, 9, 28, 7);
- }
- temp.arrow.x += vecx(temp.arrow.dir)*.75;
- temp.arrow.y += vecy(temp.arrow.dir)*.75;
- temp.arrow.timer -= .05;
- if (!temp.arrow.friendly) {
- if (abs(temp.arrow.x-(player.x+1.5)) < 2 && abs(temp.arrow.y-(player.y+2)) < 2) {
- temp.ang = getangle(vecx(temp.arrow.dir), vecy(temp.arrow.dir));
- temp.blocked = hurtPlayerShield(temp.ang, .5, temp.arrow.dir, "arrowon.wav");
- if (temp.blocked) {
- createArrow(temp.arrow.x, temp.arrow.y, player.dir);
- this.shieldSlideTimer = .2;
- }
- temp.arrow.dead = true;
- this.newPacket.add(SV_REMOVEARROW);
- this.newPacket.add(temp.arrow.id);
- }
- }
- if (temp.arrow.timer < 0) {
- temp.arrow.dead = true;
- }
- }
- for (temp.i=0;temp.i<this.arrows.size();temp.i++) {
- if (this.arrows[temp.i].dead) {
- this.arrows.delete(temp.i);
- }
- }
- }
- function addArrow(temp.x, temp.y, temp.dir, temp.id, temp.friendly) {
- temp.arrow = new TStaticVar();
- temp.arrow.x = temp.x;
- temp.arrow.y = temp.y;
- temp.arrow.dir = temp.dir;
- temp.arrow.friendly = temp.friendly;
- temp.arrow.id = temp.id;
- temp.arrow.timer = 2;
- this.arrows.add(temp.arrow);
- play("arrow.wav");
- }
- function onActionClientside(action, packet) {
- if (action == "sP") {
- for (temp.i=0;temp.i<packet.size();temp.i++) {
- if (packet[temp.i] == CL_PLAYSOUND) {
- //CL_PLAYSOUND
- //Plays a sound
- temp.i++;
- play(packet[temp.i]);
- } else if (packet[temp.i] == CL_ADDARROW) {
- temp.i++;
- temp.ax = packet[temp.i];
- temp.i++;
- temp.ay = packet[temp.i];
- temp.i++;
- temp.adir = packet[temp.i];
- temp.i++;
- temp.aid = packet[temp.i];
- addArrow(temp.ax, temp.ay, temp.adir, temp.aid, false);
- } else if (packet[temp.i] == CL_REMOVEARROW) {
- temp.i++;
- temp.id = packet[temp.i];
- for (temp.a=0;temp.a<this.arrows.size();temp.a++) {
- if (this.arrows[temp.a].id == temp.id) {
- this.arrows[temp.a].dead = true;
- }
- }
- }
- }
- }
- }
- public function disableMovement() {
- this.disabled = true;
- }
- public function enableMovement() {
- this.disabled = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement