• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit with range and close combat

Status
Not open for further replies.
Level 4
Joined
Jan 3, 2009
Messages
64
Hi, i was thinking about a unit who can switch between range and close combat, like... i have my hero and i'm shooting another hero, so when he come closes to me i switch to close combat just like in real life.

Note¹: When i'm using range combat style my defense goes lower than the normal and when i'm using close combat style my defense goes higher than the normal.

Note²:There is a way to change the weapon in the hand of my hero?




+rep


SOLVED BY swipe5weep
 
Last edited:
Level 6
Joined
Mar 22, 2009
Messages
276
The answer is yes. With the morphing abilities you can do it with your hero.
Create 2 copies of your hero in the object editor. The one is melee and the other one is ranged. So the base unit is the ranged one. As you said it has a lower defense so make its defense lower, or make the melee hero have a higher defense on object editor.
If you want it to be morphed automatically, you need a trigger for that.
The trigger may seem like this.
  • Events
    • Unit - A unit is attacked
  • Condition
    • ((Attacked Unit) is equal to (YourRangedHero)) or ((Attacked Unit) is equal to (YourMeleeHero))
  • Actions
    • Custom script: local unit u = GetAttackedUnit()
    • Custom script: if u == YourRangedHero Then
    • Custom script: call UnitIssueOrderBJ(YourRangedHero, MetamorphosisOn)
    • Custom script: else
    • Custom script: endif
    • Custom script: if u == YourMeleeHero Then
    • Custom script: call UnitIssueOrderBJ(YourMeleeHero, MetamorphosisOff)
    • Custom script: else
    • Custom script: endif
Those are not the exact syntax you will use but those are the ideas to start from.

In your second quest. The answer is also yes.
If you have another model to be used or weapon that can be attached to your hero in melee form or ranged form.

Edit: I forgot to add the distance checking from the automatic morph trigger, distance between attacked unit and attacking unit location. anyway it seems you dont need the automatic morphing trigger.
 
Last edited:
Level 18
Joined
Feb 28, 2009
Messages
1,970
Note²:There is a way to change the weapon in the hand of my hero?
You can 'change' the attachement model
  • Actions
    • Special Effect - Destroy Melee_Weapon[(Player number of (Owner of (Triggering unit)))]
    • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using SomeWeapon.mdl
    • Set Ranged_Weapon[(Player number of (Owner of (Triggering unit)))] = (Last created special effect)
(it`s MPI)
But if the unit already has a weapon with model itself it will just put second model on the first one what will suck.
 
Status
Not open for further replies.
Top