Help with "attack" ability

Gamewolf3000

Member
Reaction score
1
Hi, so I am trying to make a turn-based and need to be able to restrict the attacks of units, I have solved the problem with units auto attacking and running around by applying an entangling roots buff which stops them from attacking and moving as long as it is aplied. First idea that came to my mind was to put a cooldown on the attack order, but I don't think that is possible.

Secondly I tried making a trigger where a dummy ability which does no damage is used on the target you want to attack and the trigger then first changes owner of the ability using unit (to stop the player from interferring with stuff), then removes the buff from the unit and orders the ability using unit to attack the target unit. The trigger then waits for the targeted unit to take damage by checking if the hp it had when the trigger started (stored in a variable) is more than it's current hp. After that it orders an invisible unit to reaply the entangling roots effects.

The problem there is that the unit just stands there, it never attacks the target and I don't know why.
The third idea I had was to use the damage target action and just have it damage the target for damage equal to the attackers damage - targets armor. But i can't find a way to get the value of a units attack (or armor).

Anyone got any idea for how I can solve this predicament?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
You cant. Thats why nobody is making a turn based wc3 map.
Or if they do, they use custom attack systems and dont use the wc3 standard attacks at all.
 

denmax

You can change this now in User CP.
Reaction score
155
First.. you don't really need that entangling roots method going for.. If what I remember is correct, adding "Worker" as a unit classification type on your unit of interest will stop it from auto-attacking. Once you order it to attack, however, you'll need to stop it.

You can use "Unit - Unit takes damage" as an event. The problem with this, however, is that you cannot really set it to a generic unit, it has to be a specific unit that already exists in the map. This can be resolved by using the action "Trigger - Add new event on trigger". The unit field can be switched out to less specific terms like "Picked unit" or "Matching unit" etc.

Once you have a trigger that states "Unit takes damage", the corresponding unit fields are "Triggering unit" for the unit being attacked, and "Damage source" for the unit that is attacking.

You can basically just have one trigger for this using hashtables to save the location of the unit beforehand, etc.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
First.. you don't really need that entangling roots method going for.. If what I remember is correct, adding "Worker" as a unit classification type on your unit of interest will stop it from auto-attacking. Once you order it to attack, however, you'll need to stop it.

You can use "Unit - Unit takes damage" as an event. The problem with this, however, is that you cannot really set it to a generic unit, it has to be a specific unit that already exists in the map. This can be resolved by using the action "Trigger - Add new event on trigger". The unit field can be switched out to less specific terms like "Picked unit" or "Matching unit" etc.

Once you have a trigger that states "Unit takes damage", the corresponding unit fields are "Triggering unit" for the unit being attacked, and "Damage source" for the unit that is attacking.

You can basically just have one trigger for this using hashtables to save the location of the unit beforehand, etc.
There are plentfy of problems with the "unit takes damage" event. Not only does it leak events, it is also kind of trigger happy.
In this particular case, for example, it would trigger every second because of the entangling roots buff. Even if you set the damage on entangling roots to 0 it will still trigger the event. So does any other negative buff.

I would really advice you to create a custom attack system and not use the standard attack and defense of the game. It might seem like more work at first, but in the long run you might see, that trying to work around all the quirks of wc3 will be a lot harder then just starting from scratch.
 

Gamewolf3000

Member
Reaction score
1
First.. you don't really need that entangling roots method going for.. If what I remember is correct, adding "Worker" as a unit classification type on your unit of interest will stop it from auto-attacking. Once you order it to attack, however, you'll need to stop it.

You can use "Unit - Unit takes damage" as an event. The problem with this, however, is that you cannot really set it to a generic unit, it has to be a specific unit that already exists in the map. This can be resolved by using the action "Trigger - Add new event on trigger". The unit field can be switched out to less specific terms like "Picked unit" or "Matching unit" etc.

Once you have a trigger that states "Unit takes damage", the corresponding unit fields are "Triggering unit" for the unit being attacked, and "Damage source" for the unit that is attacking.

You can basically just have one trigger for this using hashtables to save the location of the unit beforehand, etc.


The Entangling root is mostly there to stop units from running around freely. Using unit takes damage could and might very well be more efficient, but the main problem is that the unit doesn't attack, so there is no damage done. I don't know why it isn't attacking.
 

Gamewolf3000

Member
Reaction score
1
There are plentfy of problems with the "unit takes damage" event. Not only does it leak events, it is also kind of trigger happy.
In this particular case, for example, it would trigger every second because of the entangling roots buff. Even if you set the damage on entangling roots to 0 it will still trigger the event. So does any other negative buff.

I would really advice you to create a custom attack system and not use the standard attack and defense of the game. It might seem like more work at first, but in the long run you might see, that trying to work around all the quirks of wc3 will be a lot harder then just starting from scratch.


Yeah, I never expected there to be a way of using the attack order directly, but i thought maybe (only maybe) someone knew a way around it. But the trigger i created doesn't work and I can't find the reason.
 

O.A

Quantum physics rules
Reaction score
29
For a turn-based map i'd recommend disabling all normal attacks from Object Editor (Combat - Enabled Attacks = None), and pausing all units when the player's turn ends, or pausing a single unit one by one when it runs out of action points (i don't know if you use AP). When you pause the units, order them to stop first, or once they are unpaused they will continue the order they were in the middle of completing when they were paused (move to a point for example).

Then make custom attacks from the Channel ability, set the casting range accordingly (melee/ranged).

Here's an example of how you can then control the damage and other stuff via triggers;
Trigger:
  • Grunt Slice
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel Based Custom with melee cast range (40-60)
    • Actions
      • -------- Check random integer for a critical hit (33%) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • -------- Check custom buffs (in this case Terror, which halves the critical chance of this unit) --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has buff Terror ) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 2) Equal to 1
                • Then - Actions
                  • -------- More custom buffs (Fortify damage, increases damage 75% and doubles critical damage) --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Triggering unit) has buff Fortify Damage ) Equal to True
                    • Then - Actions
                      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 300.00 damage of attack type Normal and damage type Normal
                    • Else - Actions
                      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 150.00 damage of attack type Normal and damage type Normal
                • Else - Actions
                  • -------- Failed critical with Terror decreases damage by 10% --------
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 90.00 damage of attack type Normal and damage type Normal
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) has buff Fortify Damage ) Equal to True
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 300.00 damage of attack type Normal and damage type Normal
                • Else - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 150.00 damage of attack type Normal and damage type Normal
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has buff Fortify Damage ) Equal to True
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 175.00 damage of attack type Normal and damage type Normal
            • Else - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 100.00 damage of attack type Normal and damage type Normal


It contains a few ideas i had for my never-to-be-finished turn-based map (the buffs). Anyways, that's how i would go about doing this, don't know if it suits your map.
 

Gamewolf3000

Member
Reaction score
1
For a turn-based map i'd recommend disabling all normal attacks from Object Editor (Combat - Enabled Attacks = None), and pausing all units when the player's turn ends, or pausing a single unit one by one when it runs out of action points (i don't know if you use AP). When you pause the units, order them to stop first, or once they are unpaused they will continue the order they were in the middle of completing when they were paused (move to a point for example).

Then make custom attacks from the Channel ability, set the casting range accordingly (melee/ranged).

Here's an example of how you can then control the damage and other stuff via triggers;
Trigger:
  • Grunt Slice
    • Events
    • Unit - A unit Starts the effect of an ability
    • Conditions
    • (Ability being cast) Equal to Channel Based Custom with melee cast range (40-60)
    • Actions
    • -------- Check random integer for a critical hit (33%) --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Random integer number between 1 and 3) Equal to 1
    • Then - Actions
    • -------- Check custom buffs (in this case Terror, which halves the critical chance of this unit) --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Triggering unit) has buff Terror ) Equal to True
    • Then - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Random integer number between 1 and 2) Equal to 1
    • Then - Actions
    • -------- More custom buffs (Fortify damage, increases damage 75% and doubles critical damage) --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Triggering unit) has buff Fortify Damage ) Equal to True
    • Then - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 300.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 150.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • -------- Failed critical with Terror decreases damage by 10% --------
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 90.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Triggering unit) has buff Fortify Damage ) Equal to True
    • Then - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 300.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 150.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Triggering unit) has buff Fortify Damage ) Equal to True
    • Then - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 175.00 damage of attack type Normal and damage type Normal
    • Else - Actions
    • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 100.00 damage of attack type Normal and damage type Normal


It contains a few ideas i had for my never-to-be-finished turn-based map (the buffs). Anyways, that's how i would go about doing this, don't know if it suits your map.


Well I don't know how pausing would work since i use abilities. The map is supposed to have a kind of chess board so units can only move to specific positions (I have a system for this which seems to work at least). So the basic abilities for a unit is a movement ability with a certain range (And a CD which is longer than the maximum turn time, thus stopping them from using it again) and an attack ability with a certain range that costs 1 mana (the idea is that units with abilities will for the most part have to choose between attacking or using their special ability). But maybe someone knows of a better way of doing it?
 

Gamewolf3000

Member
Reaction score
1
I got an idea that might work, I find no way to use attack and armor values in the trigger editor, but would it be possible to use a simple bit of jass code to get attack and armor value from attacking and attacked unit and store them in a way that the trigger editor can use?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
You can not get attack and armor values in the editor. There is no way to get them. (unless you try to calculate them yourself)
 

O.A

Quantum physics rules
Reaction score
29
The units would be paused when it's no longer their turn, and unpaused when it is. I don't see how whether you use abilities or not has anything to do with it. All of these custom attacks would be "abilities", when based on Channel, even the melee attacks. But like i said, i don't know exactly how your map works so, on to the point;

A unit's damage reduction will work even when you use the Damage Target action, you can set a different base defense to different units to get the DR% you want (setting the gameplay constant to 0.01 might give a little more tweaking room with this). This way you don't need the armor value, and all attacks would of course have pre-set damage amounts in the triggers.

Ps. This also gives a few strategic possibilities, e.g, giving some units "real" spells (they would ignore the DR), so they could blast through some unit's insane defense that would take much longer to beat to pieces with melee attacks.
 

Gamewolf3000

Member
Reaction score
1
You can not get attack and armor values in the editor. There is no way to get them. (unless you try to calculate them yourself)


Not even with jass coding?

The units would be paused when it's no longer their turn, and unpaused when it is. I don't see how whether you use abilities or not has anything to do with it. All of these custom attacks would be "abilities", when based on Channel, even the melee attacks. But like i said, i don't know exactly how your map works so, on to the point;

A unit's damage reduction will work even when you use the Damage Target action, you can set a different base defense to different units to get the DR% you want (setting the gameplay constant to 0.01 might give a little more tweaking room with this). This way you don't need the armor value, and all attacks would of course have pre-set damage amounts in the triggers.

Ps. This also gives a few strategic possibilities, e.g, giving some units "real" spells (they would ignore the DR), so they could blast through some unit's insane defense that would take much longer to beat to pieces with melee attacks.


It's kinda like the battle system in heroes of might and magic where you have several units on the field at the same time, but more fleshed out. The problem I see with a pausing all units is that if it is supposed to stop units from moving unless the movement ability is used, pausing will hinder the ability from being used.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Jass does not offer you much more then GUI. At least not in this regard. There is no simple way to get the attack and armor values for a unit.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
What about Drunken Haze? It can be set to prevent attacks and movement as long as the buff is present.
 

Gamewolf3000

Member
Reaction score
1
What about Drunken Haze? It can be set to prevent attacks and movement as long as the buff is present.


Well that would kinda be the same thing as the entangling roots buff i use now. Thanks anyway.

Jass does not offer you much more then GUI. At least not in this regard. There is no simple way to get the attack and armor values for a unit.


Well, that sucks, that would hamper alot of ability potentials like increasing your hp with the same amount as your attack, your damage is the same as you armor and other stuff like that. Does anyone know of another engine more suitable for making a turnbased strategy game like this?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Yes. C++, C#, Java...

There isnt any big finished engines which are just lying around to be used by everybody freely. There are a few, but these are usually quite bad or limited to 2D, or they cost a lot of money. Usually they dont even come with preset graphics, music and sound.
Your best bet could be the starcraft 2 galaxy editor (which is very very powerful by the way) but that thing is a bit more complex.
 

Gamewolf3000

Member
Reaction score
1
Yes. C++, C#, Java...

There isnt any big finished engines which are just lying around to be used by everybody freely. There are a few, but these are usually quite bad or limited to 2D, or they cost a lot of money. Usually they dont even come with preset graphics, music and sound.
Your best bet could be the starcraft 2 galaxy editor (which is very very powerful by the way) but that thing is a bit more complex.


Well 2d could work i guess, there is nothing about my game that really requiers 3d (except from it looking cooler but that's not really a requierment). And if I tried to code it myself (which has poped up in my mind) I would never even try to make it in 3d, I have some very basic coding knowledge but going from that to 3d would be an insane idea. So if anyone knows of a good/decent engine that works even if it's in 2d then feel free to post it. I could pay for it aswell if it got a good reputation and doesn't cost an absurd amount.

Using the starcraft 2 editor is something I have been thinking about and maybe that's what I have to do. I have tried to use it before but as you said it is much more complex but learning is not something I am against. The main reason for using the warcraft 3 editor (except it being easier to use) was that the units in wc3 are fantasy based and there is alot of resources on sites like the hive workshop where I can find other stuff. For a game like this I think that fantasy would work alot better, at least in my mind. It gives more freedom and variety to unit creation that sci-fi doesn't allow. But that's just my opinion.

I will probably look at the starcraft 2 editor a bit tho, it might be my best shot if no one knows of a better engine. So if as I said, if anyone knows of one that could work then feel free to post it. But in the case of no one having more to add, I want to thank everyone here for trying to help me solve my problem!
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
There is some "rather" simple 3D engines out there. When you actually know how to code the game yourself and only need a graphics engine then there are plenty.
If you are working with Java you can use the JMonkey-Engine (free to use) or LibGDX (free to use). These use OpenGL and OpenAL for graphics and music and can both display 2D and 3D graphics quite well.
There are numerous libraries for 2D / 3D with C++.

If you want something really simple for windows then you could try the RPG-Maker Ace which costs about 40 bugs. That a 2D engine build with Ruby. Ruby is an incredible simple scripting language which absolutely everybody should be able to use. The RPG-Maker comes with pre made graphics, music and sounds too. And there are tons of custom made libraries for the maker which you can use to customize your game. If I remember correctly there are several libraries for tactical turn based games for the RPGMAce.
 

Gamewolf3000

Member
Reaction score
1
There is some "rather" simple 3D engines out there. When you actually know how to code the game yourself and only need a graphics engine then there are plenty.
If you are working with Java you can use the JMonkey-Engine (free to use) or LibGDX (free to use). These use OpenGL and OpenAL for graphics and music and can both display 2D and 3D graphics quite well.
There are numerous libraries for 2D / 3D with C++.

If you want something really simple for windows then you could try the RPG-Maker Ace which costs about 40 bugs. That a 2D engine build with Ruby. Ruby is an incredible simple scripting language which absolutely everybody should be able to use. The RPG-Maker comes with pre made graphics, music and sounds too. And there are tons of custom made libraries for the maker which you can use to customize your game. If I remember correctly there are several libraries for tactical turn based games for the RPGMAce.


I'll give those engines a check, I have heard of monkey before. Rpg maker vx ace might work and I actually own it, the main problem i can see is that I don't think there is any way of playing it multiplayer/online.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Not quite. In theory the RPG-Maker could play online, but the performance is pretty bad. And the amount of work you have to put into it is huge.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top