• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] "Gulf-Warish" turret rotation feature

Status
Not open for further replies.

Oli

Oli

Level 4
Joined
Aug 9, 2015
Messages
42
Hello, i've been lately trying to create a realistic turret rotation system which besides obviously having turret-rotation features would also shoot at enemies indenpendantly to what is the unit actually doing (in other words, the turret would rotate at enemies even if there was no attack order and something would cause it to shoot.) If an specific target attack order was given the turret would then focus the targeted unit.

Such system or feature already exists in a map called The Gulf War. The map however is not open-source (it's protected) and the author seems to be dead(been inactive for a long while).
Below is the link for the map;
Gulf War1.3.1 Desert Storm

I realized that to create such system i would need two things; a trigger and a spell. Once the spell is initiated the trigger would cause the turret to rotate. There are a few problems;
-If the spell would be based on phoenix fire the player can't focus it on an unit he wants to (when given an target order attack). Also the GUI script language seems to not have enough event types to realize whether an unit is attacked by phoenix fire. That means that the script must be atleast partially written in jass or lua.
phoenix-fire.png

I would be deeply in debt for any help.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
oh, didn't understand that from op.

you could try basing a spell off of barrage, (or wtvr th siege engine shooting at flyers thing is called if it's not hardcoded to only target air ) that targets the unit type you want - as it seems to do more or less what you want (attacking randomly while moving), and use the following to turn the turret:

I think he used SetUnitLookAt().
With it, you can lock a part of the model (such as the head or, in your case, the turret) to a specific unit.

it's from this:



(just found it at the similar posts on the bottom...)
 

Oli

Oli

Level 4
Joined
Aug 9, 2015
Messages
42
oh, didn't understand that from op.

you could try basing a spell off of barrage, (or wtvr th siege engine shooting at flyers thing is called if it's not hardcoded to only target air ) that targets the unit type you want - as it seems to do more or less what you want (attacking randomly while moving), and use the following to turn the turret:



it's from this:



(just found it at the similar posts on the bottom...)
I've seen the post already (and went through many others on this site.)

I don't think it can be based on the barrage spell as it needs an order from the unit to attack? The spell itself must shoot randomly in nature but when the player wants to precise which unit to attack by ordering the unit to attack the spell would start focusing the targered unit. That's what i want to achieve.

You can also take a look at the map which i've sent in the post - i want it to be identical.
1618704721408.png


^The tank is moving but it's shooting in the same time.
1618708027302.png


^Another good example of this system, this time taken from a map called Modern Warfare
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Such a system may be available in the spell section. I recommend looking through that first in case there is one that is ready to import and use.

You can always look at the underlying JASS map script to see how they implemented it. This can be done by extracting it MPQEdit and then opening it in your favourite text editor, preferably with support for multiple styles of end line. The script might be obfuscated in which case it may be difficult to understand and find the related code for people inexperienced with the JASS scripting language. If you find the related code you can learn from it and use similar concepts and ideas to write your similar system. Avoid directly copy and pasting pieces of the script as that could be considered theft.

If trying to create such a system entirely by yourself then I would recommend looking into the following approaches.
  • Using units that are moved by triggers with 0 attack delay and limited rotation rate. The turret rotation would be limited by the unit rotation speed as units can only attack when facing their target. The position of the turret units is updated many times a second using the SetUnitX/Y functions.
  • Entirely simulate the turret mechanics using a trigger system including target acquisition, rotation and firing angle limits. For actual attacks, either move a dummy unit to perform a real attack at a target, or also simulate the attacks with triggers by using a projectile system and triggered damage. This approach is a lot more customisable than the previous method but also likely more complicated to implement.
For the tank turret rotation the turret is likely a head bone of sorts within the model so can be freely rotated by triggers using the appropriate animation actions that lock head facing. For models where this is not the case then dummy units, attachments or special effects with high update frequency could be used to try and simulate a turret.
 
Last edited:
Status
Not open for further replies.
Top