设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1199|回复: 1
打印 上一主题 下一主题

[已经解决] 关于攻击两名敌人

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
129 小时
注册时间
2011-9-19
帖子
42
跳转到指定楼层
1
发表于 2012-1-28 23:34:19 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
有能攻击两名敌人或者三名敌人的脚本吗,就好像大话西游里仙族秒3秒4秒5,人族混3混4混5这样的

Lv3.寻梦者

梦石
0
星屑
3668
在线时间
3077 小时
注册时间
2011-11-17
帖子
980
2
发表于 2012-1-28 23:51:53 | 只看该作者
  1. class Scene_Battle
  2. #------------------------------------
  3. # ● 设置物品或特技对像方的战斗者
  4. # scope : 特技或者是物品的范围
  5. #------------------------------------
  6. def set_target_battlers(scope)
  7. # 行动方的战斗者是敌人的情况下
  8. if @active_battler.is_a?(Game_Enemy)
  9. # 效果范围分支
  10. case scope
  11. when 1 # 敌单体
  12. index = @active_battler.current_action.target_index
  13. @target_battlers.push($game_party.smooth_target_actor(index))
  14. dr_ac
  15. when 2 # 敌全体
  16. for actor in $game_party.actors
  17. if actor.exist?
  18. @target_battlers.push(actor)
  19. end
  20. end
  21. when 3 # 我方单体
  22. index = @active_battler.current_action.target_index
  23. @target_battlers.push($game_troop.smooth_target_enemy(index))
  24. dr_dr
  25. when 4 # 我方全体
  26. for enemy in $game_troop.enemies
  27. if enemy.exist?
  28. @target_battlers.push(enemy)
  29. end
  30. end
  31. when 5 # 我方单体 (HP 0)
  32. index = @active_battler.current_action.target_index
  33. enemy = $game_troop.enemies[index]
  34. if enemy != nil and enemy.hp0?
  35. @target_battlers.push(enemy)
  36. end
  37. when 6 # 我方全体 (HP 0)
  38. for enemy in $game_troop.enemies
  39. if enemy != nil and enemy.hp0?
  40. @target_battlers.push(enemy)
  41. end
  42. end
  43. when 7 # 使用者
  44. @target_battlers.push(@active_battler)
  45. end
  46. end
  47. # 行动方的战斗者是角色的情况下
  48. if @active_battler.is_a?(Game_Actor)
  49. # 效果范围分支
  50. case scope
  51. when 1 # 敌单体
  52. index = @active_battler.current_action.target_index
  53. @target_battlers.push($game_troop.smooth_target_enemy(index))
  54. ac_dr
  55. when 2 # 敌全体
  56. for enemy in $game_troop.enemies
  57. if enemy.exist?
  58. @target_battlers.push(enemy)
  59. end
  60. end
  61. when 3 # 我方单体
  62. index = @active_battler.current_action.target_index
  63. @target_battlers.push($game_party.smooth_target_actor(index))
  64. ac_ac
  65. when 4 # 我方全体
  66. for actor in $game_party.actors
  67. if actor.exist?
  68. @target_battlers.push(actor)
  69. end
  70. end
  71. when 5 # 我方单体 (HP 0)
  72. index = @active_battler.current_action.target_index
  73. actor = $game_party.actors[index]
  74. if actor != nil and actor.hp0?
  75. @target_battlers.push(actor)
  76. end
  77. when 6 # 我方全体 (HP 0)
  78. for actor in $game_party.actors
  79. if actor != nil and actor.hp0?
  80. @target_battlers.push(actor)
  81. end
  82. end
  83. when 7 # 使用者
  84. @target_battlers.push(@active_battler)
  85. end
  86. end
  87. end
  88. end
  89. module RPG
  90. class Sprite < ::Sprite
  91. @@_animations = []
  92. @@_reference_count = {}
  93. def initialize(viewport = nil)
  94. super(viewport)
  95. @_whiten_duration = 0
  96. @_appear_duration = 0
  97. @_escape_duration = 0
  98. @_collapse_duration = 0
  99. @_damage_duration = 0
  100. @_animation_duration = 0
  101. @_blink = false
  102. end
  103. def dispose
  104. dispose_damage
  105. dispose_animation
  106. dispose_loop_animation
  107. super
  108. end
  109. def xiaoshi=(xiaoshi)
  110. @xiaoshi = xiaoshi
  111. return @xiaoshi
  112. end
  113. def xiaoshi
  114. return @xiaoshi
  115. end
  116. def whiten
  117. self.blend_type = 0
  118. self.color.set(255, 255, 255, 128)
  119. self.opacity = 255
  120. @_whiten_duration = 16
  121. @_appear_duration = 0
  122. @_escape_duration = 0
  123. @_collapse_duration = 0
  124. end
  125. def appear
  126. self.blend_type = 0
  127. self.color.set(0, 0, 0, 0)
  128. self.opacity = 0
  129. @_appear_duration = 16
  130. @_whiten_duration = 0
  131. @_escape_duration = 0
  132. @_collapse_duration = 0
  133. end
  134. def escape
  135. self.blend_type = 0
  136. self.color.set(0, 0, 0, 0)
  137. self.opacity = 255
  138. @_escape_duration = 32
  139. @_whiten_duration = 0
  140. @_appear_duration = 0
  141. @_collapse_duration = 0
  142. end
  143. def collapse
  144. self.blend_type = 1
  145. self.color.set(255, 64, 64, 255)
  146. self.opacity = 255
  147. @_collapse_duration = 48
  148. @_whiten_duration = 0
  149. @_appear_duration = 0
  150. @_escape_duration = 0
  151. end
  152. def animation(animation, hit)
  153. dispose_animation
  154. @_animation = animation
  155. return if @_animation == nil
  156. @_animation_hit = hit
  157. @_animation_duration = @_animation.frame_max
  158. animation_name = @_animation.animation_name
  159. animation_hue = @_animation.animation_hue
  160. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  161. if @@_reference_count.include?(bitmap)
  162. @@_reference_count[bitmap] += 1
  163. else
  164. @@_reference_count[bitmap] = 1
  165. end
  166. @_animation_sprites = []
  167. if @_animation.position != 3 or not @@_animations.include?(animation)
  168. for i in 0..15
  169. sprite = ::Sprite.new(self.viewport)
  170. sprite.bitmap = bitmap
  171. sprite.visible = false
  172. @_animation_sprites.push(sprite)
  173. end
  174. unless @@_animations.include?(animation)
  175. @@_animations.push(animation)
  176. end
  177. end
  178. update_animation
  179. end
  180. def loop_animation(animation)
  181. return if animation == @_loop_animation
  182. dispose_loop_animation
  183. @_loop_animation = animation
  184. return if @_loop_animation == nil
  185. @_loop_animation_index = 0
  186. animation_name = @_loop_animation.animation_name
  187. animation_hue = @_loop_animation.animation_hue
  188. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  189. if @@_reference_count.include?(bitmap)
  190. @@_reference_count[bitmap] += 1
  191. else
  192. @@_reference_count[bitmap] = 1
  193. end
  194. @_loop_animation_sprites = []
  195. for i in 0..15
  196. sprite = ::Sprite.new(self.viewport)
  197. sprite.bitmap = bitmap
  198. sprite.visible = false
  199. @_loop_animation_sprites.push(sprite)
  200. end
  201. update_loop_animation
  202. end
  203. def dispose_damage
  204. if @_damage_sprite != nil
  205. @_damage_sprite.bitmap.dispose
  206. @_damage_sprite.dispose
  207. @_damage_sprite = nil
  208. @_damage_duration = 0
  209. end
  210. end
  211. def dispose_animation
  212. if @_animation_sprites != nil
  213. sprite = @_animation_sprites[0]
  214. if sprite != nil
  215. @@_reference_count[sprite.bitmap] -= 1
  216. if @@_reference_count[sprite.bitmap] == 0
  217. sprite.bitmap.dispose
  218. end
  219. end
  220. for sprite in @_animation_sprites
  221. sprite.dispose
  222. end
  223. @_animation_sprites = nil
  224. @_animation = nil
  225. end
  226. end
  227. def dispose_loop_animation
  228. if @_loop_animation_sprites != nil
  229. sprite = @_loop_animation_sprites[0]
  230. if sprite != nil
  231. @@_reference_count[sprite.bitmap] -= 1
  232. if @@_reference_count[sprite.bitmap] == 0
  233. sprite.bitmap.dispose
  234. end
  235. end
  236. for sprite in @_loop_animation_sprites
  237. sprite.dispose
  238. end
  239. @_loop_animation_sprites = nil
  240. @_loop_animation = nil
  241. end
  242. end
  243. def blink_on
  244. unless @_blink
  245. @_blink = true
  246. @_blink_count = 0
  247. end
  248. end
  249. def blink_off
  250. if @_blink
  251. @_blink = false
  252. self.color.set(0, 0, 0, 0)
  253. end
  254. end
  255. def blink?
  256. @_blink
  257. end
  258. def effect?
  259. @_whiten_duration > 0 or
  260. @_appear_duration > 0 or
  261. @_escape_duration > 0 or
  262. @_collapse_duration > 0 or
  263. @_damage_duration > 0 or
  264. @_animation_duration > 0
  265. end
  266. def update
  267. super
  268. if @_whiten_duration > 0
  269. @_whiten_duration -= 1
  270. self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  271. end
  272. if @_appear_duration > 0
  273. @_appear_duration -= 1
  274. self.opacity = (16 - @_appear_duration) * 16
  275. end
  276. if @_escape_duration > 0
  277. @_escape_duration -= 1
  278. self.opacity = 256 - (32 - @_escape_duration) * 10
  279. end
  280. if @_collapse_duration > 0
  281. @_collapse_duration -= 1
  282. self.opacity = 256 - (48 - @_collapse_duration) * 6
  283. end
  284. if @_damage_duration > 0
  285. @_damage_duration -= 1
  286. case @_damage_duration
  287. when 38..39
  288. @_damage_sprite.y -= 4
  289. when 36..37
  290. @_damage_sprite.y -= 2
  291. when 34..35
  292. @_damage_sprite.y += 2
  293. when 28..33
  294. @_damage_sprite.y += 4
  295. end
  296. @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  297. if @_damage_duration == 0
  298. dispose_damage
  299. end
  300. end
  301. if @_animation != nil and (Graphics.frame_count % 2 == 0)
  302. @_animation_duration -= 1
  303. update_animation
  304. end
  305. if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  306. update_loop_animation
  307. @_loop_animation_index += 1
  308. @_loop_animation_index %= @_loop_animation.frame_max
  309. end
  310. if @_blink
  311. @_blink_count = (@_blink_count + 1) % 32
  312. if @_blink_count < 16
  313. alpha = (16 - @_blink_count) * 6
  314. else
  315. alpha = (@_blink_count - 16) * 6
  316. end
  317. self.color.set(255, 255, 255, alpha)
  318. end
  319. @@_animations.clear
  320. end
  321. def update_animation
  322. if @_animation_duration > 0
  323. frame_index = @_animation.frame_max - @_animation_duration
  324. cell_data = @_animation.frames[frame_index].cell_data
  325. position = @_animation.position
  326. animation_set_sprites(@_animation_sprites, cell_data, position)
  327. for timing in @_animation.timings
  328. if timing.frame == frame_index
  329. animation_process_timing(timing, @_animation_hit)
  330. end
  331. end
  332. else
  333. dispose_animation
  334. end
  335. end
  336. def update_loop_animation
  337. if @xiaoshi2 != nil and @xiaoshi2 > 0
  338. @xiaoshi2 -= 1
  339. frame_index = @_loop_animation_index
  340. cell_data = @_loop_animation.frames[frame_index].cell_data
  341. position = @_loop_animation.position
  342. animation_set_sprites(@_loop_animation_sprites, cell_data, position,true)

  343. else
  344. frame_index = @_loop_animation_index
  345. cell_data = @_loop_animation.frames[frame_index].cell_data
  346. position = @_loop_animation.position
  347. animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  348. for timing in @_loop_animation.timings
  349. if timing.frame == frame_index
  350. animation_process_timing(timing, true)
  351. end
  352. end
  353. end
  354. end
  355. def animation_set_sprites(sprites, cell_data, position,kds = false)

  356. if kds
  357. for i in 0..15
  358. sprites[i].visible = false
  359. end
  360. return
  361. end


  362. for i in 0..15
  363. sprite = sprites[i]
  364. pattern = cell_data[i, 0]
  365. if sprite == nil or pattern == nil or pattern == -1
  366. sprite.visible = false if sprite != nil
  367. next
  368. end
  369. sprite.visible = true
  370. sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  371. if position == 3
  372. if self.viewport != nil
  373. sprite.x = self.viewport.rect.width / 2
  374. sprite.y = self.viewport.rect.height - 160
  375. else
  376. sprite.x = 320
  377. sprite.y = 240
  378. end
  379. else
  380. sprite.x = self.x - self.ox + self.src_rect.width / 2
  381. sprite.y = self.y - self.oy + self.src_rect.height / 2
  382. sprite.y -= self.src_rect.height / 4 if position == 0
  383. sprite.y += self.src_rect.height / 4 if position == 2
  384. end
  385. sprite.x += cell_data[i, 1]
  386. sprite.y += cell_data[i, 2]
  387. sprite.z = self.z#2000
  388. sprite.ox = 96
  389. sprite.oy = 96
  390. sprite.zoom_x = cell_data[i, 3] / 100.0
  391. sprite.zoom_y = cell_data[i, 3] / 100.0
  392. sprite.angle = cell_data[i, 4]
  393. sprite.mirror = (cell_data[i, 5] == 1)
  394. sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  395. sprite.blend_type = cell_data[i, 7]
  396. end
  397. end
  398. def animation_process_timing(timing, hit)

  399. if (timing.condition == 0) or
  400. (timing.condition == 1 and hit == true) or
  401. (timing.condition == 2 and hit == false)
  402. if timing.se.name != ""
  403. se = timing.se
  404. Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  405. end
  406. case timing.flash_scope
  407. when 1
  408. self.flash(timing.flash_color, timing.flash_duration * 2)
  409. when 2
  410. if self.viewport != nil
  411. self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  412. end
  413. when 3
  414. self.flash(nil, timing.flash_duration * 2)
  415. @xiaoshi2 = timing.flash_duration
  416. @xiaoshi = timing.flash_duration

  417. end
  418. end
  419. end
  420. def x=(x)
  421. sx = x - self.x
  422. if sx != 0
  423. if @_animation_sprites != nil
  424. for i in 0..15
  425. @_animation_sprites[i].x += sx
  426. end
  427. end
  428. if @_loop_animation_sprites != nil
  429. for i in 0..15
  430. @_loop_animation_sprites[i].x += sx
  431. end
  432. end
  433. end
  434. super
  435. end
  436. def y=(y)
  437. sy = y - self.y
  438. if sy != 0
  439. if @_animation_sprites != nil
  440. for i in 0..15
  441. @_animation_sprites[i].y += sy
  442. end
  443. end
  444. if @_loop_animation_sprites != nil
  445. for i in 0..15
  446. @_loop_animation_sprites[i].y += sy
  447. end
  448. end
  449. end
  450. super
  451. end
  452. end
  453. end

  454. module RPG
  455. class Skill
  456. def name
  457. name = @name.split(/◆/)[0]
  458. return name != nil ? name : ""
  459. end
  460. def kds_miao
  461. name = @name.split(/◆/)[1]
  462. return name != nil ? name.to_i.abs : 0
  463. end
  464. end
  465. end
  466. class Scene_Battle
  467. def tg_xiuzheng(s)
  468. for kds_dui in $data_skills[@active_battler.current_action.skill_id].plus_state_set
  469. if $game_party.smooth_target_actor(s).states.include?(kds_dui)
  470. return true
  471. end
  472. end
  473. return false
  474. end
  475. def tg_xiuzheng2(s)
  476. for kds_dui in $data_skills[@active_battler.current_action.skill_id].plus_state_set
  477. if $game_troop.smooth_target_enemy(s).states.include?(kds_dui)
  478. return true
  479. end
  480. end
  481. return false
  482. end
  483. def dr_ac
  484. index = @active_battler.current_action.target_index
  485. $miao = 1
  486. if @active_battler.current_action.kind == 1
  487. @skill = $data_skills[@active_battler.current_action.skill_id]
  488. if $data_skills[@skill.id].kds_miao > 1
  489. @sudu = []
  490. @guang = []
  491. for s in 0..$game_party.actors.size-1
  492. if $game_party.actors[s].hp != 0
  493. @sudu.push($game_party.smooth_target_actor(s).agi)
  494. @guang.push(s)
  495. end
  496. end
  497. for a in [email protected]
  498. for s in [email protected]
  499. if s < @sudu.size-1 and @sudu[s] < @sudu[s+1]
  500. elsif s < @sudu.size-1 and @sudu[s] > @sudu[s+1]
  501. @abc = @sudu[s]
  502. @sudu[s] = @sudu[s+1]
  503. @sudu[s+1] = @abc
  504. @bcd = @guang[s]
  505. @guang[s] = @guang[s+1]
  506. @guang[s+1] = @bcd
  507. end
  508. end
  509. end
  510. for s in [email protected]
  511. if @guang[@sudu.size-1-s] == index
  512. else
  513. $miao += 1
  514. @target_battlers.push($game_party.smooth_target_actor(@guang[@sudu.size-1 - s]))
  515. end
  516. if $miao == $data_skills[@skill.id].kds_miao
  517. break
  518. end
  519. end
  520. end
  521. end
  522. end
  523. def dr_dr
  524. index = @active_battler.current_action.target_index
  525. $miao = 1
  526. if @active_battler.current_action.kind == 1
  527. @skill = $data_skills[@active_battler.current_action.skill_id]
  528. if $data_skills[@skill.id].kds_miao > 1
  529. @sudu = []
  530. @guang = []
  531. for s in 0..$game_troop.enemies.size-1
  532. if $game_troop.enemies[s].hp != 0 and @active_battler.current_action.kind == 1 and tg_xiuzheng2(s) == false
  533. @sudu.push($game_troop.smooth_target_enemy(s).agi)
  534. @guang.push(s)
  535. end
  536. end
  537. for a in [email protected]
  538. for s in [email protected]
  539. if s < @sudu.size-1 and @sudu[s] < @sudu[s+1]
  540. elsif s < @sudu.size-1 and @sudu[s] > @sudu[s+1]
  541. @abc = @sudu[s]
  542. @sudu[s] = @sudu[s+1]
  543. @sudu[s+1] = @abc
  544. @bcd = @guang[s]
  545. @guang[s] = @guang[s+1]
  546. @guang[s+1] = @bcd
  547. end
  548. end
  549. end
  550. for s in [email protected]
  551. if @guang[@sudu.size-1-s] == index
  552. else
  553. $miao += 1
  554. @target_battlers.push($game_troop.smooth_target_enemy(@guang[@sudu.size-1 - s]))
  555. end
  556. if $miao == $data_skills[@skill.id].kds_miao
  557. break
  558. end
  559. end
  560. end
  561. end
  562. end
  563. def ac_dr
  564. index = @active_battler.current_action.target_index
  565. if @active_battler.current_action.kind == 1
  566. @skill = $data_skills[@active_battler.current_action.skill_id]
  567. $miao = 1
  568. if $data_skills[@skill.id].kds_miao > 1
  569. @sudu = []
  570. @guang = []
  571. for s in 0..$game_troop.enemies.size-1
  572. if $game_troop.enemies[s].hp != 0
  573. @sudu.push($game_troop.smooth_target_enemy(s).agi)
  574. @guang.push(s)
  575. end
  576. end
  577. for a in [email protected]
  578. for s in [email protected]
  579. if s < @sudu.size-1 and @sudu[s] < @sudu[s+1]
  580. elsif s < @sudu.size-1 and @sudu[s] > @sudu[s+1]
  581. @abc = @sudu[s]
  582. @sudu[s] = @sudu[s+1]
  583. @sudu[s+1] = @abc
  584. @bcd = @guang[s]
  585. @guang[s] = @guang[s+1]
  586. @guang[s+1] = @bcd
  587. end
  588. end
  589. end
  590. for s in [email protected]
  591. if @guang[@sudu.size-1-s] == index
  592. else
  593. $miao += 1
  594. @target_battlers.push($game_troop.smooth_target_enemy(@guang[@sudu.size-1 - s]))
  595. end
  596. if $miao == $data_skills[@skill.id].kds_miao
  597. break
  598. end
  599. end
  600. end
  601. end
  602. end
  603. def ac_ac
  604. index = @active_battler.current_action.target_index
  605. if @active_battler.current_action.kind == 1
  606. @skill = $data_skills[@active_battler.current_action.skill_id]
  607. $miao = 1
  608. if $data_skills[@skill.id].kds_miao > 1
  609. @sudu = []
  610. @guang = []
  611. for s in 0..$game_party.actors.size-1
  612. if $game_party.actors[s].hp != 0 and @active_battler.current_action.kind == 1 and tg_xiuzheng(s) == false
  613. @sudu.push($game_party.smooth_target_actor(s).agi)
  614. @guang.push(s)
  615. end
  616. end
  617. for a in [email protected]
  618. for s in [email protected]
  619. if s < @sudu.size-1 and @sudu[s] < @sudu[s+1]
  620. elsif s < @sudu.size-1 and @sudu[s] > @sudu[s+1]
  621. @abc = @sudu[s]
  622. @sudu[s] = @sudu[s+1]
  623. @sudu[s+1] = @abc
  624. @bcd = @guang[s]
  625. @guang[s] = @guang[s+1]
  626. @guang[s+1] = @bcd
  627. end
  628. end
  629. end
  630. for s in [email protected]
  631. if @guang[@sudu.size-1-s] == index
  632. else
  633. $miao += 1
  634. @target_battlers.push($game_party.smooth_target_actor(@guang[@sudu.size-1 - s]))
  635. end
  636. if $miao == $data_skills[@skill.id].kds_miao
  637. break
  638. end
  639. end
  640. end
  641. end
  642. end
  643. end
复制代码
使用方法 技能名后加◆XX XX代表攻击数量
比如火箭◆2 就是打2个敌人
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-5-25 15:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表