From: terencehill Date: Fri, 17 Feb 2017 18:37:59 +0000 (+0100) Subject: Merge branch 'master' into terencehill/bot_AI_improvements X-Git-Tag: xonotic-v0.8.2~202^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f94eb06cd0ff401f63e8e8c81f55961544846ee6;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into terencehill/bot_AI_improvements --- f94eb06cd0ff401f63e8e8c81f55961544846ee6 diff --cc qcsrc/common/t_items.qc index f295c1da3,3e3f32a9d..b6f405fec --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@@ -1302,58 -1286,8 +1305,56 @@@ void StartItem(entity this, GameItem de ); } +#define IS_SMALL(def) ((def.instanceOfHealth && def == ITEM_HealthSmall) || (def.instanceOfArmor && def == ITEM_ArmorSmall)) +int group_count = 1; + +void setItemGroup(entity this) +{ + if(!IS_SMALL(this.itemdef)) + return; + + FOREACH_ENTITY_RADIUS(this.origin, 120, (it != this) && IS_SMALL(it.itemdef), + { + if(!this.item_group) + { + if(!it.item_group) + { + it.item_group = group_count; + group_count++; + } + this.item_group = it.item_group; + } + else // spawning item is already part of a item_group X + { + if(!it.item_group) + it.item_group = this.item_group; + else if(it.item_group != this.item_group) // found an item near the spawning item that is part of a different item_group Y + { + int grY = it.item_group; + // move all items of item_group Y to item_group X + FOREACH_ENTITY(IS_SMALL(it.itemdef), + { + if(it.item_group == grY) + it.item_group = this.item_group; + }); + } + } + }); +} + +void setItemGroupCount() +{ + for (int k = 1; k <= group_count; k++) + { + int count = 0; + FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { count++; }); + if (count) + FOREACH_ENTITY(IS_SMALL(it.itemdef) && it.item_group == k, { it.item_group_count = count; }); + } +} + spawnfunc(item_rockets) { - if(!this.ammo_rockets) - this.ammo_rockets = g_pickup_rockets; StartItem(this, ITEM_Rockets); }