// NPC made by Nalin /* if ((playerenters || created)) { toweapons -Rha_Swim_af15_underwater; hide; timeout=0.05; } if ((created || playerenters) && isweapon) { // { jump, increment, max } this.gravity_ground={1.0,0.20,0}; this.gravity_water={0.70,0.05,0.55}; this.respawn_zones={6.5, 29.5, 32, 9.5, 57.5, 29.5, 43.5, 50.5, 7.5, 50.5}; this.no_swim = 0; setstring this.levels,o_rha_af15_underwater.nw; } function FireWeapon() { //shootfireball playerdir; this.timer=0.5; callweapon selectedweapon,2dweaponfired; } join rha_2d; */ if ((created || playerenters) && isweapon) { setarray this.keys,15; this.zone={-1,-1}; // 0 - ground, 1 - water this.block_a=1; if (playerdir in {0, 2}) playerdir+=1; timeout=0.05; } if (timeout && isweapon) { if (this.timer>0) this.timer-=0.05; else this.timer=0; if (lindexof(#L,this.levels) < 0 && isweapon) { playerhearts=playerfullhearts; enabledefmovement; setani idle,; destroy; } disabledefmovement; if (this.playerdead == 0) { GetPlayerLocation(); if (!2dfreeze) CheckForKeyPress(); else this.move=0; CheckForGround(); MovePlayer(); timeout=0.05; } else { this.newloc = int(random(0,arraylen(this.respawn_zones)/2)); playerx=this.respawn_zones[this.newloc]; playery=this.respawn_zones[this.newloc+1]; timeout=2; this.playerdead=0; } } if (playerhurt) { timeout=1; } if (playerdies) { setani dead,; this.playerdead=1; timeout=0.05; } function GetPlayerLocation() { this.zone[1] = this.zone[0]; if ( this.no_swim == 0 ) { if ( onwater(playerx+1.5,playery+2) && onwater(playerx+1.5,playery+1) ) this.zone[0]=1; else this.zone[0]=0; if ( this.zone[0] == 1 && this.zone[1] == 0 ) { putleaps 5,playerx+0.5,playery; setani rha_swim_2d,; } } else this.zone[0] = 0; } function CheckForKeyPress() { for (this.i=0; this.i=2) ? 2 : 1; else this.keys[this.i] = (this.keys[this.i]>0) ? -1 : 0; } // Make sure A isn't being held when your start. if ( this.block_a == 1 && this.keys[6] < 1 ) this.block_a = 0; if (!strequals(#m,dead)) { if (strequals(#m,sword) && 2donGround) this.move=0; if (!strequals(#m,sword)) { this.move=0; if (this.keys[1] > 0) { this.move=-0.5; playerdir=1; set this.keywalk; } if (this.keys[3] > 0) { this.move=0.5; playerdir=3; set this.keywalk; } if (this.keys[4] == 1 && this.keys[5] < 1 && this.zone[0]==0 && this.timer==0) FireWeapon(); if (this.keys[6] > 0 && this.block_a == 0 && ((2donGround && this.gravity==0) || (this.zone[0]==1 && this.keys[6] == 1))) { if (this.zone[0] == 0) { this.gravity=-this.gravity_ground[0]; setani bravo_gravjump,; } else { this.gravity=-this.gravity_water[0]; setani rha_swim_2d,; } set this.jump; unset 2donGround; } } if (this.keys[5] == 1 && this.zone[0] == 0) { setani sword,; hitobjects 1,playerx+1.5+(vecx(playerdir)*2),playery+2+(vecy(playerdir)*2); } } } function CheckForGround() { if (onwall(playerx+0.5,playery+3) || onwall(playerx+1.5,playery+3) || onwall(playerx+2.4,playery+3)) set 2donGround; else unset 2donGround; } function MovePlayer() { this.py = playery; this.px = playerx; this.g = this.gravity; this.m = this.move; this.xmod = (this.move < 0 ? 0.5 : 2.5); this.ymod = (this.gravity < 0 ? 0 : 3); if (!strequals(#m,sword)) { if (this.move != 0 && 2donGround && playerfreezetime == -1) setani walk,; if (this.move == 0 && 2donGround && !2dfreeze) setani idle,; if (!2donGround && this.zone[0] == 0 && !2dfreeze) setani bravo_gravjump,; } if (!2donGround && this.zone[0] == 1 && !strequals(#m,rha_swim_2d)) setani rha_swim_2d,; while (this.g != 0) { if (onwall(playerx+0.5, this.py+this.ymod+(abs(this.g) >= 1 ? (this.g<0?-1:1) : this.g)) || onwall(playerx+1.5, this.py+this.ymod+(abs(this.g) >= 1 ? (this.g<0?-1:1) : this.g)) || onwall(playerx+2.4, this.py+this.ymod+(abs(this.g) >= 1 ? (this.g<0?-1:1) : this.g))) { if (this.gravity >= 0 && !2donGround) this.py+=1; this.py=int(this.py); this.g=0; if (this.gravity > 0) { set 2donGround; unset this.jump; } this.gravity = 0; } else { this.py+=(abs(this.g) >= 1 ? (this.g < 0 ? -1 : 1) : this.g); this.g-=(abs(this.g) >= 1 ? (this.g < 0 ? -1 : 1) : this.g); } } playery = this.py; while (this.m != 0) { if (onwall(playerx+this.xmod+(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m), playery+1) || onwall(playerx+this.xmod+(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m), playery+2) || (2donGround ? false : onwall(playerx+this.xmod+(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m), playery+3))) { if (!onwall(playerx+this.xmod+(vecx(playerdir)*0.1), playery+1) && onwall(playerx+this.xmod+(vecx(playerdir)*0.1), playery+2) && 2donGround) { this.px+=(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m); this.m-=(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m); this.py -= abs((playerx + this.move) - playerx); if (this.py < (playery - 1)) this.py = playery - 1; playery = this.py; } else { this.px=int(this.px)+0.5; this.m=0; } } else { if (2donGround) {this.py = int(playery); playery = int(playery); } this.px+=(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m); this.m-=(abs(this.m) >= 1 ? (this.m < 0 ? -1 : 1) : this.m); } } playerx = this.px; if (!2donGround) { if (this.zone[0] == 0) { this.gravity+=this.gravity_ground[1] * ((keydown(6) == false && this.gravity<0) ? 3 : 1); if (this.gravity>this.gravity_ground[2] && this.gravity_ground[2] != 0) this.gravity=this.gravity_ground[2]; } else { this.gravity+=this.gravity_water[1]; if (this.gravity>this.gravity_water[2] && this.gravity_water[2] != 0) this.gravity=this.gravity_water[2]; } } }