HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Code an auto-cast

01-22-2009, 08:18 PM#1
Flame_Phoenix
Hi guys, I was wondering, is it possible to code an auto-cast ability? I really don't get how it could ever be possible to code that "right-click" and "glow thing around the icon" with just using vJASS. If some one has ideas or suggestions they are welcome.
01-22-2009, 08:24 PM#2
the-thingy
Wait, what exactly are you trying to do? You want to detect when autocast has been enabled/disabled, or...?

If it's an attack modifier autocast, you could use a damage detection system and use Poison Arrows/Cold Arrows (or some other autocast attack mod that applies a buff), then check for the buff on damage - if the buff is present, remove the buff (to avoid falsely triggering the effects from another hit) and do your actions accordingly
01-22-2009, 08:26 PM#3
Flame_Phoenix
Quote:
Wait, what exactly are you trying to do? You want to detect when autocast has been enabled/disabled, or...?
Exactly =D
01-22-2009, 08:34 PM#4
the-thingy
Collapse JASS:
function Meh takes nothing returns nothing
    if GetIssuedOrderId () == OrderId ("flamingarrows") then
        call BJDebugMsg ("Searing Arrows - autocast enabled")
    elseif GetIssuedOrderId () == OrderId ("unflamingarrows") then
        call BJDebugMsg ("Searing Arrows - autocast disabled")
    endif
endfunction

//===========================================================================
function MehAgain takes nothing returns nothing
    local trigger t = CreateTrigger ()
    call TriggerRegisterAnyUnitEventBJ (t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
    call TriggerAddAction (t, function Meh)
endfunction

I think that's how it's done, never really worked with autocast abilities

Object Editor should have all the Turn On/Off order strings for autocast abilities, Searing Arrows is the only one I remember :)
01-22-2009, 09:06 PM#5
Flame_Phoenix
I will test this asap!
Maybe, If I make a system with Table I can create my own auto-cast abilities.
Thx for help!

EDIT EDIT EDIT

It works !!!!
Now should I create a system for this? Like I have in mind:
- When a unit is created, if it is a special unit with some kind of special ability, I add it to table, and some sort of boolean value (isAutoOn) equal to false
- When the user changes that value, I change the boolean respective to the unit
- When some one is attack (per example, like slow) if the boolean value for that unit in "true" I make it autocast the spell (I order it to cast it) else I do nothing

Do you guys think this is a good idea ?
01-22-2009, 09:12 PM#6
akolyt0r
Quote:
Originally Posted by Flame_Phoenix
I will test this asap!
Maybe, If I make a system with Table I can create my own auto-cast abilities.
Thx for help!

EDIT EDIT EDIT

It works !!!!
Now should I create a system for this? Like I have in mind:
- When a unit is created, if it is a special unit with some kind of special ability, I add it to table, and some sort of boolean value (isAutoOn) equal to false
- When the user changes that value, I change the boolean respective to the unit
- When some one is attack (per example, like slow) if the boolean value for that unit in "true" I make it autocast the spell (I order it to cast it) else I do nothing

Do you guys think this is a good idea ?

me personally no.. i think we dont need a system for such a special case ...i would not use a system ...for maybe 2-3 triggered autocast abilities in a map ...where 2-3 of them would not even require such a thing...
01-22-2009, 09:17 PM#7
Flame_Phoenix
Quote:
..i would not use a system ...for maybe 2-3
I have the double in my project, I need something like this badly. Besides I can only assume there ARE others that need it as bad as I do.

Yet, ignoring personal opinions, what do you think of my algorithm, would it be good?
01-22-2009, 10:00 PM#8
akolyt0r
you dont need such an algorithm AT ALL
can all be done with a timer which checks if there are conditions for cast (when autocast is enabled)
01-23-2009, 02:30 AM#9
fX_
If you are making your triggered effects functions of casting the spell (spellcast-->triggered effects), then you need not make a system. Because the units will cast the spells automatically if the spell is auto-casted and (recall spellcast-->triggered effects *SPELLCAST*) you only need to detect when the spell is casted to apply the triggered effects.

edit:
Further, the system you are conceiving functions to simulate auto-casting... but it operates on as a function of auto-casting events... so you are making a system that simulates auto-casting when auto-casting occurs... seems like a redundant iteration of 'auto-casting'.
..and the system has no motivation since its function is already accommodated naturally - and, in fact, like said above, the system relies on this.

doesnt seem to be any sense in making a system.
01-23-2009, 09:15 AM#10
Flame_Phoenix
Quote:
whether it's been turned on. You'll actually have to simulate some or all of the AI behaviors you want it to have.
Exact, which is why I need the system. It is useful to detect if auto-cast is on or off.
01-23-2009, 10:36 AM#11
fX_
But the purpose for which you will do that detection is to simulate auto-casting:

by triggered-casting the spells when auto-cast is enabled.

- but this is already how auto-cast works... when it is enabled, it automatically-casts the spell...
01-23-2009, 11:23 AM#12
Flame_Phoenix
Quote:
- but this is already how auto-cast works... when it is enabled, it automatically-casts the spell...
Which is the problem. By controlling auto-cats I can pick which targets are good and bad =)
01-23-2009, 12:23 PM#13
Anitarf
You're not controlling it, though, the unit will still cast the autocast spell automatically regardless of what your code does.
01-23-2009, 12:40 PM#14
Rising_Dusk
Quote:
Originally Posted by Flame_Phoenix
Exact, which is why I need the system. It is useful to detect if auto-cast is on or off.
Detecting when autocast is turned on is trivial. The challenging part of this is emulating the AI behavior, like I was telling you in chat. However, since the AI for each individual autocast ability is so vastly different, it would not be good to try to mesh that into a system. There would be too many hardcoded aspects for it to really be a proper system, may as well split it up into individual components for the different autocasts that interest you.
01-23-2009, 12:54 PM#15
Flame_Phoenix
Quote:
Detecting when autocast is turned on is trivial. The challenging part of this is emulating the AI behavior, like I was telling you in chat. However, since the AI for each individual autocast ability is so vastly different, it would not be good to try to mesh that into a system. There would be too many hardcoded aspects for it to really be a proper system, may as well split it up into individual components for the different autocasts that interest you.
Agreed. Yet, thx for your help =)