Thread: Npc Projectiles

Results 1 to 2 of 2
  1. #1 Npc Projectiles 
    Registered Member
    Grant_'s Avatar
    Join Date
    Aug 2014
    Posts
    495
    Thanks given
    96
    Thanks received
    109
    Rep Power
    136
    Hello Rune-Server, I am trying to get an npc to shoot a projectile and an x,y coordinate rather than a player. Unfortuantly there is a "lockon" parameter which tracks the player when the projectile is shot. I tried removing the parameter, but that only made the server crash. Here is the method:
    Code:
    public void createProjectile(final int x, final int y, final int offX, final int offY, final int angle,
    			final int speed, final int gfxMoving, final int startHeight, final int endHeight, final int lockon,
    			final int time) {
    		// synchronized(c) {
    		if (c.getOutStream() != null && c != null) {
    			c.getOutStream().createFrame(85);
    			c.getOutStream().writeByteC(y - c.getMapRegionY() * 8 - 2);
    			c.getOutStream().writeByteC(x - c.getMapRegionX() * 8 - 3);
    			c.getOutStream().createFrame(117);
    			c.getOutStream().writeByte(angle);
    			c.getOutStream().writeByte(offY);
    			c.getOutStream().writeByte(offX);
    			c.getOutStream().writeWord(lockon);
    			c.getOutStream().writeWord(gfxMoving);
    			c.getOutStream().writeByte(startHeight);
    			c.getOutStream().writeByte(endHeight);
    			c.getOutStream().writeWord(time);
    			c.getOutStream().writeWord(speed);
    			c.getOutStream().writeByte(16);
    			c.getOutStream().writeByte(64);
    			c.flushOutStream();
    		}
    		// }
    	}
    The current example for shooting a projectile at a player is
    Code:
    c.getPA().createPlayersProjectileZulrah(nX, nY, offX, offY, 50,
            							100,
            							NPCHandler.npcs[i].projectileId, 43, 31,
            							 -c.getId() -1,65);
    The -c.getId() - 1 being the lockon parameter. Is there a way i can replace this with another number for it to locate as the spot? Or just a way to remove the lockon altogether.

    Thanks - Grant
    Attached image
    Reply With Quote  
     

  2. #2  
    Registered Member
    Invision's Avatar
    Join Date
    Nov 2013
    Posts
    287
    Thanks given
    54
    Thanks received
    303
    Rep Power
    655
    It will help to use correctly refactored client as reference.
    What you call lockon, is index of the targeted NPC.

    Code:
    		if (opcode == 117) {
    			int sourcePos = buffer.readUByte();
    			int sourceX = localX + (sourcePos >> 4 & 7);
    			int sourceZ = localZ + (sourcePos & 7);
    			int destinationX = sourceX + buffer.readByte();
    			int destinationY = sourceZ + buffer.readByte();
    			int target = buffer.readShort();
    			int graphic = buffer.readUShort();
    			int sourceElevationOffset = buffer.readUByte() * 4;
    			int destinationElevation = buffer.readUByte() * 4;
    			int ticksToEnd = buffer.readUShort();
    			int ticksToStart = buffer.readUShort();
    			int elevationPitch = buffer.readUByte();
    			int leapScale = buffer.readUByte();
    			if (sourceX >= 0 && sourceZ >= 0 && sourceX < 104 && sourceZ < 104
    					&& destinationX >= 0 && destinationY >= 0
    					&& destinationX < 104 && destinationY < 104
    					&& graphic != 65535) {
    				sourceX = sourceX * 128 + 64;
    				sourceZ = sourceZ * 128 + 64;
    				destinationX = destinationX * 128 + 64;
    				destinationY = destinationY * 128 + 64;
    				Projectile projectile = new Projectile(sourceX, sourceZ,
    						getFloorDrawHeight(sourceX, sourceZ, plane)
    						- sourceElevationOffset, destinationElevation,
    						elevationPitch, ticksToStart + tick, ticksToEnd + tick,
    						leapScale, plane, target, graphic);
    				projectile.target(destinationX, destinationY,
    						getFloorDrawHeight(destinationX, destinationY, plane)
    						- destinationElevation, ticksToEnd + tick);
    				projectiles.pushBack(projectile);
    			}
    		}
    in the projectile process code we see:

    Code:
    			if (projectile.target > 0) {
    					Npc npc = npcs[projectile.target - 1];
    					if (npc != null && npc.sceneX >= 0 && npc.sceneX < 13312
    							&& npc.sceneZ >= 0 && npc.sceneZ < 13312) {
    						projectile
    						.target(npc.sceneX,
    								npc.sceneZ,
    								getFloorDrawHeight(npc.sceneX,
    										npc.sceneZ, projectile.plane)
    										- projectile.destinationElevation,
    										tick);
    					}
    				}
    				if (projectile.target < 0) {
    					int index = -projectile.target - 1;
    					Player player;
    					if (index == localPlayerIndex) {
    						player = localPlayer;
    					} else {
    						player = players[index];
    					}
    
    					if (player != null && player.sceneX >= 0
    							&& player.sceneX < 13312 && player.sceneZ >= 0
    							&& player.sceneZ < 13312) {
    						projectile
    						.target(player.sceneX,
    								player.sceneZ,
    								getFloorDrawHeight(player.sceneX,
    										player.sceneZ, projectile.plane)
    										- projectile.destinationElevation,
    										tick);
    					}
    				}
    so to remove the "lock on", try sending -1 in place of NPC index.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Clipped Player/Npcs/Projectiles Etc PI Base
    By CrazeNation in forum Buying
    Replies: 3
    Last Post: 01-09-2013, 05:24 AM
  2. npc projectiles.
    By Clx3 in forum Help
    Replies: 0
    Last Post: 11-23-2011, 10:19 PM
  3. Fight Cave Npcs - Projectile Ids and GFX
    By Azurite in forum Help
    Replies: 1
    Last Post: 05-21-2011, 10:06 PM
  4. Basic Npc projectiles
    By Kelvin in forum Tutorials
    Replies: 2
    Last Post: 08-12-2009, 11:32 PM
  5. NPC Projectiles
    By Note in forum Help
    Replies: 0
    Last Post: 07-20-2009, 12:49 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •