• 🏆 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!

Spell Question - Would appreciate fast reply

Status
Not open for further replies.
Level 5
Joined
Jul 20, 2004
Messages
156
I have a fan of knives spell. I want it to ensnare a random 1-15 units near the caster. I have a dummy unit with the ensnare spell and everything else thats needed, but my trigger just doesn't seem to be working. Here it is:

Assassin's Favorite Shot
Events:
Unit - A unit Starts the effect of an ability
Conditions:
(Ability being cast) Equal to Assassin's Favorite Shot
Actions:
Unit - Create one Assassin's Favorite Shot Dummy for (Owner of (Casting unit)) at (Target point of ability being cast) facing Default building degrees
Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
Unit - Order (Last created unit) to Orc Raider - Ensnare (Random unit from (Random (Random integer number between 1 and 15) units from (Units within 1000.00 of (Position of (Targeted unit)))))

Can anyone correct this? Thanks.
 
Level 7
Joined
May 16, 2004
Messages
355
Well I can see several problems, now I may be wrong but I don't think that slam spells like FON has a target point, instead create them at position of casting unit. Next, since you only have one casting unit there is a slight delay between castings, meaning that it will only ensnare maybe one or two units(if you are lucky) so for the casting I suggest doing this:
Code:
for loop integer A 1- (number of units within 
1000 of casting unit matching (belongs to an enemy of owner of casting unit)
    Loop Actions-
           Pick random 1 unit within 1000 of position 
           of casting unit matching (belongs to an 
           enemy of owner of casting unit) and 
           (is alive equal to true) and (has buff 
           (ensnare) equal to false)
       Create 1 Ensnarer for (owner of casting unit)  
       at position of picked units
       add generic expiration timer to last created 
       unit
       Order last created unit to Orc- raider ensnare
       (picked unit)

Its kinda messy and psuedo code but that is basically the way it should be done, if it doesnt work tell me and ill make a test for you to see
 
Level 2
Joined
Mar 10, 2005
Messages
19
well chuckle i think youre way is too complicated and confusing. there has been a specific nova target system in the spells section which explains how to solve this problem. maybe you should download it. well heres how it works.

only do:
actions
PICK every unit within range <your range> and do
create dummy unit at position of casting unit
add a 1 sec expiration timer to last created unit
order last created unit to ....effect.... PICKED unit
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
*mumbles something about incompetence

Oh well, here is the solution. Use dummy units of course and yes, you need a variable (so it won't really be multiinstance unless you use JASS). Call it... g and make it an unit group. Also have an unit varaible called u. Now, have a look at this trigger:

For Integer A from 1 to Random Integer between 1 and 15 do actions
-> set u = Random Unit From Unit Group ((Units In 1000 range of (Triggering Unit))) Matching Condition (Picked Unit is an Enemy of (Owner of (Casting Unit))) equal to true
-> Add u to g //Add Unit to group action
-> Create 1 Dummy Unit for Owner of (Casting Unit) at (Position of u) facing 0.00 angle
-> Add 1 second Expiration Timer to (Last Created Unit)
-> Order (Last Created Unit) to Orc - Raider - Ensnare u

set u = null
set g = null

That should avoid MOST of the leaks. To know more about leaks, look in the FAQ.

~Daelin
 
Level 2
Joined
Mar 10, 2005
Messages
19
ähm yes i didnt notice it was supposed to be for only 15 units. well i notice me doing this mistake very often. i only read the main things and forgot the details, sry for that. once i wrote an physics exam and i didnt read that at the end of the bottom has been clearly said: plz write all the varaibles before you use the value. the complete exam was correct. but the teacher didnt gave me an A he gave me a B- caus i didnt work with the variables..... LOL yesterday i wrote a maths exam and did nealry the same mistake. i know this is quite off topic but i only want to excuse me for doing such mistakes.
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
There is no problem... I may have been a little harsh but these comments and controverses kinda caught me in too. Dragon_Lord, check what I told you, and if it works, I will close this thread (no more spamming :p).

I know I'm a little bit strict about closing threads guys and I don't mean to be strict, but I just want to avoid spamming. I think the Offtopic section has enough spammers and gives enough opportunities (I hate it...). Oh well...

~Daelin
 
Status
Not open for further replies.
Top