152 lines
4.7 KiB
JavaScript
152 lines
4.7 KiB
JavaScript
var gameConfig =require("gameConfig")
|
|
var dropItemConfig =gameConfig.dropItemConfig
|
|
var chacheobj = require("battleobjcache")
|
|
|
|
|
|
var dropobj = function(){
|
|
this.init = function(uuid,cid,x,y,gunlv,player){
|
|
this.obj_uniid = uuid
|
|
this.pos={
|
|
x:x,
|
|
y:y,
|
|
}
|
|
this.object_type = 5
|
|
this.item_id = cid
|
|
this.cfg = dropItemConfig[cid]
|
|
this.dead = false
|
|
this.equip_type = this.cfg.equip_type
|
|
this.item_level = gunlv
|
|
|
|
if(player){
|
|
this.doeff(player)
|
|
this.dead = true
|
|
player.needreport = true
|
|
}else{
|
|
chacheobj.objdrop[uuid]=this
|
|
}
|
|
}
|
|
this.doeff=function(player){
|
|
var res = -1
|
|
if(this.cfg.equip_type==1){
|
|
|
|
if(this.cfg.equip_subtype!=1){
|
|
if(player.weapons[1].weapon_id==0){
|
|
res = 0
|
|
player.weapons[1].weapon_id = this.cfg.id
|
|
player.weapons[1].weapon_lv = this.item_level
|
|
player.weapons[1].ammo=0
|
|
}else if(player.weapons[2].weapon_id==0){
|
|
res = 0
|
|
player.weapons[2].weapon_id = this.cfg.id
|
|
player.weapons[2].weapon_lv = this.item_level
|
|
player.weapons[2].ammo=0
|
|
}
|
|
}else{
|
|
if(player.weapons[0].weapon_id==30101){
|
|
res = 0
|
|
player.weapons[0].weapon_id = this.cfg.id
|
|
if(player.cur_weapon_idx==0){
|
|
player.changeweapon(0)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if(this.cfg.equip_type==2){
|
|
if(player.buchongzidan(this.cfg.inventory_slot)){
|
|
res = 0
|
|
}
|
|
}
|
|
|
|
else if(this.cfg.equip_type==3){
|
|
if(this.cfg.equip_subtype==2){
|
|
if(player.getitem(5)){
|
|
player.weapons[3].weapon_id = this.cfg.id
|
|
player.weapons[3].ammo = player.packstart[5]
|
|
res = 0
|
|
}
|
|
}else{
|
|
if(player.getitem(6)){
|
|
player.weapons[4].weapon_id = this.cfg.id
|
|
player.weapons[4].ammo = player.packstart[6]
|
|
res = 0
|
|
}
|
|
}
|
|
}
|
|
else if(this.cfg.equip_type==4){
|
|
if(this.cfg.equip_subtype ==1){
|
|
if(player.chest==0){
|
|
res = 0
|
|
player.chest = this.cfg.id
|
|
}else if(this.cfg.equip_lv > dropItemConfig[player.chest].equip_lv){
|
|
res = player.chest
|
|
player.chest = this.cfg.id
|
|
}
|
|
|
|
}else if(this.cfg.equip_subtype ==2){
|
|
if(player.helmet==0){
|
|
res = 0
|
|
player.helmet = this.cfg.id
|
|
}else if(this.cfg.equip_lv > dropItemConfig[player.helmet].equip_lv){
|
|
res = player.helmet
|
|
player.helmet = this.cfg.id
|
|
}
|
|
|
|
}
|
|
}
|
|
else if(this.cfg.equip_type==5){
|
|
if(this.cfg.equip_subtype==1){
|
|
if(player.getitem(7)){
|
|
res = 0
|
|
}
|
|
}else{
|
|
if(player.getitem(8)){
|
|
res = 0
|
|
}
|
|
}
|
|
}
|
|
else if(this.cfg.equip_type==7){
|
|
if(player.backpack==0){
|
|
res = 0
|
|
player.backpack = this.cfg.id
|
|
player.refreshbag()
|
|
}else if(this.cfg.equip_lv > dropItemConfig[player.backpack].equip_lv){
|
|
res = player.backpack
|
|
player.backpack = this.cfg.id
|
|
player.refreshbag()
|
|
}
|
|
|
|
}
|
|
else if(this.cfg.equip_type==9){
|
|
res = 0
|
|
player.closehorse()
|
|
player.addbuff(this.cfg.buffid)
|
|
player.daduanaction()
|
|
}
|
|
else if(this.cfg.equip_type==10){
|
|
if(this.cfg.equip_subtype==11){//
|
|
res = 0
|
|
player.sethat(this.cfg.id)
|
|
}
|
|
else if(this.cfg.equip_subtype==12){
|
|
res = 0
|
|
player.setcloth(this.cfg.id)
|
|
}
|
|
}
|
|
else if(this.cfg.equip_type==11){
|
|
res = 0
|
|
player.addfake(this.cfg.id)
|
|
}
|
|
else if(this.cfg.equip_type==12){
|
|
res = 0
|
|
player.additem(this.cfg.id)
|
|
}
|
|
|
|
return res
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = dropobj;
|