1606 lines
51 KiB
JavaScript
1606 lines
51 KiB
JavaScript
var gameConfig = require("gameConfig")
|
|
var dropItemConfig = gameConfig.dropItemConfig
|
|
var playerconfig = gameConfig.playerConfig["40001"]
|
|
var chacheobj = require("battleobjcache")
|
|
var buffobj = require("buffobj")
|
|
var Utils = require("Utils")
|
|
|
|
var AIConfig = require("aiconfig").cfg
|
|
var AIEnum = require("aiconfig").enum
|
|
var deadConfig = require("aiconfig").deadConfig
|
|
var dressConfig = require("aiconfig").dressConfig
|
|
|
|
|
|
var robotai = require("robotai")
|
|
|
|
// var equipUpgradeConfig = gameConfig.equipUpgradeConfig
|
|
var skillConfig = gameConfig.skillConfig
|
|
var dtoh = 0.0174528
|
|
|
|
|
|
var movespeed = playerconfig.move_speed * 20
|
|
var shotmovespeed = playerconfig.shot_speed * 20
|
|
var animovespeed = playerconfig.aiming_speed * 20
|
|
var downspeed = playerconfig.move_speed3 * 20
|
|
|
|
// var jumpcd = 1000
|
|
var playersize = 20
|
|
var movesize = 10
|
|
var movepy = -17
|
|
var TempV = cc.v2()
|
|
|
|
var volume111 = playerconfig.volume.split('|')
|
|
for (var i = 0; i < volume111.length; i++) {
|
|
volume111[i] = volume111[i].split(':')
|
|
}
|
|
var slowswitch = 1300
|
|
var longswitch = 2800
|
|
|
|
var maxkucun = 90
|
|
|
|
|
|
var playerobj = function(uuid) {
|
|
this.obj_uniid = uuid
|
|
this.dir = cc.v2(0, 0)
|
|
this.pos = cc.v2(0, 0)
|
|
this.x = this.y = 0
|
|
this.width = this.height = playersize
|
|
this.attack_dir = cc.v2(0, 0)
|
|
this.move_dir = cc.v2(0, 0)
|
|
this.downed = false
|
|
this.dead = false
|
|
this.max_health = this.health = playerconfig.health
|
|
this.energy_shield = 0
|
|
this.backpack = 0
|
|
this.chest = 0
|
|
this.helmet = 0
|
|
this.actiontime = 0
|
|
this.hurttime = 0
|
|
this.revive_countdown = 10
|
|
this.def = 0
|
|
this.skill_left_time = 0
|
|
this.life = 1
|
|
this.attr = {}
|
|
this.propertyarr = []
|
|
this.killcount = 0
|
|
this.dmg = 0
|
|
// this.bulletbag = 90
|
|
this.states = []
|
|
this.buff_list = []
|
|
this.emote = null
|
|
this.sex = 2
|
|
|
|
this.packadd = {}
|
|
this.shotadd = {
|
|
x: 0,
|
|
y: 0,
|
|
}
|
|
|
|
this.skin = [{
|
|
skin_id: 1
|
|
}, {
|
|
skin_id: 1
|
|
}, {
|
|
skin_id: 1
|
|
}, {
|
|
skin_id: 1
|
|
}]
|
|
|
|
|
|
this.shot_hold = false
|
|
this.shottime = 0
|
|
this.can_revive = null
|
|
this.battleitemmap = {}
|
|
|
|
//
|
|
this.weapons = [{
|
|
weapon_id: 30101,
|
|
ammo: 999999
|
|
}, {
|
|
weapon_id: 0,
|
|
weapon_lv: 1,
|
|
ammo: 0
|
|
}, {
|
|
weapon_id: 0,
|
|
weapon_lv: 1,
|
|
ammo: 0
|
|
}, {
|
|
weapon_id: 0
|
|
}, {
|
|
weapon_id: 0
|
|
}, ]
|
|
|
|
this.additem = function(v) {
|
|
if (!this.battleitemmap[v]) {
|
|
this.battleitemmap[v] = 1
|
|
} else {
|
|
this.battleitemmap[v] = this.battleitemmap[v] + 1
|
|
}
|
|
}
|
|
|
|
|
|
this.getv = function(k) {
|
|
if (!this.attr[k]) {
|
|
this.attr[k] = 0
|
|
}
|
|
return this.attr[k]
|
|
}
|
|
this.addv = function(k, v, tp) {
|
|
var rk = tp == 2 ? k + 1000 : k
|
|
if (!this.attr[rk]) {
|
|
this.attr[rk] = 0
|
|
}
|
|
this.attr[rk] += v
|
|
}
|
|
this.removev = function(k, v, tp) {
|
|
var rk = tp == 2 ? k + 1000 : k
|
|
if (!this.attr[rk]) {
|
|
this.attr[rk] = 0
|
|
}
|
|
this.attr[rk] -= v
|
|
|
|
}
|
|
this.addbuff = function(bid) {
|
|
var buf = new buffobj(bid)
|
|
buf.add(this)
|
|
|
|
this.buff_list.push(buf)
|
|
|
|
cc.clientbattle.pushcgbuff({
|
|
buff_id: bid,
|
|
left_time: buf.left_time,
|
|
lasting_time: buf.lasting_time
|
|
}, this, 0)
|
|
}
|
|
|
|
this.setposition = function(x, y) {
|
|
this.x = x
|
|
this.y = y
|
|
this.pos.x = x
|
|
this.pos.y = y
|
|
}
|
|
this.init = function(cfg, member, gunid) {
|
|
this.aicfg = null
|
|
this.deadcfg = null
|
|
this.pausetime = 0
|
|
chacheobj.objmapplayer[this.obj_uniid] = this
|
|
this.nowspeed = movespeed
|
|
this.inventory = []
|
|
for (var i = 0; i < 16; i++) {
|
|
this.inventory.push(0)
|
|
}
|
|
this.skill_list = []
|
|
if (cfg) {
|
|
this.sex = cfg.sex
|
|
this.setcfg(cfg)
|
|
} else {
|
|
this.sex = Math.random() > 0.5 ? 1 : 2
|
|
var headid = this.sex == 1 ? 18101 : 18201
|
|
this.robot(gunid)
|
|
this.user_data = JSON.stringify({
|
|
avatar_id: headid
|
|
})
|
|
this.avatar_url = headid
|
|
|
|
|
|
if (member) {
|
|
this.ismember = true
|
|
}
|
|
}
|
|
}
|
|
this.closebufbytype = function(tp) {
|
|
for (var i = this.buff_list.length - 1; i >= 0; i--) {
|
|
if (this.buff_list[i].buff_effect == tp) {
|
|
this.buff_list[i].duration_time = 0
|
|
}
|
|
}
|
|
}
|
|
this.closefake = function() {
|
|
this.closebufbytype(5)
|
|
|
|
}
|
|
this.closehorse = function() {
|
|
for (var i = this.buff_list.length - 1; i >= 0; i--) {
|
|
if (this.buff_list[i].buff_effect == 3) {
|
|
this.buff_list[i].duration_time = 0
|
|
cc.clientbattle.createdropitem(this.buff_list[i].cfg.buff_param4, this.pos, 0, true)
|
|
}
|
|
}
|
|
this.shotadd.x = this.shotadd.y = 0
|
|
}
|
|
this.changeweapon = function(idx, isfirst) {
|
|
this.daduanaction()
|
|
this.gguncfg = gameConfig.dropItemConfig[this.weapons[idx].weapon_id]
|
|
if (!this.gguncfg) {
|
|
return
|
|
}
|
|
this.nowcaowei = gameConfig.dropItemConfig[this.gguncfg.use_bullet].inventory_slot
|
|
this.cur_weapon_idx = idx
|
|
this.gunid = this.weapons[idx].weapon_id
|
|
this.shotcd = this.gguncfg.fire_rate / 1000
|
|
this.shotmax = this.gguncfg.clip_volume
|
|
this.reloadtype = this.gguncfg.reloadtype
|
|
|
|
var gunlv = this.weapons[idx].weapon_lv
|
|
|
|
var equipattr = null
|
|
// if (gameConfig.equipUpgradeConfig[this.gunid]) {
|
|
// equipattr = gameConfig.equipUpgradeConfig[this.gunid].spera_attr
|
|
// }
|
|
|
|
this.shotmax += Utils.findvarbylv(10, gunlv, equipattr)
|
|
|
|
// if(this.gunid ==this.spweapon){
|
|
// this.shotmax = this.spammo
|
|
// gunlv = this.splv
|
|
// }
|
|
|
|
var barr = this.gguncfg.bullet_born_offset.split('|')
|
|
this.bulletborn = []
|
|
for (var i = 0; i < barr.length; i++) {
|
|
this.bulletborn.push(barr[i].split(':'))
|
|
}
|
|
this.shotnowtime = this.shotcd
|
|
|
|
|
|
this.reloadtime = this.gguncfg.reload_time / 1000
|
|
this.needreport = true
|
|
|
|
this.weapon = {
|
|
weapon_id: this.gunid,
|
|
weapon_lv: gunlv
|
|
}
|
|
// this.weapons[idx].weapon_lv = gunlv
|
|
|
|
if (isfirst && !this.isrole) { //jjtest
|
|
this.weapons[idx].ammo = this.shotmax
|
|
}
|
|
if (this.weapons[idx].ammo == 0) {
|
|
this.doreload()
|
|
}
|
|
|
|
}
|
|
this.setskin = function(v) {
|
|
for (var i = 0; i < 4; i++) {
|
|
this.skin[i].skin_id = v[i]
|
|
}
|
|
}
|
|
|
|
this.sethat = function(v) {
|
|
var old = this.skin[2].skin_id
|
|
this.skin[2].skin_id = v
|
|
cc.clientbattle.createdropitem(old, this.pos)
|
|
}
|
|
this.setcloth = function(v) {
|
|
var old = this.skin[1].skin_id
|
|
this.skin[1].skin_id = v
|
|
cc.clientbattle.createdropitem(old, this.pos)
|
|
}
|
|
|
|
|
|
|
|
this.refreshbag = function() {
|
|
this.packadd = {}
|
|
var volume = gameConfig.dropItemConfig[this.backpack].volume.split('|')
|
|
for (var i = 0; i < volume.length; i++) {
|
|
volume[i] = volume[i].split(':')
|
|
}
|
|
for (var i = 0; i < volume.length; i++) {
|
|
this.packadd[volume[i][0]] = Number(volume[i][1])
|
|
}
|
|
}
|
|
this.setitems = function(v) {
|
|
// this.inventory = []
|
|
// for(var i=0;i<16;i++){
|
|
// this.inventory.push(0)
|
|
// }
|
|
this.items = []
|
|
this.packstart = {}
|
|
for (var i = 0; i < volume111.length; i++) {
|
|
this.packstart[volume111[i][0]] = Number(volume111[i][1])
|
|
}
|
|
for (var i = 0; i < v.length; i++) {
|
|
this.items.push(v[i])
|
|
}
|
|
}
|
|
this.addfake = function(id) {
|
|
for (var i = this.items.length - 1; i >= 0; i--) {
|
|
if (this.items[i].key == id) {
|
|
this.items[i].value++
|
|
this.propertyarr.push({
|
|
property_type: 9,
|
|
property_subtype: id,
|
|
value: this.items[i].value,
|
|
obj_id: this.obj_uniid,
|
|
})
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
this.getitem = function(idx) {
|
|
var sv = this.packstart[idx]
|
|
var av = this.packadd[idx]
|
|
if (!av) {
|
|
av = 0
|
|
}
|
|
|
|
if (this.inventory[idx] < sv + av) {
|
|
this.inventory[idx]++
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
|
|
this.onreport = function(data) {
|
|
|
|
if (this.pausetime > 0) {
|
|
return
|
|
}
|
|
|
|
var needclosefake = false
|
|
if (data.move_dir) {
|
|
this.move_dir = data.move_dir.normalize()
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
if (!(this.dir.x == 0 && this.dir.y == 0)) {
|
|
needclosefake = true
|
|
}
|
|
}
|
|
if (data.attack_dir) {
|
|
this.attack_dir = data.attack_dir.normalize()
|
|
this.dir.x = this.attack_dir.x
|
|
this.dir.y = this.attack_dir.y
|
|
|
|
}
|
|
if (data.attack_dir.x == 0 && data.attack_dir.y == 0) {
|
|
data.shot_hold = false
|
|
}
|
|
if (data.shot_hold && !this.tiaosan) {
|
|
if (!(this.weapons[this.cur_weapon_idx].ammo == 0 && this.action_type == 1)) {
|
|
this.daduanaction()
|
|
}
|
|
|
|
needclosefake = true
|
|
this.shot_hold = true
|
|
// console.log(this.pos)
|
|
} else {
|
|
this.shot_hold = false
|
|
}
|
|
if (data.emote) {
|
|
this.emote = {
|
|
player_id: this.obj_uniid,
|
|
emote_id: data.emote
|
|
}
|
|
}
|
|
if (data.reload && !this.tiaosan && this.inventory[this.nowcaowei] > 0) {
|
|
if (this.weapons[this.cur_weapon_idx].ammo < this.shotmax) {
|
|
this.doreload()
|
|
needclosefake = true
|
|
}
|
|
}
|
|
if (data.drop_weapon != undefined && !this.tiaosan) {
|
|
this.dodrop(data.drop_weapon)
|
|
}
|
|
|
|
if (data.interaction_objids.length > 0 && !this.tiaosan) {
|
|
for (var i = data.interaction_objids.length - 1; i >= 0; i--) {
|
|
var drop = chacheobj.objdrop[data.interaction_objids[i]]
|
|
if (drop) {
|
|
var newid = drop.doeff(this)
|
|
if (newid > 0) {
|
|
cc.clientbattle.createdropitem(newid, this.pos)
|
|
}
|
|
if (newid >= 0) {
|
|
drop.dead = true
|
|
this.needreport = true
|
|
}
|
|
} else {
|
|
var loot = chacheobj.objmaploot[data.interaction_objids[i]]
|
|
if (loot) {
|
|
loot.dodakai()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (data.select_weapon != undefined && !this.tiaosan) {
|
|
this.changeweapon(data.select_weapon)
|
|
needclosefake = true
|
|
}
|
|
|
|
if (data.aiming && !this.tiaosan) { //瞄准
|
|
this.aiming = true
|
|
needclosefake = true
|
|
}
|
|
if (data.shot_start && !this.tiaosan) {
|
|
this.aiming = false
|
|
if (!data.fly_distance) {
|
|
this.shot(9999)
|
|
} else {
|
|
var canshot = false
|
|
var needcg = false
|
|
if (this.cur_weapon_idx == 3 && this.inventory[5] > 0) {
|
|
this.inventory[5]--
|
|
if (this.inventory[5] == 0) {
|
|
this.weapons[3].weapon_id = 0
|
|
needcg = true
|
|
}
|
|
this.weapons[3].ammo = this.packstart[5]
|
|
canshot = true
|
|
} else if (this.cur_weapon_idx == 4 && this.inventory[6] > 0) {
|
|
this.inventory[6]--
|
|
if (this.inventory[6] == 0) {
|
|
this.weapons[4].weapon_id = 0
|
|
needcg = true
|
|
}
|
|
this.weapons[4].ammo = this.packstart[6]
|
|
canshot = true
|
|
}
|
|
if (canshot) {
|
|
this.doshot(data.fly_distance)
|
|
}
|
|
if (needcg) {
|
|
this.overlose()
|
|
}
|
|
|
|
}
|
|
needclosefake = true
|
|
}
|
|
if (data.use_item_idx) {
|
|
//console.log(data.use_item_idx)
|
|
|
|
if (this.inventory[data.use_item_idx] > 0) {
|
|
if (data.use_item_idx == 7) {
|
|
this.yaoidx = 7
|
|
this.doheal(30301)
|
|
} else if (data.use_item_idx == 8) {
|
|
this.yaoidx = 8
|
|
this.doheal(30302)
|
|
}
|
|
}
|
|
|
|
needclosefake = true
|
|
}
|
|
if (needclosefake) {
|
|
this.closefake()
|
|
}
|
|
if (data.use_item_id && !this.tiaosan) {
|
|
this.daduanaction()
|
|
for (var i = 0; i < this.items.length; i++) {
|
|
if (this.items[i].key == data.use_item_id) {
|
|
if (this.items[i].value > 0) {
|
|
this.items[i].value--
|
|
this.propertyarr.push({
|
|
property_type: 9,
|
|
property_subtype: this.items[i].key,
|
|
obj_id: this.obj_uniid,
|
|
value: this.items[i].value
|
|
})
|
|
|
|
this.closefake()
|
|
this.addbuff(data.use_item_id)
|
|
this.needreport = true
|
|
}
|
|
break
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
if (data.get_down && !this.tiaosan) {
|
|
this.daduanaction()
|
|
this.closehorse()
|
|
this.needreport = true
|
|
}
|
|
if (data.use_skill && !this.tiaosan) {
|
|
this.daduanaction()
|
|
for (var i = 0; i < this.skill_list.length; i++) {
|
|
if (this.skill_list[i].skill_id == data.skill_id) {
|
|
this.closefake()
|
|
this.skill_list[i].left_time = this.skill_list[i].cd_time
|
|
if (i == 0) {
|
|
this.addbuff(1002)
|
|
if (this.dashdir) {
|
|
this.dir.x = this.dashdir.x
|
|
this.dir.y = this.dashdir.y
|
|
this.dashdir = null
|
|
}
|
|
this.movev(this.dir, 100)
|
|
} else {
|
|
cc.clientbattle.nowskill = data.skill_id
|
|
TempV.x = data.skill_dir.x
|
|
TempV.y = data.skill_dir.y
|
|
TempV = TempV.normalize()
|
|
var bt = {
|
|
dir: {
|
|
x: TempV.x,
|
|
y: TempV.y
|
|
},
|
|
// fly_distance: fly,
|
|
gun_id: 30901,
|
|
gun_lv: 1,
|
|
player_id: this.obj_uniid,
|
|
pos: {
|
|
x: this.pos.x,
|
|
y: this.pos.y
|
|
}
|
|
}
|
|
chacheobj.bulletarr.push(bt)
|
|
this.dopause(1.5)
|
|
|
|
|
|
// this.addhp(200)
|
|
// var loot = cc.clientbattle.createlootbyid(80006, this.pos.x, this.pos.y)
|
|
// this.pausetime = 2.4
|
|
// setTimeout(() => {
|
|
// loot.dead = true
|
|
// }, 4900);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
this.needreport = true
|
|
}
|
|
if (data.spectate) {
|
|
this.life = 0
|
|
this.dodead(this.obj_uniid)
|
|
}
|
|
}
|
|
this.overlose = function() {
|
|
if (this.weapons[1].weapon_id != 0) {
|
|
this.changeweapon(1)
|
|
} else if (this.weapons[2].weapon_id != 0) {
|
|
this.changeweapon(2)
|
|
} else {
|
|
this.changeweapon(0)
|
|
}
|
|
}
|
|
this.buchongzidan = function(idx) {
|
|
if (this.inventory[idx] < maxkucun) {
|
|
this.inventory[idx] += 30
|
|
this.inventory[idx] = Math.min(this.inventory[idx], maxkucun)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
|
|
this.dodrop = function(idx) {
|
|
if (idx == 1 || idx == 2) {
|
|
if (this.weapons[idx].weapon_id > 0) {
|
|
cc.clientbattle.createdropitem(this.weapons[idx].weapon_id, this.pos, 70, null, this.weapons[idx].weapon_lv)
|
|
this.weapons[idx].weapon_id = 0
|
|
this.weapons[idx].ammo = 0
|
|
this.needreport = true
|
|
|
|
if (idx == 1) {
|
|
if (this.weapons[2].weapon_id != 0) {
|
|
this.changeweapon(2)
|
|
} else {
|
|
this.changeweapon(0)
|
|
}
|
|
|
|
} else if (idx == 2) {
|
|
if (this.weapons[1].weapon_id != 0) {
|
|
this.changeweapon(1)
|
|
} else {
|
|
this.changeweapon(0)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
} else if (idx == 0) {
|
|
if (this.weapons[idx].weapon_id != 30101) {
|
|
cc.clientbattle.createdropitem(this.weapons[idx].weapon_id, this.pos, 70)
|
|
this.weapons[idx].weapon_id = 30101
|
|
this.weapons[idx].ammo = 999999
|
|
if (this.cur_weapon_idx == 0) {
|
|
this.changeweapon(0)
|
|
}
|
|
this.needreport = true
|
|
}
|
|
} else if (idx == 3) {
|
|
|
|
if (this.inventory[5] > 0) {
|
|
for (var i = 0; i < this.inventory[5]; i++) {
|
|
cc.clientbattle.createdropitem(this.weapons[3].weapon_id, this.pos, 70)
|
|
}
|
|
this.inventory[5] = 0
|
|
this.weapons[3].ammo = 0
|
|
this.weapons[3].weapon_id = 0
|
|
|
|
}
|
|
if (this.cur_weapon_idx == 3) {
|
|
this.overlose()
|
|
}
|
|
|
|
} else if (idx == 4) {
|
|
if (this.inventory[6] > 0) {
|
|
for (var i = 0; i < this.inventory[6]; i++) {
|
|
cc.clientbattle.createdropitem(this.weapons[4].weapon_id, this.pos, 70)
|
|
}
|
|
this.inventory[6] = 0
|
|
this.weapons[4].ammo = 0
|
|
this.weapons[4].weapon_id = 0
|
|
}
|
|
if (this.cur_weapon_idx == 4) {
|
|
this.overlose()
|
|
}
|
|
}
|
|
}
|
|
this.hurt = function(atk, atkerid, gun) {
|
|
if (this.dead) {
|
|
return
|
|
}
|
|
if (this.wudi) {
|
|
return
|
|
}
|
|
|
|
if (cc.clientbattle.memberarr[atkerid] && (this.ismember || this.isrole)) {
|
|
return
|
|
}
|
|
if (cc.clientbattle.isnewbie) {
|
|
if (cc.clientbattle.player.obj_uniid != atkerid && cc.clientbattle.player.obj_uniid != this.obj_uniid) {
|
|
return
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (this.energy_shield > 0) {
|
|
this.energy_shield -= atk
|
|
this.needreport = true
|
|
return
|
|
}
|
|
|
|
if (gun.id == 30901) { //jjtest
|
|
this.addbuff(201013)
|
|
this.dopause(5)
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.shot_hold = false
|
|
}
|
|
|
|
if (this.isrole || this.ismember) {
|
|
atk = 5
|
|
}
|
|
this.health -= atk
|
|
if (this.isrole || this.ismember) {
|
|
if (this.health / this.max_health < 0.2) {
|
|
this.health = Math.floor(this.max_health * 0.2)
|
|
}
|
|
}
|
|
|
|
if (cc.clientbattle.player.obj_uniid == atkerid) {
|
|
cc.clientbattle.player.dmg += atk
|
|
}
|
|
|
|
if (this.health <= 0) {
|
|
this.dodead(atkerid, gun)
|
|
|
|
}
|
|
this.needreport = true
|
|
}
|
|
this.dodead = function(atkerid, gun) {
|
|
if (atkerid) {
|
|
this.atkerid = atkerid
|
|
}
|
|
this.health = 0
|
|
this.dead = true
|
|
this.killer_id = this.atkerid
|
|
if (this.atkerid == -1) {
|
|
this.killer_name = cc.language.stringformat("duquan")
|
|
} else if (this.atkerid == this.obj_uniid) {
|
|
this.killer_name = cc.language.stringformat("ziji")
|
|
} else {
|
|
this.killer_name = cc.language.stringformat("morenmingzi")
|
|
}
|
|
this.closefake()
|
|
this.closehorse()
|
|
if (this.isrole && this.life > 0) {
|
|
this.life--
|
|
this.can_revive = true
|
|
} else {
|
|
this.can_revive = false
|
|
}
|
|
|
|
var atkname = null
|
|
|
|
if (this.can_revive == false) {
|
|
var iself = false
|
|
if (cc.clientbattle.player.obj_uniid == this.atkerid && this.obj_uniid != this.atkerid) {
|
|
cc.clientbattle.player.killcount++
|
|
iself = true
|
|
}
|
|
if (!this.isrole) {
|
|
cc.clientbattle.aliverobot--
|
|
}
|
|
if (atkerid == cc.clientbattle.player.obj_uniid) {
|
|
atkname = cc.clientbattle.player.name
|
|
} else if (cc.clientbattle.memberarr[atkerid]) {
|
|
atkname = cc.clientbattle.memberarr[atkerid].name
|
|
}
|
|
cc.clientbattle.dokillmsg(atkname, gun)
|
|
|
|
this.dodeaddrop()
|
|
}
|
|
|
|
}
|
|
|
|
this.dodeaddrop = function() {
|
|
|
|
if (this.deadcfg) {
|
|
var x = this.deadcfg[1]
|
|
var y = this.deadcfg[2]
|
|
if (this.deadcfg[3] == 1) {
|
|
x += cc.clientbattle.player.x
|
|
y += cc.clientbattle.player.y
|
|
}
|
|
cc.clientbattle.createlootbyid(this.deadcfg[0], x, y)
|
|
}
|
|
|
|
|
|
if (!cc.clientbattle.isnewbie) {
|
|
// cc.clientbattle.createdropitem(this.skin[1].skin_id, this.pos)
|
|
// cc.clientbattle.createdropitem(this.skin[2].skin_id, this.pos)
|
|
if (this.weapons[0].weapon_id != 30101) {
|
|
cc.clientbattle.createdropitem(this.weapons[0].weapon_id, this.pos)
|
|
}
|
|
if (this.weapons[1].weapon_id != 0) {
|
|
cc.clientbattle.createdropitem(this.weapons[1].weapon_id, this.pos)
|
|
}
|
|
if (this.weapons[2].weapon_id != 0) {
|
|
cc.clientbattle.createdropitem(this.weapons[2].weapon_id, this.pos)
|
|
}
|
|
}
|
|
|
|
if (this.isrole) {
|
|
cc.clientbattle.dogameover(this.killer_name)
|
|
}
|
|
}
|
|
|
|
|
|
this.revive = function() {
|
|
this.health = this.max_health
|
|
this.dead = false
|
|
if (Math.random() > 0.5) {
|
|
this.addbuff(1007)
|
|
this.addbuff(1011)
|
|
this.addbuff(1012)
|
|
} else {
|
|
this.addbuff(1008)
|
|
this.addbuff(1021)
|
|
this.addbuff(1022)
|
|
}
|
|
|
|
}
|
|
|
|
this.doshot = function(fly) {
|
|
|
|
|
|
let dir = cc.v2()
|
|
for (var i = 0; i < this.bulletborn.length; i++) {
|
|
dir.x = this.attack_dir.x
|
|
dir.y = this.attack_dir.y
|
|
let onedata = this.bulletborn[i]
|
|
if (onedata[2]) {
|
|
dir = Utils.dirRotate(dir, Number(onedata[2]) * dtoh)
|
|
}
|
|
|
|
if (this.gguncfg && this.gguncfg.bullet_angle > 0) {
|
|
dir = Utils.dirRotate(dir, (Utils.randintSeed(this.gguncfg.bullet_angle * 2) - this.gguncfg.bullet_angle) * dtoh)
|
|
}
|
|
|
|
var bt = {
|
|
dir: {
|
|
x: dir.x,
|
|
y: dir.y
|
|
},
|
|
fly_distance: fly,
|
|
gun_id: this.gunid,
|
|
gun_lv: 1,
|
|
player_id: this.obj_uniid,
|
|
pos: {
|
|
x: this.pos.x + this.shotadd.x,
|
|
y: this.pos.y + this.shotadd.y
|
|
}
|
|
}
|
|
chacheobj.bulletarr.push(bt)
|
|
|
|
}
|
|
|
|
this.needreport = true
|
|
|
|
|
|
}
|
|
this.doreload = function() {
|
|
if (this.action_type == 1) {
|
|
return
|
|
}
|
|
|
|
if (this.inventory[this.nowcaowei] <= 0) {
|
|
return
|
|
}
|
|
|
|
this.action_type = 1
|
|
this.actiontime = this.reloadtime
|
|
this.action_duration = this.reloadtime * 1000
|
|
this.needreport = true
|
|
|
|
|
|
if (!this.isrole) {
|
|
if (this.action_duration <= slowswitch) {
|
|
this.showEmoteNetAnimation(1003)
|
|
} else if (this.action_duration >= longswitch) {
|
|
this.showEmoteNetAnimation(11005)
|
|
} else {
|
|
this.showEmoteNetAnimation(11004)
|
|
}
|
|
}
|
|
}
|
|
this.showEmoteNetAnimation = function(id) {
|
|
this.emote = {
|
|
player_id: this.obj_uniid,
|
|
emote_id: id
|
|
}
|
|
}
|
|
this.shot = function(dt) {
|
|
if (this.action_type == 1) {
|
|
return
|
|
}
|
|
this.shotnowtime += dt
|
|
|
|
if (this.shotnowtime > this.shotcd) {
|
|
this.shotnowtime = 0
|
|
if (this.weapons[this.cur_weapon_idx].ammo > 0) {
|
|
this.weapons[this.cur_weapon_idx].ammo = this.weapons[this.cur_weapon_idx].ammo - 1
|
|
this.doshot()
|
|
}
|
|
if (this.weapons[this.cur_weapon_idx].ammo <= 0 && this.inventory[this.nowcaowei] > 0) {
|
|
this.doreload()
|
|
}
|
|
}
|
|
}
|
|
this.luodi = function() {
|
|
var start = 1
|
|
var arr = [
|
|
[50, 0],
|
|
[-50, 0],
|
|
[0, 50],
|
|
[0, -50]
|
|
]
|
|
var res = this.pengzhuangcheck()
|
|
|
|
|
|
|
|
if (res) {
|
|
while (true) {
|
|
for (var i = 0; i < 4; i++) {
|
|
var oldx = this.pos.x
|
|
var oldy = this.pos.y
|
|
this.pos.x += arr[i][0] * start
|
|
this.pos.y += arr[i][1] * start
|
|
this.pos.x = Math.min(Math.max(0, this.pos.x), cc.clientbattle.mapsize)
|
|
this.pos.y = Math.min(Math.max(0, this.pos.y), cc.clientbattle.mapsize)
|
|
this.x = this.pos.x
|
|
this.y = this.pos.y
|
|
|
|
if (!this.pengzhuangcheck()) {
|
|
return
|
|
} else {
|
|
this.pos.x = oldx
|
|
this.pos.y = oldy
|
|
}
|
|
|
|
}
|
|
start++
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
this.pengzhuangcheck = function() {
|
|
var objs = cc.clientbattle.getpzobjs({
|
|
x: this.pos.x,
|
|
y: this.pos.y,
|
|
width: this.width * 4,
|
|
height: this.height * 4
|
|
})
|
|
var pz = false
|
|
for (var i = objs.length - 1; i >= 0; i--) {
|
|
var obj = objs[i]
|
|
if (obj.loot) {
|
|
if (obj.loot.dead || obj.loot.event || obj.width == 0 || obj.height == 0) {
|
|
continue
|
|
}
|
|
}
|
|
var pobj = {
|
|
x: obj.xx,
|
|
y: obj.yy,
|
|
width: obj.width,
|
|
height: obj.height,
|
|
}
|
|
var size = movesize
|
|
// if (!obj.loot) {
|
|
// size = movesize * 1.5
|
|
// }
|
|
var autobox = false
|
|
if (Utils.hitTestRectangle(pobj, {
|
|
x: this.pos.x,
|
|
y: this.pos.y + movepy,
|
|
width: size,
|
|
height: size
|
|
})) {
|
|
pz = true
|
|
break
|
|
}
|
|
}
|
|
|
|
|
|
return pz
|
|
|
|
}
|
|
|
|
this.movev = function(dir, v) {
|
|
if (cc.jietumode) {
|
|
v *= 10
|
|
this.pos.x += dir.x * v
|
|
this.pos.y += dir.y * v
|
|
this.pos.x = Math.min(Math.max(0, this.pos.x), cc.clientbattle.mapsize)
|
|
this.pos.y = Math.min(Math.max(0, this.pos.y), cc.clientbattle.mapsize)
|
|
this.x = this.pos.x
|
|
this.y = this.pos.y
|
|
return true
|
|
|
|
}
|
|
|
|
if (this.notpz || this.tiaosan) {
|
|
this.pos.x += dir.x * v
|
|
this.pos.y += dir.y * v
|
|
this.pos.x = Math.min(Math.max(0, this.pos.x), cc.clientbattle.mapsize)
|
|
this.pos.y = Math.min(Math.max(0, this.pos.y), cc.clientbattle.mapsize)
|
|
this.x = this.pos.x
|
|
this.y = this.pos.y
|
|
return true
|
|
}
|
|
|
|
|
|
var diedai = Math.ceil(v / 5)
|
|
var vv = v / diedai
|
|
|
|
var canx = 1
|
|
var cany = 1
|
|
this.oldx = this.pos.x
|
|
this.oldy = this.pos.y
|
|
|
|
|
|
for (var ii = 0; ii < diedai; ii++) {
|
|
var addx = dir.x * vv * canx
|
|
var addy = dir.y * vv * cany
|
|
var objs = cc.clientbattle.getpzobjs({
|
|
x: this.pos.x,
|
|
y: this.pos.y,
|
|
width: this.width * 4,
|
|
height: this.height * 4
|
|
})
|
|
for (var i = objs.length - 1; i >= 0; i--) {
|
|
var obj = objs[i]
|
|
if (obj.loot) {
|
|
if (obj.loot.dead || obj.width == 0 || obj.height == 0) {
|
|
continue
|
|
}
|
|
}
|
|
var pobj = {
|
|
x: obj.xx,
|
|
y: obj.yy,
|
|
width: obj.width,
|
|
height: obj.height,
|
|
}
|
|
var size = movesize
|
|
// if (!obj.loot) {
|
|
// size = playersize * 1.5
|
|
// }
|
|
var autobox = false
|
|
var canevent = true
|
|
if (Utils.hitTestRectangle(pobj, {
|
|
x: this.pos.x + addx,
|
|
y: this.pos.y + movepy,
|
|
width: size,
|
|
height: size
|
|
})) {
|
|
|
|
if (cc.clientbattle.gamestart && obj.loot && obj.loot.dropid) {
|
|
autobox = true
|
|
}
|
|
if (this.isrole && obj.loot && obj.loot.event) {
|
|
obj.loot.doevent()
|
|
canevent = false
|
|
} else {
|
|
addx = 0
|
|
canx = 0
|
|
}
|
|
}
|
|
if (Utils.hitTestRectangle(pobj, {
|
|
x: this.pos.x,
|
|
y: this.pos.y + addy + movepy,
|
|
width: size,
|
|
height: size
|
|
})) {
|
|
|
|
if (cc.clientbattle.gamestart && obj.loot && obj.loot.dropid) {
|
|
autobox = true
|
|
}
|
|
if (this.isrole && obj.loot && obj.loot.event) {
|
|
if (canevent) {
|
|
obj.loot.doevent()
|
|
}
|
|
} else {
|
|
addy = 0
|
|
cany = 0
|
|
}
|
|
|
|
|
|
}
|
|
if (!this.isrole && cc.clientbattle.fixdrop.length > 0) {
|
|
autobox = false
|
|
}
|
|
if (autobox) {
|
|
//cc.clientbattle.createdrop(obj.loot.hurt(9999, this.obj_uniid), this.pos)
|
|
|
|
}
|
|
}
|
|
this.pos.x += addx
|
|
this.pos.y += addy
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir.x != 0 || dir.y != 0) {
|
|
var objs = cc.clientbattle.getpzobjs({
|
|
x: this.pos.x,
|
|
y: this.pos.y,
|
|
width: this.width * 4,
|
|
height: this.height * 4
|
|
})
|
|
for (var i = objs.length - 1; i >= 0; i--) {
|
|
var obj = objs[i]
|
|
if (obj.loot) {
|
|
if (obj.loot.dead || obj.loot.event || obj.width == 0 || obj.heigth == 0) {
|
|
continue
|
|
}
|
|
}
|
|
var pobj = {
|
|
x: obj.xx,
|
|
y: obj.yy,
|
|
width: obj.width,
|
|
height: obj.height,
|
|
}
|
|
var size = movesize
|
|
if (!obj.loot) {
|
|
size = playersize * 1.5
|
|
}
|
|
|
|
if (Utils.hitTestRectangle(pobj, {
|
|
x: this.pos.x,
|
|
y: this.pos.y + movepy,
|
|
width: size,
|
|
height: size
|
|
})) {
|
|
this.pos.x = this.oldx
|
|
this.pos.y = this.oldy
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
this.pos.x = Math.min(Math.max(0, this.pos.x), cc.clientbattle.mapsize)
|
|
this.pos.y = Math.min(Math.max(0, this.pos.y), cc.clientbattle.mapsize)
|
|
|
|
|
|
this.x = this.pos.x
|
|
this.y = this.pos.y
|
|
|
|
|
|
|
|
}
|
|
this.domove = function(dt) {
|
|
var speed = (this.getv(5) + this.nowspeed) * (1 + this.getv(1005))
|
|
this.movev(this.move_dir, speed * dt)
|
|
}
|
|
this.doheal = function(bid) {
|
|
if (this.action_type == 2) {
|
|
return
|
|
}
|
|
var cfg = dropItemConfig[bid]
|
|
this.action_type = 2
|
|
this.actiontime = cfg.use_time / 1000
|
|
this.action_duration = cfg.use_time
|
|
this.needreport = true
|
|
this.yaov = cfg.heal
|
|
}
|
|
this.addhp = function(v) {
|
|
this.health += v
|
|
if (this.health > this.max_health) {
|
|
this.health = this.max_health
|
|
}
|
|
}
|
|
this.daduanaction = function() {
|
|
this.action_type = 0
|
|
}
|
|
this.update = function(dt, gas) {
|
|
if (this.dead) {
|
|
return
|
|
}
|
|
if (this.nextreload) {
|
|
this.nextreload = false
|
|
this.doreload()
|
|
}
|
|
|
|
|
|
this.pausetime -= dt
|
|
if (this.pausetime <= 0) {
|
|
this.ai(dt)
|
|
}
|
|
this.domove(dt)
|
|
if (this.skill_left_time > 0) {
|
|
this.skill_left_time -= dt * 1000
|
|
if (this.skill_left_time <= 0) {
|
|
this.needreport = true
|
|
}
|
|
}
|
|
|
|
for (var i = 0; i < this.skill_list.length; i++) {
|
|
if (this.skill_list[i].left_time > 0) {
|
|
this.skill_list[i].left_time -= dt * 1000
|
|
|
|
if (this.skill_list[i].left_time <= 0) {
|
|
this.needreport = true
|
|
}
|
|
}
|
|
this.skill_list[i].curr_times = this.skill_list[i].left_time > 0 ? 0 : 1
|
|
|
|
}
|
|
|
|
this.nowspeed = movespeed
|
|
if (this.action_type == 1 && this.actiontime > 0) {
|
|
this.nowspeed = shotmovespeed
|
|
this.actiontime -= dt
|
|
if (this.actiontime <= 0) {
|
|
this.action_type = 0
|
|
this.shotnowtime = this.shotcd
|
|
var upv = this.weapons[this.cur_weapon_idx].ammo + 1
|
|
if (!this.reloadtype || upv == this.shotmax) {
|
|
|
|
var addbullet = this.shotmax
|
|
if (this.inventory[this.nowcaowei] <= this.shotmax) {
|
|
addbullet = this.inventory[this.nowcaowei]
|
|
}
|
|
var plusb = 0
|
|
if(this.weapons[this.cur_weapon_idx].ammo>0){
|
|
plusb = this.weapons[this.cur_weapon_idx].ammo
|
|
}
|
|
this.inventory[this.nowcaowei] -= addbullet
|
|
this.inventory[this.nowcaowei]+=plusb
|
|
this.weapons[this.cur_weapon_idx].ammo = addbullet
|
|
} else {
|
|
this.weapons[this.cur_weapon_idx].ammo = this.weapons[this.cur_weapon_idx].ammo + 1
|
|
this.nextreload = true
|
|
}
|
|
this.needreport = true
|
|
}
|
|
|
|
this.action_duration = this.actiontime * 1000
|
|
} else if (this.action_type == 2 && this.actiontime > 0) {
|
|
this.nowspeed = shotmovespeed
|
|
this.actiontime -= dt
|
|
if (this.actiontime <= 0) {
|
|
this.action_type = 0
|
|
this.inventory[this.yaoidx]--;
|
|
this.addhp(this.yaov)
|
|
this.needreport = true
|
|
}
|
|
|
|
this.action_duration = this.actiontime * 1000
|
|
} else if (this.shot_hold && !this.tiaosan) {
|
|
this.nowspeed = shotmovespeed
|
|
this.shot(dt)
|
|
chacheobj.shotarr.push({
|
|
player_id: this.obj_uniid,
|
|
weapon: {
|
|
weapon_id: this.weapons[this.cur_weapon_idx].weapon_id
|
|
}
|
|
})
|
|
} else if (this.aiming) {
|
|
this.nowspeed = shotmovespeed
|
|
}
|
|
|
|
|
|
for (var i = this.buff_list.length - 1; i >= 0; i--) {
|
|
if (this.buff_list[i].update(dt)) {
|
|
|
|
cc.clientbattle.pushcgbuff({
|
|
buff_id: this.buff_list[i].buff_id,
|
|
left_time: this.buff_list[i].left_time,
|
|
lasting_time: this.buff_list[i].lasting_time,
|
|
}, this, 1)
|
|
|
|
this.buff_list.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
this.hurttime += dt
|
|
if (this.hurttime > 1) {
|
|
var dx = gas.pos_old.x - this.pos.x
|
|
var dy = gas.pos_old.y - this.pos.y
|
|
if (dx * dx + dy * dy > gas.rad_old * gas.rad_old) {
|
|
this.hurt(gas.hurt, -1)
|
|
|
|
}
|
|
this.hurttime = 0
|
|
}
|
|
|
|
|
|
}
|
|
this.setcfg = function(cfg) {
|
|
this.isrole = true
|
|
this.max_health = this.health = playerconfig.health
|
|
this.energy_shield = cfg.energy_shield
|
|
this.setskin([1, 0, 0, 0])
|
|
this.setitems([{
|
|
key: 30703,
|
|
value: 5
|
|
}])
|
|
this.doprepar(cfg.prepare_items)
|
|
console.log("测试数据555====", cfg);
|
|
|
|
var s1 = cfg.skill_list[0].key
|
|
var s2 = cfg.skill_list[1].key
|
|
this.skill_list = [{
|
|
skill_id: s1,
|
|
left_time: 0, //skillConfig[s1].skill_cd * 1000,
|
|
cd_time: skillConfig[s1].skill_cd * 1000,
|
|
max_times: 1,
|
|
curr_times: 0,
|
|
}, {
|
|
skill_id: s2,
|
|
left_time: 0, //skillConfig[s2].skill_cd * 1000,
|
|
cd_time: skillConfig[s2].skill_cd * 1000,
|
|
max_times: 1,
|
|
curr_times: 0,
|
|
}]
|
|
|
|
|
|
this.vip_lv = cfg.vip_lv
|
|
this.head = cfg.head
|
|
this.user_data = cfg.user_data
|
|
|
|
if (cfg.weapons && cfg.weapons.length > 0) {
|
|
if (!cfg.weapons[0].weapon_id) {
|
|
return
|
|
}
|
|
if (!gameConfig.dropItemConfig[cfg.weapons[0].weapon_id]) {
|
|
return
|
|
}
|
|
this.weapons[1].weapon_id = cfg.weapons[0].weapon_id
|
|
this.weapons[1].weapon_lv = cfg.weapons[0].weapon_lv
|
|
|
|
if (cfg.weapons[1] && cfg.weapons[1].weapon_id && gameConfig.dropItemConfig[cfg.weapons[1].weapon_id]) {
|
|
this.weapons[2].weapon_id = cfg.weapons[1].weapon_id
|
|
this.weapons[2].weapon_lv = cfg.weapons[1].weapon_lv
|
|
this.changeweapon(2, true)
|
|
}
|
|
|
|
// this.spweapon = cfg.weapons[0].weapon_id
|
|
// this.spammo = cfg.weapons[0].ammo
|
|
// this.splv = cfg.weapons[0].weapon_lv
|
|
|
|
this.changeweapon(1, true)
|
|
}
|
|
|
|
}
|
|
this.doprepar = function(v) {
|
|
var widx = 0
|
|
for (var i = v.length - 1; i >= 0; i--) {
|
|
var eid = v[i]
|
|
var data = dropItemConfig[eid]
|
|
if (!data) {
|
|
continue
|
|
}
|
|
if (data.equip_type == 1 && data.equip_subtype == 1) {
|
|
this.weapons[0].weapon_id = eid
|
|
} else if (data.equip_type == 1) {
|
|
this.weapons[1].weapon_id = eid
|
|
widx = 1
|
|
} else if (data.equip_type == 9) {
|
|
this.addbuff(data.buffid)
|
|
} else if (data.equip_type == 3) {
|
|
if (data.equip_subtype == 2) {
|
|
if (this.getitem(5)) {
|
|
this.weapons[3].weapon_id = data.id
|
|
this.weapons[3].ammo = 1
|
|
|
|
}
|
|
} else {
|
|
if (this.getitem(6)) {
|
|
this.weapons[4].weapon_id = data.id
|
|
this.weapons[4].ammo = 1
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.changeweapon(widx)
|
|
|
|
}
|
|
this.robot = function(gunid) {
|
|
this.inventory[1] = this.inventory[2] = this.inventory[3] = 9999
|
|
|
|
|
|
this.thinktime = 0
|
|
this.sleeptime = 0
|
|
this.isrole = false
|
|
var gid = Utils.randintSeed(6) + 12108
|
|
if (gunid) {
|
|
gid = gunid
|
|
}
|
|
this.weapons[1].weapon_id = gid
|
|
this.setskin([Utils.randintSeed(4), 13001 + Utils.randintSeed(6), 15001 + Utils.randintSeed(6), 0])
|
|
this.changeweapon(1, true)
|
|
|
|
|
|
// this.rx = Utils.randintSeed(100)-50
|
|
// this.ry = Utils.randintSeed(100)-50
|
|
this.inventory[7] = 1
|
|
}
|
|
this.setaicfg = function(data) {
|
|
if (data && AIConfig[data]) {
|
|
this.aicfg = new robotai()
|
|
this.aicfg.setaicfg(data, this)
|
|
if (deadConfig[data]) {
|
|
this.deadcfg = deadConfig[data]
|
|
}
|
|
if (dressConfig[data]) {
|
|
this.setskin(dressConfig[data])
|
|
}
|
|
|
|
|
|
} else {
|
|
this.aicfg = null
|
|
}
|
|
|
|
}
|
|
this.dopause = function(time) {
|
|
this.shot_hold = false
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
this.pausetime = time
|
|
}
|
|
this.ai = function(dt) {
|
|
if (this.isrole || this.dead) {
|
|
return
|
|
}
|
|
if (this.aicfg) {
|
|
var isover = this.aicfg.update(dt)
|
|
if (isover) {
|
|
this.aicfg = null
|
|
}
|
|
return
|
|
}
|
|
if (this.ismember) {
|
|
this.thinktime -= dt
|
|
if (this.thinktime <= 0) {
|
|
this.thinktime = 3
|
|
|
|
if (Utils.randintSeed(100) > 50) {
|
|
TempV.x = cc.clientbattle.player.x - this.pos.x + Utils.randintSeed(200) - 100
|
|
TempV.y = cc.clientbattle.player.y - this.pos.y + Utils.randintSeed(200) - 100
|
|
this.move_dir = TempV.normalize();
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
this.shot_hold = false
|
|
|
|
} else {
|
|
var temp = []
|
|
for (var i = cc.clientbattle.playerarr.length - 1; i >= 0; i--) {
|
|
var onep = cc.clientbattle.playerarr[i]
|
|
if (!onep.dead && !onep.ismember && !onep.isrole) {
|
|
temp.push(onep)
|
|
}
|
|
}
|
|
if (temp.length > 0) {
|
|
TempV.x = temp[0].x - this.pos.x + Utils.randintSeed(100) - 50
|
|
TempV.y = temp[0].y - this.pos.y + Utils.randintSeed(100) - 50
|
|
this.attack_dir = TempV.normalize();
|
|
this.dir.x = this.attack_dir.x
|
|
this.dir.y = this.attack_dir.y
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.shot_hold = true
|
|
this.thinktime = 1
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
}
|
|
|
|
|
|
if (this.sleeptime > 0) {
|
|
this.sleeptime -= dt
|
|
if (this.sleeptime <= 0) {
|
|
this.showEmoteNetAnimation(1)
|
|
}
|
|
return
|
|
}
|
|
|
|
var dx = Math.abs(this.pos.x - cc.clientbattle.player.x)
|
|
var dy = Math.abs(this.pos.y - cc.clientbattle.player.y)
|
|
var shiyewai = false
|
|
if (dx > 512 || dy > 512) {
|
|
shiyewai = true
|
|
this.notpz = true
|
|
} else {
|
|
this.notpz = false
|
|
}
|
|
|
|
|
|
|
|
this.thinktime -= dt
|
|
if (this.thinktime <= 0) {
|
|
this.thinktime = 3
|
|
|
|
if (shiyewai) {
|
|
TempV.x = cc.clientbattle.player.x - this.pos.x
|
|
TempV.y = cc.clientbattle.player.y - this.pos.y
|
|
this.move_dir = TempV.normalize();
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
this.shot_hold = false
|
|
this.thinktime = 1
|
|
return
|
|
}
|
|
|
|
|
|
if (Utils.randintSeed(100) > 40) {
|
|
TempV.x = cc.clientbattle.player.x - this.pos.x + Utils.randintSeed(100) - 50
|
|
TempV.y = cc.clientbattle.player.y - this.pos.y + Utils.randintSeed(100) - 50
|
|
|
|
if (dx > 100 || dy > 100) {
|
|
this.move_dir = TempV.normalize();
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
this.shot_hold = false
|
|
|
|
var objs = cc.clientbattle.getpzobjs({
|
|
x: this.pos.x,
|
|
y: this.pos.y,
|
|
width: this.width * 4,
|
|
height: this.height * 4
|
|
})
|
|
for (var i = objs.length - 1; i >= 0; i--) {
|
|
var obj = objs[i]
|
|
if (obj.loot) {
|
|
if (obj.loot.dead || obj.loot.event) {
|
|
continue
|
|
}
|
|
}
|
|
var pobj = {
|
|
x: obj.xx,
|
|
y: obj.yy,
|
|
width: obj.width,
|
|
height: obj.height,
|
|
}
|
|
var size = movesize
|
|
// if (!obj.loot) {
|
|
// size = playersize * 1.5
|
|
// }
|
|
|
|
if (Utils.hitTestRectangle(pobj, {
|
|
x: this.pos.x,
|
|
y: this.pos.y + movepy,
|
|
width: size,
|
|
height: size
|
|
})) {
|
|
this.pos.x += (-this.dir.x * (50 + Utils.randintSeed(100)))
|
|
this.pos.y += (-this.dir.y * (50 + Utils.randintSeed(100)))
|
|
this.x = this.pos.x
|
|
this.y = this.pos.y
|
|
break
|
|
}
|
|
}
|
|
|
|
this.thinktime = 2
|
|
if (Utils.randintSeed(100) > 70) {
|
|
this.attack_dir.x = this.move_dir.x
|
|
this.attack_dir.y = this.move_dir.y
|
|
this.shot_hold = true
|
|
this.thinktime = 1
|
|
}
|
|
|
|
} else {
|
|
this.attack_dir = TempV.normalize();
|
|
this.dir.x = this.attack_dir.x
|
|
this.dir.y = this.attack_dir.y
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.shot_hold = true
|
|
this.thinktime = 2
|
|
}
|
|
|
|
} else {
|
|
this.shot_hold = false
|
|
var rd = Utils.randintSeed(100)
|
|
if (rd > 90) {
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.sleeptime = 0.5
|
|
this.thinktime = 1
|
|
} else if (false && this.skill_left_time <= 0) {
|
|
this.addbuff(1002)
|
|
this.movev(this.dir, 100)
|
|
this.thinktime = 2
|
|
} else if (rd > 70 && this.health / this.max_health < 0.5 && this.inventory[7] > 0) {
|
|
this.inventory[7]--;
|
|
TempV.x = cc.clientbattle.player.x - this.pos.x
|
|
TempV.y = cc.clientbattle.player.y - this.pos.y
|
|
this.move_dir = TempV.normalize();
|
|
this.move_dir.x = -this.move_dir.x
|
|
this.move_dir.y = -this.move_dir.y
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
|
|
this.yaoidx = 7
|
|
this.doheal(30301)
|
|
|
|
|
|
|
|
} else if (rd > 60) {
|
|
this.move_dir.x = this.move_dir.y = 0
|
|
this.thinktime = 1
|
|
} else if (rd > 30) {
|
|
TempV.x = cc.clientbattle.player.x - this.pos.x
|
|
TempV.y = cc.clientbattle.player.y - this.pos.y
|
|
this.move_dir = TempV.normalize();
|
|
this.dir.x = this.move_dir.x
|
|
this.dir.y = this.move_dir.y
|
|
this.attack_dir.x = this.dir.x
|
|
this.attack_dir.y = this.dir.y
|
|
this.move_dir.x = -this.move_dir.x
|
|
this.move_dir.y = -this.move_dir.y
|
|
this.shot_hold = true
|
|
if (Utils.randintSeed(100) > 70) {
|
|
this.showEmoteNetAnimation(1)
|
|
}
|
|
this.thinktime = 2
|
|
} else {
|
|
var dir = cc.v2(0, 1)
|
|
dir = Utils.dirRotate(dir, Utils.randintSeed(360) * dtoh)
|
|
this.move_dir.x = dir.x
|
|
this.move_dir.y = dir.y
|
|
this.dir.x = dir.x
|
|
this.dir.y = dir.y
|
|
this.thinktime = 1
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
module.exports = playerobj; |