Hey guys,
I'm working on a top down shooter at the moment and I can't figure out how to do this:
The hostile units shoot at friendly units with their weapons. When their missiles hit something on their way to the target (no pathing), they get destroyed.
Now, how do I get the hostile units to not shoot when there's something in the (direct) way between them and their target? And instead walk closer to their targets until they'd be able to hit again?
I guess it's something with disabling weapons and behaviors, but when I try to think of a solution it always feels like my brain is shutting down :D
Only thoughts I have on the matter are maybe to have them try to shoot, and if it hits an obstacle, send a behavior or effect back at the caster which can disable the weapon/issue order to move closer to the intended target. Might have to use some triggers to make the movement believable, a create persistent would likely fail on this since the facing of the units isn't certain when the bullet hits the wall.
Edit: Another thought for you, this would require considerably less work, I have used it on a few of my monsters already. If the bullet hits an obstacle, apply a behavior to the marine that disables the range weapon and enables a hidden melee weapon. Just make it have period 60 and damage 0 or something. This will cause the marine to appear to go after the unit. Then when behavior wears off, back to shooting.
Solved,
after having difficulties finding a data way for this I did it with triggers:
PathingAIEventsUnit-AnyUnitstartsattackingLocalVariablesdistance=(Distancebetween(Positionof(Triggeringunit))and(PositionofFollowedUnit[1])) <Real>
distance_pathing = (Pathing cost for unit (Triggering unit) to point (Position of FollowedUnit[1]), considering buildings of type Include All Buildings) <Integer>
Conditions
(Owner of (Triggering unit)) == 15
((Triggering unit) has Deactivate Weapon) == False
(The line from (Position of (Triggering unit)) to (Position of FollowedUnit[1]) crosses a cliff edge.) == True
(Real(distance_pathing)) != distance
Actions
Unit - Add 1 Deactivate Weapon to (Triggering unit) from FollowedUnit[1]
Unit - Add Dummy Melee to (Triggering unit) using turret No Game Link
General - Wait 1.0 Game Time seconds
Unit - Remove Dummy Melee from (Triggering unit)
Unit - Remove 1 Deactivate Weapon from (Triggering unit)
FollowedUnit[1] is the player unit for testing purposes, seems to work VERY accurate actually :P
@Deadzergling: Go Thanks for the melee weapon idea! :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey guys,
I'm working on a top down shooter at the moment and I can't figure out how to do this:
The hostile units shoot at friendly units with their weapons. When their missiles hit something on their way to the target (no pathing), they get destroyed.
Now, how do I get the hostile units to not shoot when there's something in the (direct) way between them and their target? And instead walk closer to their targets until they'd be able to hit again?
I guess it's something with disabling weapons and behaviors, but when I try to think of a solution it always feels like my brain is shutting down :D
Thanks :)
@Ousnius: Go
Only thoughts I have on the matter are maybe to have them try to shoot, and if it hits an obstacle, send a behavior or effect back at the caster which can disable the weapon/issue order to move closer to the intended target. Might have to use some triggers to make the movement believable, a create persistent would likely fail on this since the facing of the units isn't certain when the bullet hits the wall.
Edit: Another thought for you, this would require considerably less work, I have used it on a few of my monsters already. If the bullet hits an obstacle, apply a behavior to the marine that disables the range weapon and enables a hidden melee weapon. Just make it have period 60 and damage 0 or something. This will cause the marine to appear to go after the unit. Then when behavior wears off, back to shooting.
Solved,
after having difficulties finding a data way for this I did it with triggers:
FollowedUnit[1] is the player unit for testing purposes, seems to work VERY accurate actually :P @Deadzergling: Go Thanks for the melee weapon idea! :)