Removing Special Effects After A Unit Dies

pladams9

Seth's Good-Twin
Reaction score
19
How can I remove all the special effects from a unit after it dies? I have a spell that adds a special effect overhead of the units it is cast on, and I'm not sure how to go about removing those once the unit has died. I guess I could make an array of units that have the effect, and then make a matching array of special effects, but I'm sure there must be a better way. How can I detect if and what special effects are attached to a given unit?
 

mems

Memory Lapse
Reaction score
24
there is no way to dedect what effects has been attached to a unit
Alternate ways are;

-The way that u mention here
-There is a function "Wait for condition" which makes tings easier that u said above
-Create dummy units and spells which have the effects you want, which will be created and make casted on targeted units in your spell so you dont need to worry about their death which makes effects outomatically disaapear
 

pladams9

Seth's Good-Twin
Reaction score
19
It would be so much easier if there was an action "Destroy all special effects attached to unit." The only problem with creating an array for the special effects is that I would have to make one of a set length. I don't know of anyway to make a dynamic array. Unless I make an extremely large one. Which could work since you can have only so many units in the game, and the spell could be cast on only so many units. The array wouldn't even have to be _extremely_ large. It could probably be around 2400 values big, which I just realized is extremely big. But that would definitely take care of it. Anyone have a better idea?
 

mems

Memory Lapse
Reaction score
24
forex you have 3 attached effects left hand, right hand, and head

So u will need 3 arrays.

To define the array index you can use custom value of unit so if a unit dies
set last created special effect ArrayLeftHand[CustomValueOf(Targeted unit..)]
a unit dies,
special effect destroy(ArrayLeftHand[CustomValueOf(DyingUnit)])
 
S

Sanitarium

Guest
Jass > All

I don't know if you know Jass, I'm guessing not, :(, but this could be done easily with Jass. If your interested, I'll track down the links to get you started.

If you do indeed know Jass, then you should read This thread on Handle Vars

You should be able to figure it out from there :)
 

pladams9

Seth's Good-Twin
Reaction score
19
Wait just a minute... I think I may have misunderstood something about arrays. When you create an array, is the size of the array equal to how many dimensions it has or how many values it can hold? I have been assuming that it is the latter, but if it is the number of dimensions, then this is an easy problem to fix.

P.S. And no Sanitarium, you're right I haven't learned JASS yet, but I probably should. I do have some experience with programming, so I don't think it should be to hard. And that link looks like it could really help.

P.P.S. Never mind. I tested it and the size is just the length of a one-dimensional array. But I think I can get this to work now anyway.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
The size of the array meens nothing, promise. It only matters when it is a unit group or player group array. Else than that it is completly worthless.

The only thing it does is to asign a vaule to each index that is lower or equal to the size, for unit and player groups this makes so that you can add a player/unit to the group before you do a "set group = something".

You can simulate a 2d array with replacing the index with this (x-1)*ymax+y
where x and y is the vectors(is that the correct word) and ymax is the maximum size of y. In your case it is 3 (3 attachment points). x is the custom vaule of the unit.
 

pladams9

Seth's Good-Twin
Reaction score
19
Well, I don't actually have 3 attachments. And actually, I have simlulated a 2-dimensional array that way before. When I had first started programming I messed around with some stuff like that. But anyway, thank you! I finished my spell, and hopefully you will like it.

It's called Spite, and it's a sort of possession spell. Test it out.
 

Attachments

  • Spite_Spell.w3x
    10.8 KB · Views: 134

mems

Memory Lapse
Reaction score
24
phyrex1an said:
The size of the array meens nothing, promise.

In small numbers yes but in large numbers you need to set a value to it i had this problem when i try to store all creeps in an array in my first map

Also about the spell
Firs of all wellcome to trigger world but when you enter spell making issues you need to learn something about Jass u can start from here:

http://wc3sear.ch/viewtopic.php?t=10112
and here:
http://www.wc3campaigns.com/showthread.php?t=74894

in first turtorial there is a section about memory leaks and u should take this subject serious.

About your spell:
Nice addition to charm but u must limit this spell couse it will be too abivous if you can cast it to all units with small duration. It likes killing units in 1 shot specially never make it can castable to heros.
- Triggers:
Code:
Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - (240.00 + (20.00 x (Real((Level of Spite  for (Casting unit)))))))
Never use that There is an option in object editor to do this. Why not to use it? Do as much work as possible in object editor and at least as possible in trigger editor. It will keep your map size even smaller and have better performance.

every 1 second your trigger tries to demage units even if there are no units around. After u get smiliar with local variables and functions read this one:
http://www.wc3sear.ch/viewtopic.php?t=5224
Ah be sure that the syntax is wrong there the one who wrote the answer has forgatten write call's to start of handle functions and some with capitals he wrote StartTimer which mus be TimerStart ect.

never use Unit - A unit Begins casting an ability
use Unit - A unit Starts the effect of an ability instead couse beginning can be cancelled anytime like your hero can die or start another spell..

Target unit of ability being cast is calling a function when you write there u already assigned this unit to a variable so why dont u use that instead of calling a function all the time? Also u MUST assign all releated units to variables at the top and use them instead of this kind of functions couse if another unit casts the same ability then targets becomes another unit..

Unit - Make (Target unit of ability being cast) Invulnerable
I hope this was for presentation couse it is alot much more abivous also dont make such things for presentations keep people to see the spell at real action.

Unit - Set life of (Target unit of ability being cast) to 100.00%
Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) - (100.00 / 15.00))%

come on you can make it better there is a current life of unit function there so make people mad when they capture a demaged unit :)

good luck keep working on spells couse this is fun when you see they are working :D
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
mems said:
In small numbers yes but in large numbers you need to set a value to it i had this problem when i try to store all creeps in an array in my first map

Actualy, i find that very wierd. After you said that I made a unit array and a unitgroup array both with size 8000 and looked at the initglobals function and the global section of the map:

Code:
globals
    // User-defined
    group array             udg_group
    unit array              udg_unit

    // Generated
    trigger                 gg_trg_Melee_Initialization = null
endglobals

function InitGlobals takes nothing returns nothing
    local integer i = 0
    set i = 0
    loop
        exitwhen (i > 8000)
        set udg_group[i] = CreateGroup()
        set i = i + 1
    endloop

endfunction


It doesnt even touch the unit array after it declared it. And remember: in RoC you couldent choose the size.
This is starting to confuse me :confused:, i beleve you when you say that it caused problems, but I cant see why.
 
H

Heptameron

Guest
pladams9, these special effects you're attaching are permanent until the unit dies?

This is what I know about arrays (secondhand, mark you, but I believe it's accurate):

Arrays can hold up to 8,192 values. This does not mean from indexes 1 to 8,192; instead it means that it can hold 8,192 values total... even if the indexes are 0, 474, 4, 34845, 8193, etc.

When you choose a size, it merely initializes the indexes 0 to the size you chose (so it actually creates one more index than you say). For unit groups, player groups, timers, dialogs, etc. this means creating one object per index. For most other arrays, it doesn't mean anything. (I'm not sure what happens if you actually try to access a value that hasn't been set. I know it's bad for non-arrays, but I've never tried it for arrays. It's just one of those things that you shouldn't do anyway.)
 

mems

Memory Lapse
Reaction score
24
yes i see no problem too but i saw another problem

Code:
function InitGlobals takes nothing returns nothing
    local integer i = 0
    set i = 0
    loop
        exitwhen (i > 8000)
        set udg_group[i] = CreateGroup()
        set i = i + 1
    endloop

endfunction

Code:
set udg_group[i] = CreateGroup()
There will be 8000 objects created for a single array

I think i will do all my map with Jass... I will take a look at my old map to see what was the problem and edit this post if it was not about arrays
Edit: yep asigning a value does not meaned anything it was something wrong about the loop integer sorry for that :(
 
H

Heptameron

Guest
mems said:
Code:
set udg_group[i] = CreateGroup()
There will be 8000 objects created for a single array
That's because he set the size of the array to 8,000.
 

pladams9

Seth's Good-Twin
Reaction score
19
Code:
Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - (240.00 + (20.00 x (Real((Level of Spite  for (Casting unit)))))))
Never use that There is an option in object editor to do this. Why not to use it? Do as much work as possible in object editor and at least as possible in trigger editor. It will keep your map size even smaller and have better performance.

Well, I based my spell off of Channel, which does not remove mana from the caster, it only prevents the use of the spell if there is not enough mana.

Unit - Make (Target unit of ability being cast) Invulnerable
I hope this was for presentation couse it is alot much more abivous also dont make such things for presentations keep people to see the spell at real action.

Actually, that wasn't for presentation. I thought, what is the point of getting a unit that is 'poisoned' if it's not going to be killed by it.

Unit - Set life of (Target unit of ability being cast) to 100.00%
Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) - (100.00 / 15.00))%

come on you can make it better there is a current life of unit function there so make people mad when they capture a demaged unit

I might change this, but (again) I wanted the spell to be the cause of death.

I will probably change this to be an ultimate spell with a duration of 30 seconds and possibly increased mana cost (300-400).
 

mems

Memory Lapse
Reaction score
24
Well, I based my spell off of Channel, which does not remove mana from the caster, it only prevents the use of the spell if there is not enough mana.

No when u assign a value to mana coast in object editor it coast mana to cast.. At least it works in my editor...
 
H

Heptameron

Guest
mems said:
No when u assign a value to mana coast in object editor it coast mana to cast.. At least it works in my editor...
He's saying that doesn't work with the Channel spell specifically.
 
H

Heptameron

Guest
darklord5907 said:
Use the "Remove all SXF from unit" code
Do you have a custom World Editor? That doesn't exist in the normal editor.
 
D

darklord5907

Guest
Im joking, and yes I do have an editor and its not custom, but my comp got erased because of a virus, so I have no files or refrence
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top