• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Help with line spell

Status
Not open for further replies.
Level 7
Joined
Jun 14, 2009
Messages
235
I need help making a spell only affect a unit once

Think of shockwave, where the missile passes through the unit, and only damages it once.

This is with a missile, periodic and stuff. Im using hashtables (dont hate).

Just wondering what to do.
 
Level 7
Joined
Jun 14, 2009
Messages
235
Add an dummy ability
Put the unit to a group
Set it's custom value to a specific number..

Many things you can do..

If i added a dummy ability, then the same spell was cast twice on the units, wouldn't it only work once? I tried putting the unit into a group, but it wasn't working, it wouldn't save the group in the hashtable

Also aren't custom numbers usually not recommended.
 
Level 11
Joined
Sep 12, 2008
Messages
657
k.. i made a custom missle once.. its not hard..

this is how to do the group:

  • Group
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in YourGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in YourGroup2 Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to YourGroup2
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing YourDamage damage of attack type YourAttackType and damage type YourDamageType
            • Else - Actions
 
Level 7
Joined
Jun 14, 2009
Messages
235
Ok thanks for the help, yes i know im doing it wrong, thats why i asked.

I'll take a look at your system + rep to you guiz
 
Simple, since you use hashtables:
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • Custom script: local group g = CreateGroup()
    • //Dummy creation and stuff
    • Unit Group - Add (Last created unit) to TempGroup //Last created unit refers to the dummy missile.
    • Custom script: call SaveGroupHandle (udg_Hash, GetHandleId (GetLastCreatedUnit()), StringHash("group"), g)
    • Trigger - Turn on (Trigger2 <gen>)
    • Custom script: set g = null
  • Trigger2
  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (TempGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Unit Group - Pick every unit in TempGroup and do (Actions)
          • Loop - Actions
            • Set Points[1] = (Position of (Picked unit))
            • Set Unit = (Picked unit)
            • Set UnitHandle = (Picked unit)
            • Set TempGroup2 = (Units within 150.00 of Points[1] matching (((Matching unit) is in (Load Key(group) of (Key(Picked unit)) in Hash) Equal to False) and ((Matching unit) belongs to an enemy of (Owner of (Picked unit)) Equal to True)
            • Unit Group - Pick every unit in TempGroup2 and do (Actions)
              • Loop - Actions
                • Unit Group - Add (Picked unit) to (Load Key(group) of (Key(UnitHandle)) in Hash)
                • Unit - Cause Unit to damage (Picked unit) dealing 100.00 damage of Attack type Spells and Damage type Normal
            • Custom script: call RemoveLocation (udg_Points[1])
            • Custom script: call DestroyGroup (udg_TempGroup2)
NOTE: The trigger above is not the full trigger of how it should look like, I am just emphasizing how you are going to work with that local group we created in the first trigger. Finally, when you have the condition (Distance between Points) to check when you are going to kill the missile unit, destroy the group: call DestroyGroup (LoadGroupHandle (udg_Hash, GetHandleId (GetEnumUnit()), StringHash("group"))).

Unit is a Unit variable, while UnitHandle is a Handle variable.
 
Level 7
Joined
Jun 14, 2009
Messages
235
Simple, since you use hashtables:
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • Custom script: local group g = CreateGroup()
    • //Dummy creation and stuff
    • Unit Group - Add (Last created unit) to TempGroup //Last created unit refers to the dummy missile.
    • Custom script: call SaveGroupHandle (udg_Hash, GetHandleId (GetLastCreatedUnit()), StringHash("group"), g)
    • Trigger - Turn on (Trigger2 <gen>)
    • Custom script: set g = null
  • Trigger2
  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (TempGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off (This trigger)
      • Else - Actions
        • Unit Group - Pick every unit in TempGroup and do (Actions)
          • Loop - Actions
            • Set Points[1] = (Position of (Picked unit))
            • Set Unit = (Picked unit)
            • Set UnitHandle = (Picked unit)
            • Set TempGroup2 = (Units within 150.00 of Points[1] matching (((Matching unit) is in (Load Key(group) of (Key(Picked unit)) in Hash) Equal to False) and ((Matching unit) belongs to an enemy of (Owner of (Picked unit)) Equal to True)
            • Unit Group - Pick every unit in TempGroup2 and do (Actions)
              • Loop - Actions
                • Unit Group - Add (Picked unit) to (Load Key(group) of (Key(UnitHandle)) in Hash)
                • Unit - Cause Unit to damage (Picked unit) dealing 100.00 damage of Attack type Spells and Damage type Normal
            • Custom script: call RemoveLocation (udg_Points[1])
            • Custom script: call DestroyGroup (udg_TempGroup2)
NOTE: The trigger above is not the full trigger of how it should look like, I am just emphasizing how you are going to work with that local group we created in the first trigger. Finally, when you have the condition (Distance between Points) to check when you are going to kill the missile unit, destroy the group: call DestroyGroup (LoadGroupHandle (udg_Hash, GetHandleId (GetEnumUnit()), StringHash("group"))).

Unit is a Unit variable, while UnitHandle is a Handle variable.

ok so you have to specifically make a empty unit group and then save it? ok testing now

Its telling me it has to be disabled because "Expected a code statment" etc, did i put it in wrong?
 
Level 7
Joined
Jun 14, 2009
Messages
235
It's a bit nasty, using custom scripts, when you don't know how to :p
Send me the map and I will fix it for you.

ok, but yah if you have anything about how to optimize stuff to that would be great :D

Trying to get better at this stuff, so i don't have to keep asking questions for everything :/
 

Attachments

  • Peircing Arrow.w3x
    16.1 KB · Views: 47
Status
Not open for further replies.
Top