Attack from an enemy to a actor as condinitional branch
#1
First of all: Hi... Im new here in this forum and just signed in because i've a huge problem. Im using the rpg xp maker since 6 years but im a total noob in scripting.

I need a script query, so when a enemy troop with the id 1 attacks the actor with the id 17. I need this as a script in the condinational branch, so I can use it as an trigger in a battle.


What I mean is this: If monster 1 from the enemy troops (there can only be 8 enemies) attacks actor with the id 17 or uses a phy, skill or a magical skill against the actor with he id 17.
I need this as an script in the condinational branch.

I tried this one:
Code:
$game_troop.enemies[1].action.target_$game_actors[17]

Very important: The trigger should also happen when the user is attacked with magical, physicla skill or just normal attacks.

but it doesnt work at all.. I made this trigger, so that if this is triggered the actor 17 will use the skill fire.

I only get a nomethoderror. Undefined method action for nil class


Without this, I cant continue my projet...

Thanks in advance
Reply }
#2
have you tried using common events?
Reply }
#3
The enemy troop is a whole group of enemies, be it 1 or 8. Are you looking for a way to make a switch be turned on if player ID 17 is attacked by any enemy from Troop #1 ?

Sorta like?
Code:
if $game_troop.id == 1  #There's no such ID right now.
  for enemy in $game_troop.enemies
    target = enemy.target
    if target.is_a?(Game_Actor)
      $game_switches[4] = true if target.id == 17
    end
  end
end

This code is clearly conjecture, but is this what you're striving for? You cannot just make it in the script call of the Troops section. More likely, you'd need to add this into the Game_Battler class as well as a simple addition to the Scene_Battle system.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#4
He's clearly asking for a script that returns true when the first enemy of a troop attacks Actor 17. He's ALSO asking for it to be a "battle trigger" in an event, which I am pretty sure is not possible. Events can run at the start of a turn, or skills can call them.

If you can make it work, its
Code:
actorAt = -1
for i in 0..$game_party.actors.count
    if $game_party.actors[i] == $game_actors[17]
        actorAt = i
    end
end
return $game_troop.enemies[1].current_action.target_index == actorAt

good luck!
Reply }
#5
Question 
Hello guys. I dont know if you didint understand me correctly. I think mechinicalpen understood me.

Im a asking for a little script code which can be used as a trigger in a battle. By tirgger I mean in a condinational branch.

Lets take another example:
I want that if the enemy, lets say enemy troop number 1, (it must be on if the 8 troops, this is very important) attacks the hero with the id 17. I want this as a little code in a condiantional branch.
So I can use this as a trigger.

With this little code I want to make a counterattack system.

This is what I want to make:
I want to make a counterattack system.

I cant just use a script because my battle system is different than the normal one.
I just cant simply take it it would not work.

Im using the atoa acbs battle system. Normally theres a counterattack script from the very beggining but it doesnt work.
So I need take another way.... by condinational branch.


Attached Files
.png   87755.png (Size: 14.72 KB / Downloads: 5)
Reply }
#6
You'd be better off scripting it into your battle system. If it is different then you should post it, and maybe one of us could alter it.
Reply }
#7
The problem with a conditional branch is that you typically have no way to determine if an enemy had attacked the hero. Or not without some scripting help as we both had mentioned...

However, you are using ATOA's system. Is your edit able to use his counter attack system? If so, maybe something can be altered to look like this if you were interested...

Setting actor 17 to counter attack if ... any attack... user #1 ... ... return with a healing skill ... or ...
Code:
Counter_Setting['Actor'][17] = {  {'type' => 4 'condition' => 'user.id(1)'} =>{'type' => 1, 'id' => 1, 'cost' => true}  }

or
Setting actor 17 to counter attack if ... any attack... user #1 ... ... return with turning Switch 15 on.
Code:
Counter_Setting['Actor'][17] = {  {'type' => 4 'condition' => 'user.id(1)'} =>{ $game_switches[15] = true }  }

That doesn't mean that the 'user.id(1)' in this code will work., nor do I have anything that checks for any particular troop ID (if desired), That may take some more time. I never really used Atoa's system,

Does this sound fairly satisfactory?
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#8
Hm I need to test it, but Im 100% sure that it wont work becasue the code itself is bugged as I noticed. I tried to modify the script and edit it but it wont work. I only get errors.

Cant you download the demo I put below on the beggining. Can you try to put the script above and check wheither it works.

this is the easies way to configurate it

Counter_Setting['State'][91] = {
{'type' => 4} => {'type' => 0, 'wait' => false},
# Counter any physical attack and target waits until action ends.
#{'type' => 2, 'condition' => 'target.in_danger?'} => {'type' => 2, 'id' => 1, 'cost' => true},
# Counter against magic using potions if the battler hp is in danger
# {'type' => 4, 'condition' => 'damage.numeric? and damage > 1000'} => {'type' => 1, 'id' => 1, 'cost' => true},
# Counter any attack that can deal more than 1000 damage using Cure in him/herself
}

if an enemy or an actor is inflicted with the status with the 91 he will counterattack if hes attacked no matter skill or just simple attack.
this is why I want to make a counterscript via condinational branch because the script doesnt work.


i tried this code:
$game_troop.enemies[1].current_action.target_index == $game_actors[17]
as an condinational branch

But I get undefined method errors of currenct_action

Cant you at least define the method currenct_action and the target_index for me.

I think this would really help me alot and maybe solve my problem
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Personal graph by actor zlsl 4 5,090 10-23-2021, 06:43 AM
Last Post: zlsl
   Multi Attack & Combo Display Keeroh 9 14,240 05-15-2017, 06:39 PM
Last Post: DerVVulfman
   Actor names in Quest Script jreagan406 5 8,806 03-07-2017, 08:06 AM
Last Post: JayRay
   [XP]Alternative Attack Algorithms by Xelias - need help with bug Geminil 0 3,261 02-06-2016, 07:56 PM
Last Post: Geminil
   Actor Graphic/Reflection Refuses to Update/Refresh penguwin 6 9,973 11-06-2014, 09:51 PM
Last Post: penguwin
   Enemy Transform w/ Minkoff Animated Battlers Kain Nobel 1 4,218 06-01-2014, 05:41 PM
Last Post: MechanicalPen
   Modifying Actor ID to Class ID for Advanced Individual Battle Commands Script NewHope 1 4,683 07-11-2012, 11:37 PM
Last Post: NewHope
   Repositioning the actor command window. MegaPowerNinja 4 9,508 04-12-2011, 05:21 AM
Last Post: MegaPowerNinja
   [RMXP] Actor Cloning dagarath 2 9,236 03-08-2011, 07:18 AM
Last Post: dagarath
   Ring Menu + Actor Train? Other party members dissapear... Shadowgaz 2 6,402 05-19-2009, 01:35 PM
Last Post: Shadowgaz



Users browsing this thread: 1 Guest(s)