View Single Post
  #3  
Old 05-25-2011, 12:55 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You might also want to move some of that code to functions. I.e:

PHP Code:
function sendTrigger(pl) {
  
triggeraction(pl.x+0.5pl.y+0.5"Damage"this.effectsplayer.account, {temp.damagetemp.criton}, temp.accuracy"Physical"100temp.armorpiercetemp.attackerlevelaxayazad); 
  if (
client.showhits){ 
    
triggerserver("gui"this.name"putnpc""testblock",pl.x+0.5pl.y+0.5); 
  }

Other functions may include:

PHP Code:
function inHittingRange(plmaxdist) {
  if (
pl == player) {
    return 
false;
  }
  if (
dist(player.1player.1.5pl.1pl.1.5) <= maxdist) {
    if (
player.dir == 0) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 1) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 2) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    else if (
player.dir == 3) {
      if (
pl.player.0.5) {
        return 
true;
      }
    }
    return 
false;
  } else {
    return 
false;
  }
}

function 
inParty(pl) {
  return (
pl.account in clientr.party);

Also I would store the tokens in it's own variable, for clarity reasons and it's slightly more efficient.

Your code can then be re-factored to:

PHP Code:
temp.weapondata wdata[5].tokenize(",");
temp.weapontype temp.weapondata[1];
temp.weapondist temp.weapondata[2];
if (
temp.weapontype == "arc") {
  for (
temp.plfindNearestPlayers(player.xplayer.y)) {
    if (!
inParty(temp.pl)) {
      if (
inHittingRange(temp.pltemp.weapondist)) {
        
sendTrigger(temp.pl);
      }
    }
  }

Reply With Quote