• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Trigger Computer to 'autocast'

Status
Not open for further replies.
Level 8
Joined
Sep 30, 2012
Messages
205
So yeah, i got some new buff spells, but however i still use all of the old ones. So now i want to create a system, so that PC players cast the dummy spells, whenever they 'attack', then checking if a valid target is in range and if it hasn't got the buff already (in this example its called bloodlust, later it won't).

So i hope its clear that i can't just base it on bloodlust, since other buffs will be applied..

The problem i'm now facing is that whenever the potential caster attacks and finds a valid target, he just freezes and waits till all potential targets drop dead or his health drop and the ai pulls the unit back...
Well occasionally he does cast the spell and all looks good, but he will certainly freeze at one point.

Any ideas why this might be the case?

Is there already a working system on the hive? I did some research and all i could find was, base your buffs on buffs that wc3 already uses, and then the original autocast will work fine, well that won't do it for me..

PS: The dummy spell is "channel" with the base/order id of holy light, and then another system spawns a dummy caster to cast "bloodlust"
- no problems there

  • AIA Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set TempUnit = (Attacking unit)
      • Set tempPlayer = (Owner of TempUnit)
      • Set DBoolean = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempPlayer controller) Equal to Computer
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempUnit) Equal to Footman
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of TempUnit) Greater than or equal to 140.00
                • Then - Actions
                  • Set TempPoint = (Position of TempUnit)
                  • Set TempUnitGroup = (Units within 800.00 of TempPoint)
                  • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Bloodlust) Equal to False
                          • ((Picked unit) is alive) Equal to True
                          • ((Picked unit) is A structure) Equal to False
                          • ((Picked unit) is Mechanical) Equal to False
                          • ((Picked unit) is Magic Immune) Equal to False
                          • ((Picked unit) is A sapper) Equal to False
                          • ((Picked unit) is hidden) Equal to False
                          • (Percentage life of (Picked unit)) Less than 100.00
                          • Or - Any (Conditions) are true
                            • Conditions
                              • ((Picked unit) belongs to an ally of tempPlayer) Equal to True
                              • (Owner of (Picked unit)) Equal to tempPlayer
                        • Then - Actions
                          • Unit Group - Add (Picked unit) to TempUnitGroup2
                          • Set DBoolean = True
                        • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • DBoolean Equal to True
                    • Then - Actions
                      • Set TempUnit2 = (Random unit from TempUnitGroup2)
                      • Unit - Order TempUnit to Human Paladin - Holy Light TempUnit2
                    • Else - Actions
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • Set TempUnit = No unit
      • Set TempUnit2 = No unit
      • Unit Group - Remove all units from TempUnitGroup
      • Unit Group - Remove all units from TempUnitGroup2
      • Unit Group - Remove all units from TempUnitGroup3
      • Custom script: set udg_tempPlayer = null
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup3)
      • Custom script: call RemoveLocation( udg_TempPoint )
 
Level 19
Joined
Jul 14, 2011
Messages
875
A unit is attacked triggers when the attacker starts its attack animation, not when he actually deals damage. I would suggest you use some kind of damage detection system, there are a handful on the hive you can choose from.

You dont need to remove all units from the groups; they are getting destroyed.
You arent using TmpUnitGroup3, but I guess you forgot to remove that.
Also combine the first three if/then/else statements.
 
Level 8
Joined
Sep 30, 2012
Messages
205
But i like it like that. I don't want to add a passive ability when the unit deals damage with his basic attack, i do like my units casting spells. And when the ai thinks this is a good time to attack, then this should trigger "oh even better lets cast a spell instead!" Thats exactly what i want, however maybe the ai then aborts the spell and forces the unit to attack again, that could explain the freeze; the ai struggling to take control^^

- good to know.
- yeah had a version with all potential casters in a group but that made no sense, only made it more complicated
- i want to add 9 more potential autocasting units with various spells and different mana costs later..
 
Status
Not open for further replies.
Top