From 8d6b2e02c7bd8762719cd21d758704ba9ac19152 Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 11 Apr 2011 05:04:49 -0700 Subject: [PATCH] Fixes issue with item lookup in LootTable for items with a special base symbol. --- data/types/bullets.yaml | 5 +++++ data/types/items.yaml | 10 ++++++++++ data/types/loots.yaml | 4 ++-- data/types/units.yaml | 1 + src/tanks/inventory/loot.cjs | 8 +++++--- src/tanks/thing/tank.cjs | 2 +- src/tanks/thing/thing.cjs | 2 ++ src/tanks/thing/unit.cjs | 2 +- 8 files changed, 27 insertions(+), 7 deletions(-) diff --git a/data/types/bullets.yaml b/data/types/bullets.yaml index b73530c..ebaca76 100644 --- a/data/types/bullets.yaml +++ b/data/types/bullets.yaml @@ -10,6 +10,11 @@ types: bounceLimit: 1 stats: move: 2.25 + cheatz: + color: '#E73075' + bounceLimit: 1 + stats: + move: 4.50 rocket: color: '#F7ADA6' bounceLimit: 0 diff --git a/data/types/items.yaml b/data/types/items.yaml index 152265f..409b8c6 100644 --- a/data/types/items.yaml +++ b/data/types/items.yaml @@ -50,11 +50,21 @@ types: art: map_icon: '/img/items/rockets-bg-25x25.png' inv_icon: '/img/items/rockets-50x50.png' + shield_orb: + name: Shield Orb + desc: 'Generates one rotating shield sphere.' + tags: [ 'armor' ] + symbol: tanks/item/shieldgen.ShieldGenerator + spheres: 1 + art: + map_icon: '/img/items/orbital_shield_x4-25x25.png' + inv_icon: '/img/items/orbital_shield_x4-50x50.png' shield_gen: name: Shield Generator desc: 'Generates four rotating shield spheres, each of which absorbs one impact.' tags: [ 'armor' ] symbol: tanks/item/shieldgen.ShieldGenerator + spheres: 4 art: map_icon: '/img/items/orbital_shield_x4-25x25.png' inv_icon: '/img/items/orbital_shield_x4-50x50.png' diff --git a/data/types/loots.yaml b/data/types/loots.yaml index 7c7f835..09c797e 100644 --- a/data/types/loots.yaml +++ b/data/types/loots.yaml @@ -4,7 +4,7 @@ defaults: types: rich: items: - - 0.2 shield_gen - 0.1 super_armor - - 0.3 nitro - 0.1 rockets + - 0.2 shield_gen + - 0.6 shield_orb diff --git a/data/types/units.yaml b/data/types/units.yaml index 4364e54..20af363 100644 --- a/data/types/units.yaml +++ b/data/types/units.yaml @@ -43,6 +43,7 @@ types: power : 1 speed : 0.5 shots : 5 + projectile: normal # cheatz inventory: equipSlots: # name -> Container options; implies equipsContents=true weapon : { 'max':1, 'reqs':'weapon' } diff --git a/src/tanks/inventory/loot.cjs b/src/tanks/inventory/loot.cjs index 35bdebf..10353e4 100644 --- a/src/tanks/inventory/loot.cjs +++ b/src/tanks/inventory/loot.cjs @@ -23,8 +23,10 @@ evt.subclass('LootTable', { return this.items.reduce(this._roll, null); }, - _roll : function _roll(drop, o){ - return drop || (Math.random() < o.p ? o.item : null); + _roll : function _roll(drop, o, idx){ + var dice = Math.random(); + // console.log('roll('+idx+'):', drop, '|| '+dice.toFixed(3)+' < '+o.p+' ?', o.item, 'o: '+o, o); + return drop || (dice < o.p ? o.item : null); } }) @@ -51,7 +53,7 @@ LootTable.on('speciate', , p = parseFloat(spec.slice(0, sep)) , id = spec.slice(sep+1) ; - return new LootTableEntry(p, Item.lookupOrSpeciate(id)); + return new LootTableEntry(p, tanks.data.items[id]); }); NewLootTable.instance = new NewLootTable(); diff --git a/src/tanks/thing/tank.cjs b/src/tanks/thing/tank.cjs index 85e62a7..ac4787c 100644 --- a/src/tanks/thing/tank.cjs +++ b/src/tanks/thing/tank.cjs @@ -271,7 +271,7 @@ Unit.subclass('Tank', { getTurretLoc : function getTurretLoc(){ - var WIGGLE = 2, pw = this.projectile.fn.width; + var WIGGLE = 3, pw = this.projectile.fn.width; return this.barrelShape.barrelTipLoc(WIGGLE+pw, true); }, diff --git a/src/tanks/thing/thing.cjs b/src/tanks/thing/thing.cjs index c65e8e7..b65df39 100644 --- a/src/tanks/thing/thing.cjs +++ b/src/tanks/thing/thing.cjs @@ -188,6 +188,8 @@ new evt.Class('Thing', { if (c) { this.components.remove(c); c.removeListener('destroy', this.onComponentDeath); + if (c.isShield && this.shields) + this.shields.remove(c); } return this; }, diff --git a/src/tanks/thing/unit.cjs b/src/tanks/thing/unit.cjs index 16220c3..8ea439a 100644 --- a/src/tanks/thing/unit.cjs +++ b/src/tanks/thing/unit.cjs @@ -77,7 +77,7 @@ Thing.subclass('Unit', { // Additional space on each side which must be clear around the // shot to ensure we don't shoot ourself in the foot (literally) - var WIGGLE = 2 + var WIGGLE = 3 , Projectile = this.projectile , pw2 = Projectile.fn.width/2, ph2 = Projectile.fn.height/2 -- 1.7.0.4