Thread: new events
View Single Post
  #4  
Old 10-14-2007, 07:43 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Here's a betting spar.

Change the "this.boxName" to 1 or 2 [Only two per level, could add more on slight modifications]. Add two of these in the level.
HTML Code:
function onCreated() {
  this.setShape(1, 32, 32);
  this.boxName = 1;
}

//Function called to pick up an item
function onActionFound(id) {
  if (level.("objectOwner" @ this.boxName) != null) {
    return false;
  }
  for (temp.i: findnearestnpcs(this.x - 2, this.y - 2, 4, 4) {
    if (temp.i.itemid == temp.id) {

      level.("objectOwner" @ this.boxName) = player; 
      level.("objectItem1" @ this.boxName) = {temp.i.mudid, temp.i.mudquantity};
      temp.i.destroy();
      return;
    }
  }
}
Here's the main control, on the GK system this will probably need ajusting more than anything

HTML Code:
function onCreated() {
  this.setShape(1, 32, 32);
  this.boxModes = {1, 2};
  level.deathAction = {this.x, this.y};
  //Maybe there's a public function for when a person dies in a level! 
  //If not, I could add a timeout, just better to send an action once someone dies
}

//If there is, here's how it'd work
function onActionDeathAction(accountName) {
  for (temp.i: this.boxModes) {
    temp.ownerAccounts.add(level.("objectOwner" @ temp.i).account); 
    temp.itemDetails.add(level.("objectItem1" @ temp.i));
  }
  if (temp.ownerAccounts == null) {
    return false;
  }
  if (temp.accountName in temp.ownerAccounts) {
    temp.winner = temp.ownerAccounts.remove(temp.accountName);
    temp.winner.chat = "You've won the bet by slain thy opponent!";
    for (temp.i: temp.itemDetails) {
     //addinvobject(int, int) - I assue id/quantity
      temp.winner.addinvobject(temp.i[0], temp.i[1]);
    }
    level.objectOwner1 = null;
    level.objectOwner2 = null;
  }
}
__________________
Reply With Quote