Jump to content
Sign in to follow this  
TMF-Rex

Activate a common event when hitting an enemy

Recommended Posts

So I'm looking to have a passive that one of my actors always has, a state that gets stronger every time you hit an enemy until a certain point, then caps.  The state also goes away when you miss an enemy.  I think I've got the event and state figured out, but I'm having issues triggering the event.  Anybody have any ideas?

Share this post


Link to post
Share on other sites

This may require scripting. It's probably doable thru events but it'd be messy and clunky.

Share this post


Link to post
Share on other sites

Moved it to script requests for you

Share this post


Link to post
Share on other sites

I have five different states that I have created.  Each state is more powerful than the last.  What the event does is it looks to see what stage has been achieved through a bunch of conditional branches.  When it figures out which state the actor has, it will remove that state and give the one that is the next stage up.

 

Here's a picture if it'll make more sense

 

cstateeric.jpg

 

The states are also set up to expire after one turn, so a miss will basically remove the state.

 

Again, I just need to be able to trigger the event in order for the ability to work

Share this post


Link to post
Share on other sites

I could be wrong but isnt it possible to link common events through spells via database? If true, why not just make it a "technique" that uses no tp? Maybe make the first stage or two of it a little weaker to add a pros and cons aspect to it. Again, im not sure if you can make spells have common events but i had to say something. The bump fest was too painfull to pass by.

Share this post


Link to post
Share on other sites

^^^ I also felt compelled to do something so I wrote this :P:

 

module CommonEventOnHitKal
  
  TAG_NAME = "ceoh"
  
  class IDExtractor
    def get_common_event_id_for(user)
      rpg_actor = $data_actors[user.id]
      extract_common_event_id(rpg_actor.note)
    end
    
    private

    def extract_common_event_id(note)
      id = note[/<#{TAG_NAME}\s+(\d+)\s*>/, 1]
      id.nil? ? nil : id.to_i
    end
  end
  
  class CommonEventRunner
    def run(common_event_id)
      page = make_page(common_event_id)
      $game_troop.interpreter.setup(page.list)
    end
    
    private
    
    def make_page(id)
      page = RPG::Troop::Page.new
      # 117 => common event code, 0 => indent, id => id of common event
      page.list.unshift(RPG::EventCommand.new(117, 0, [id]))
      page
    end
  end
  
  @id_extractor = IDExtractor.new
  @common_event_runner = CommonEventRunner.new
    
  def self.run_event_for(user)
    event_id = @id_extractor.get_common_event_id_for(user)
    @common_event_runner.run(event_id) if event_id
  end
end

class Game_Battler

  alias_method :item_apply_ceoh_kal, :item_apply
  def item_apply(user, item)
    item_apply_ceoh_kal(user, item)

    # item id 1 is Attack
    if user.is_a?(Game_Actor) && item.id == 1 && @result.hit?
      CommonEventOnHitKal.run_event_for(user)
    end
  end
end 

Actually this is a variation of this request by Kcaz64 http://www.rpgmakervxace.net/topic/16007-common-event-when-state-ends-is-removed/

So maybe a more general script that can run common events in many different situations would be useful?

 

To use this script create a tag in the actor's note box like this:

 

<ceoh 4>
 

"ceoh" is the name of the tag (you can change this in the script if you want) and the number is the id of the common event that should run when the actor hits with the Attack skill.

Share this post


Link to post
Share on other sites

@polidoro - That is possible, the thing is I wanted it to be used as the basic attack of a single character, so I would have to get scripting to check who was attacking, but thanks anyway :)

 

@kal - The script works like a charm.  I did have to tweak my event a bit, but it works just the way I envisioned it.  Thanks buddy :)

 

Big thanks to everyone who helped out.  I've gotten the exact solution I was looking for, so this thread can be locked.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted