View Full Version : [Support] (Dis)Allowing cast on some zones.
Forest_Elf
08-30-2011, 04:47 AM
Is there a way to (dis)allow some heroes to cast AoE spells targeted on some zone (or targeted spells, when the target is in the zone). Something like Nymph's ult, that is restricted to not being able to be cast on enemy base.
tojooko
08-30-2011, 11:09 AM
As you have said the key to do it is checking Nymph's ult code.
There are original lines:
notargetradius="2500"
notargetmaterial="/shared/materials/area_cast_indicator_simple_red.material"
notargetscheme="Nymphora_NoPortGadget"
notargetignoreinvulnerable="true"
Well, for example if you want to make spell target-able only if unit is not near any hero (mby for fast farming) you can do it this way:
notargetradius="500"
notargetmaterial="/shared/materials/area_cast_indicator_simple_red.material"
notargetscheme="all_heroes"
If this zone is defined by map it's really easier, because you just have to use original lines.
Forest_Elf
08-30-2011, 12:44 PM
Ye, seen that. However thanks for clarification about notargetscheme.
But still there is the second part - is it possible to Allow heroes to cast somewhere. For example a hero can cast his ability in 600 radius around self, but when a modifier is applied - he should be able to cast in 300 radius around a new entity. Something like create a new target scheme MyHero_AllowZone or something like that.
Oloko
08-30-2011, 02:25 PM
By looking at Pebble's spell, you could try something like this:
<ability
...
range="600"
>
<onimpact>
<setactivemodifierkey name="phase2" />
</onimpact>
<modifier key="phase2" modpriority="100"
range="300"
useproxy="true"
proxytargetscheme="my_target_scheme"
proxyeffecttype="Magic"
proxyselectionradius="300"
proxyselectionmethod="closest"
proxytargetmaterial="/shared/materials/area_cast_indicator_simple.material"
>
<onimpact>
<setactivemodifierkey name="" />
</onimpact>
</modifier>
</ability>
Forest_Elf
08-31-2011, 06:04 AM
One of a few heroes i didnt look at is Peb - thanks for pointing this code out.
However as i understand this code does the next - it chooses a closest entity that meets the conditions in target scheme and sets it as a proxy for this ability. However i'd like to have something like that:
Phase1 - Target Ground ability with range 600 (that's pretty easy), after cast applies Phase2 modifier.
Phase2 - Target Vector ability that can be cast either in 600 range around self or in 300 range around the Phase1 ground target position.
Is it possible to spawn an entity with my custom target scheme (like Nymphora_NoPort scheme)? Or is there another way?
PS: As atm i dont see the way to make this with my_target_scheme as you said (as it should target only near the entity i spawn and nowhere else - so nothing like player_controlled or anything like that).
Oloko
08-31-2011, 12:13 PM
You can create new targetscheme if you want.
You need to create your gadget first. In your desired gadget entity, add the following line:
unittype="gadget MyGadgetName"
This here mean that your gadget will be a unit of type "gadget" and "MyGadgetName" (change it to whatever you want).
Now you still need to create the targetscheme. To do this, create a copy of base.gamemechanics and in the targetscheme section, add yours like this:
<targetscheme name="MyTargetScheme" allow="MyGadgetName" restrict="dead,corpse,!mine"/>
So here the targetscheme "MyTargetScheme" will only work on unit type "MyGadgetName" that are mine, not dead and not corpses. So here you can change it to whatever you want.
Now there is one issue with the spell mechanic. On the phase2 of your spell, you can either cast 600 units around you, or 300 units around one of those unit. This mean that your spell can in fact be cast from anywhere on the map since your gadget could be 9000 units from you.
So you will need to put the range of your spell to range="999999" so that it's global.
The idea is to be able to cast from anywhere and then test via script if you can cast your spell there. Sadly, this make the spell a bit awkward, since it fool the player in thinking he can cast is spell anywhere but it will do nothing if it does not meet the requirements.
You can test it out by using the <distance /> (to test with your hero) and <testnearby /> (to test with the gadget) action.
tojooko
08-31-2011, 12:16 PM
Is it possible to spawn an entity with my custom target scheme (like Nymphora_NoPort scheme)? Or is there another way?
I think I'll just clarify again but:
You can make it by adding unittype to entity (can be applied in state)
unittype="MyUnit"
and add it to targetschemes:
<targetscheme name="MyUnits" allow="MyUnit" restrict="dead,corpse"/>
To be honest I've no idea now how to do it with Target Vector ability :(
It's possible with normal target unit. I can explain how if you want.
It could be doable if in <activatecost > event we had target_position defined.
EDIT Oloko was faster:P
Also I've to check one more way to do it, with faked <invalidate/> action