Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> [RESOLVED] Yerd_TargetEffects support please!
Guyver's Bane
post Mar 25 2012, 03:15 PM
Post #1


The Guiding Light
Group Icon

Group: Revolutionary
Posts: 801
Type: Event Designer
RM Skill: Masterful




It's been awhile since i posted a new topic and it figures it would be for support lol. Well here's my problem:

This following script piece is a custom targeting choice i was given support on (i cant remember who from )and what it does is target enemies of the same id only. What i'm wondering is if theres a way to make target two random enemies of the same id?
Thanks to anyone who helps me out and credit will be given!

CODE
when 3 # target a group
      return if @target_index == -1 # target index not valid
      ptarg = opponents_unit.members[@target_index] # get potential target
      return if ptarg.nil? # potential target is out of range (should not happen)
      type = opponents_unit.existing_members.find{|member| member.is_a?(Game_Enemy) ? member.enemy_id == ptarg.enemy_id : member == ptarg }
      # find first living battler of the selected type
      type ||= opponents_unit.smooth_target(@target_index)
      # if the type was not found, get another group      
      if type.is_a?(Game_Enemy) # if enemy
        opponents_unit.existing_members.each {|enemy|
        selected.push(enemy) if enemy.enemy_id == type.enemy_id target# target all enemies of this id
        }
      elsif type.is_a?(Game_Actor) # if actor
        selected.push(type) # target 'this actor' only
      end
      # if type points to nil, no targets are added


This post has been edited by Guyver's Bane: Apr 8 2012, 07:04 AM


__________________________
Characters:

"damned shitty highjacked internet"

Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Night_Runner
post Apr 3 2012, 05:52 AM
Post #2


Level 50
Group Icon

Group: +Gold Member
Posts: 1,520
Type: Scripter
RM Skill: Undisclosed




From what I understand of the code it should automatically select all enemies of the correct ID.
So I'm guessing that this request is to limit it, so the script only targets 2 enemies of the correct ID (selected at random), not all of them?

Fingers crossed, something like this should work for you:
CODE
when 3 # target a group
      return if @target_index == -1 # target index not valid
      ptarg = opponents_unit.members[@target_index] # get potential target
      return if ptarg.nil? # potential target is out of range (should not happen)
      type =
        opponents_unit.existing_members.find { |member|
          if member.is_a?(Game_Enemy) ? member.enemy_id == ptarg.enemy_id : member == ptarg
        }
      # find first living battler of the selected type
      type ||= opponents_unit.smooth_target(@target_index)
      # if the type was not found, get another group      
      if type.is_a?(Game_Enemy) # if enemy
        possible_enemies = []
        opponents_unit.existing_members.each {|enemy|
          possible_enemies.push(enemy) if enemy.enemy_id == type.enemy_id target# target all enemies of this id
        }
        selected.push( possible_enemies.map { |each| [each, Random.rand(100)] }.sort { |a,b|­ a[1]<=>b[1] }[0..1].map { |each| each[0] } )
      elsif type.is_a?(Game_Actor) # if actor
        selected.push(type) # target 'this actor' only
      end
      # if type points to nil, no targets are added

Otherwise I would have to ask for a demo, so I could properly debug it, without having to waste your time sending it to you to test each attempt.


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   

Posts in this topic


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 20th May 2013 - 03:47 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker