Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Scripted by iMagic*
- //findplayer("Graal2007722").addweapon(this.name);
- this.image = "tb_imagic-portalgun-icon.png";
- function onActionServerSide(mode, bulletx, bullety, modeID, temp.pl, dir) {
- switch (mode) {
- case "SpawnPortal":
- this.portaloffset = {{-2,-1.5},{-0.7,-3.5},{-2,-3.5},{-3,-3.5}};
- switch (temp.modeID) {
- case "PortalGun_modeBlue":
- temp.obj = putnpc2(temp.bulletx + this.portaloffset[temp.dir][0], temp.bullety + this.portaloffset[temp.dir][1], "join(\"personal_graal2007722_portal1\");");
- temp.obj.owner = temp.pl;
- for (temp.npc: this.level.npcs) {
- if (temp.npc.isinclass("personal_graal2007722_portal1")) {
- if (!(temp.npc.x == temp.bulletx && temp.npc.y == temp.bullety)) {
- temp.npc.destroy();
- }
- }
- }
- break;
- case "PortalGun_modeOrange":
- temp.obj = putnpc2(temp.bulletx + this.portaloffset[temp.dir][0], temp.bullety + this.portaloffset[temp.dir][1], "join(\"personal_graal2007722_portal2\");");
- temp.obj.owner = temp.pl;
- for (temp.npc: this.level.npcs) {
- if (temp.npc.isinclass("personal_graal2007722_portal2")) {
- if (!(temp.npc.x == temp.bulletx && temp.npc.y == temp.bullety)) {
- temp.npc.destroy();
- }
- }
- }
- break;
- }
- break;
- case "destroy":
- for (temp.npc: this.level.npcs) {
- if (temp.npc.isinclass("personal_graal2007722_portal1") || temp.npc.isinclass("personal_graal2007722_portal2")) {
- temp.npc.destroy();
- }
- }
- break;
- }
- }
- //#CLIENTSIDE
- this.image = "tb_imagic-portalgun-icon.png";
- function onCreated() {
- // GANIS
- this.gun_blueidle = "tb_imagic-portalgun-blueidle";
- this.gun_bluewalk = "tb_imagic-portalgun-bluewalk";
- this.gun_bluefire = "tb_imagic-portalgun-bluefire";
- this.gun_orangeidle = "tb_imagic-portalgun-orangeidle";
- this.gun_orangewalk = "tb_imagic-portalgun-orangewalk";
- this.gun_orangefire = "tb_imagic-portalgun-orangefire";
- this.gun_transition1 = "tb_imagic-portalgun-transition1";
- this.gun_transition2 = "tb_imagic-portalgun-transition2";
- // STATS
- this.gun_firerate = 0.8;
- this.gun_freeze = 0.2;
- this.gun_bulletpos = {{-0.35,-2}, {-1.5,1}, {1.2,2.5}, {2,0.8}};
- }
- function onKeyPressed(code, key) {
- if (player.weapon == this.name) {
- if (key == "2") {
- if (!this.isGunEquipped) {
- this.isGunEquipped = true;
- this.is_blue = true;
- player.chat = "*Portal Gun Equipped*";
- player.ani = "tb_imagic-portalgun-blueidle";
- replaceani("idle", this.gun_blueidle);
- replaceani("walk", this.gun_bluewalk);
- freezeplayer(0.2);
- setTimer(0.5);
- } else {
- this.isGunEquipped = false;
- this.is_blue = NULL;
- player.ani = "idle";
- player.chat = "Unequipped";
- replaceani("walk", "walk");
- replaceani("idle", "idle");
- freezeplayer(0.2);
- }
- }
- if (this.isGunEquipped) {
- if (key == "x") {
- player.chat = "All portals have been destroyed";
- triggerserver("gui", this.name, "destroy");
- }
- if (key == "d") {
- if (!this.shooting) {
- if (this.is_blue) {
- this.shooting = true;
- player.ani = this.gun_bluefire;
- temp.angle = getangle(vecx(player.dir), vecy(player.dir));
- modeID = "PortalGun_modeBlue";
- setshootparams(modeID, player.account, player.dir);
- shoot(player.x + this.gun_bulletpos[player.dir][0], player.y + this.gun_bulletpos[player.dir][1], player.z, temp.angle, 0, 0, "tb_imagic-portalgun-bulletblue", "");
- freezeplayer(this.gun_freeze);
- blue_port_exists = true;
- scheduleEvent(0.25, "onCheckMode", "");
- setTimer(this.gun_firerate);
- } else {
- this.shooting = true;
- player.ani = this.gun_orangefire;
- temp.angle = getangle(vecx(player.dir), vecy(player.dir));
- modeID = "PortalGun_modeOrange";
- setshootparams(modeID, player.account, player.dir);
- shoot(player.x + this.gun_bulletpos[player.dir][0], player.y + this.gun_bulletpos[player.dir][1], player.z, temp.angle, 0, 0, "tb_imagic-portalgun-bulletorange", "");
- this.join("personal_graal2007722_projectiles");
- freezeplayer(this.gun_freeze);
- orange_port_exists = true;
- scheduleEvent(0.25, "onCheckMode", "");
- setTimer(this.gun_firerate);
- }
- }
- }
- if (key == "f") {
- onCheckMode();
- }
- }
- }
- }
- function onActionProjectile2(temp.x, temp.y, modeID, temp.pl, player.dir) {
- if (player.weapon == this.name) {
- temp.bulletx = params[0];
- temp.bullety = params[1];
- temp.modeID = params[2];
- temp.pl = params[3];
- pl.dir = params[4];
- triggerserver("gui", this.name, "SpawnPortal", bulletx, bullety, modeID, temp.pl, pl.dir);
- }
- }
- function onCheckMode() {
- if (this.is_blue) {
- player.ani = this.gun_transition1;
- replaceani("idle", this.gun_orangeidle);
- replaceani("walk", this.gun_orangewalk);
- this.is_blue = false;
- } else {
- player.ani = this.gun_transition2;
- replaceani("idle", this.gun_blueidle);
- replaceani("walk", this.gun_bluewalk);
- this.is_blue = true;
- }
- }
- function onTimeOut() {
- this.shooting = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment