• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Math Formula

Status
Not open for further replies.
Hello =)

Again me and my bad math...

So I've been working on a spell that makes special effects in a line from position of caster to targeted location... now everything would be just nice if the cast range would be constant like 700, but now I have the problem with making special effects in order, so it wouldn't matter if cast range is 900 or 100.

You know what i mean, here is a sketch of how it should look
Locations.jpg

The formula should involve distance between points (from caster to targeted location) Loop for integer A, and something i can't figure out :S

Oh, i forgot to mention loop repeats 20 times ;D

Thanks!

~Berz
 
Level 13
Joined
Sep 14, 2008
Messages
1,408
1. Set the total distance into a variable
2. Divide this distance by (is "by" right?) the number of special effects you want to have.
3. Set the result into another variable (lets say "b")
4. Use:
Loop 1-MaxNumberEffects
create effect at position of casting Unit offset by (integer A * b)


That should work?!
 
I don't understand the second point how to get "b"

Edit, attached trigger, if it makes it any easier?

  • Blink Strike Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shadowstep
    • Actions
      • Set Shadowstep_Caster = (Triggering unit)
      • Set Shadowstep_Target = (Target unit of ability being cast)
      • Set Shadowstep_Location = (Position of Shadowstep_Target)
      • Set Shadowstep_Location_2 = (Position of Shadowstep_Caster)
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set Shadowstep_Loop_Location = (Shadowstep_Location_2 offset by ((Distance between Shadowstep_Location and Shadowstep_Location_2) / (Real((Integer A)))) towards (Facing of Shadowstep_Caster) degrees)
          • Special Effect - Create a special effect at Shadowstep_Location_2 using Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Shadowstep_Loop_Location)
      • Custom script: call RemoveLocation(udg_Shadowstep_Location)
      • Custom script: call RemoveLocation(udg_Shadowstep_Location_2)
 
Level 11
Joined
Feb 22, 2006
Messages
752
JASS:
function addSpecialEffectLine takes string effectPath, unit caster, location targetLoc, int effectCount returns nothing
    local real casterX = GetUnitX(caster)
    local real casterY = GetUnitY(caster)
    local real targetX = GetLocationX(targetLoc)
    local real targetY = GetLocationY(targetLoc)
    local real dx = targetX - casterX
    local real dy = targetY - casterY
    local real angle = Atan2(dy, dx)
    local real dist = Sqrt(dx * dx + dy * dy)
    local integer i = 1

    loop
        exitwhen (i > effectCount)

        call DestroyEffect(AddSpecialEffect(effectPath, casterX + (i * dist / effectCount) * Cos(angle), casterY + (i * dist / effectCount) * Sin(angle)))
    
        set i = i + 1
    endloop
endfunction

EDIT: forgot to add endfunction, hehe...
 
Level 12
Joined
Mar 26, 2005
Messages
790
exactly as above.


Create first special effect on position of casting unit offset by (A/B)x1
Create second special effect on position of casting unit offset by (A/B)x2
Create third special effect on position of casting unit offset by (A/B)x3
...

A=distance between caster and target
B=number of special effects
third number is normal A integer starting from 1 to B(number of special effects)


Of course that action can be executed by loop, i just write it this way
 
Status
Not open for further replies.
Top