Thanks for doing that, warspawn


On Wed, Oct 30, 2013 at 9:07 PM, Ben Sparks <notifications@github.com>wrote:

> In scripts/triggers/halloween.js:
>
> > @@ -43,19 +43,22 @@ module.exports = {
> >          onEnter: function(unit) {
> >              var trigger = this;
> >
> > -            // gimme candy!
> > -            // player drops candy
> > -            // get item (pumpkin mask?)
> > -
> > +            trigger.say("Trick or Treat!")
> > +            if(item.$template.name === '') {//candy
>
> for this particular quest, I added some new metadata to dropped items; in
> the game when you drop an item it creates the loot bag; the loot bag is
> also a unit, so it will have this onEnter function executed on it as well;
> so you will have to test separately for that; might be something like:
>
> if(unit.id < 0 && unit.data && unit.data.droppedBy > 0) {
>     // this should be a loot bag, it will have a "loot" array
>     // next, even though it is an array, for a loot bag it'll only be one item, so just grab it
>     var item = unit.loot[0];
>     if(item.$template.name === 'Candy Corn') {
>         // here we should snatch up the loot bag's candy before any player's can grab it
>         // and then give the droppedBy player the reward.
>         // the droppedBy value is the id of the unit (player)
>         // all triggers have a guests array of other units that are within its radius, so we can loop through and check if this player is a guest
>        var player = _.find(trigger.guests, function(guest) {
>               return guest.id === unit.data.droppedBy;
>        });
>        if(player) {
>               // give them the item
>               player.GiveItem(dataHandler.items[118]); // pumpkin mask is 118
>         }
>     }
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/ironbane/IronbaneAssets/pull/4/files#r7333699>
> .
>