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

[System] Unit Properties

Level 8
Joined
Aug 6, 2008
Messages
451
If you read the comments, you see that its just a wrapper, which can be replaced with any unit indexing or data attachment system.

It should probably be made to require AutoIndex or something, but then again, its not a big job to edit UP code a bit and make it work so.





Also, since Cassiel posted this here just for those who already use the system to get the code from somewhere, I think it doesnt really need any updating, unless he releases that UP2 he mentioned in the first page of this thread.


So, currently its probably the best to just edit the system code by yourself and hope that this new UnitProperties will be realeased someday.
 
Level 5
Joined
Aug 15, 2007
Messages
145
Could you make a template using your system that when a unit buys an item, +damage and +stats are added to that unit, and when the unit loses/does not have that item again restore his stats to the way they were before the item? Would greatly help :)
 
Level 8
Joined
Dec 1, 2006
Messages
342
You just detect when a unit acquires an item and when a unit drops an item. Then you search for what that item is, and add (or remove) thee bonuses it gives. It's rather simple, maybe a little annoying using many if conditions while searching for the item id.



private function onItemPicked takes nothing returns nothing
local integer it = GetItemTypeId(GetManipulatedItem())
local unit u = GetTriggerUnit()
if it==RING_OF_REGENERATION_ID then
call UnitModifyLifeRegen(u, 2.0)
elseif it==SOBY_MASK_ID then
...
...
...
endif
endfunction

private function onItemDroped takes nothing returns nothing
local integer it = GetItemTypeId(GetManipulatedItem())
local unit u = GetTriggerUnit()
if it==RING_OF_REGENERATION_ID then
call UnitModifyLifeRegen(u, -2.0)
elseif it==SOBY_MASK_ID then
...
...
...
endif
endfunction

private function Init takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(Trigger1, EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddAction(Trigger1, function onItemPicked)
call TriggerRegisterAnyUnitEventBJ(Trigger2, EVENT_PLAYER_UNIT_DROP_ITEM)
call TriggerAddAction(Trigger2, function onItemDroped)
endfunction
 
Level 8
Joined
Aug 6, 2008
Messages
451
You should probably write some BonusMod like thingy that gives you a bonus parent type, that contaijns all of those properties. It could contain those if then else thingies for modifying the correct property, and so allow you to just attach this bonus instance to item, and make all items work with same onPickup and onDrop -triggers that just get the attached bonus struct and add bonuses from it to your unit.
 
Level 3
Joined
Dec 16, 2010
Messages
31
I am having a problem with this system. Whenever I remove a certain amount of armor, it will never go into negatives.

For example, I add 16 armor. That works. I subtract 16 armor. That works, and I am back at 0. I subtract 16 again, but nothing! no red -16.

Is this on purpose? Anyone else run into this?

Edit2: I found the problem. For some reason I changed the offset in the code to 2048 from 512 thinking it had to do with stat increases when in fact it was the difference between positive stat/negative stat ability id's.
 
Last edited:
Level 13
Joined
Jul 26, 2008
Messages
1,009
I'm having an issue with this system. Whenever I give a unit damage, such as a unit summoned, the damage on the next unit is higher than the last summoned unit. This continues until the summons have ridiculous damage. It's as though the properties don't get reset. Any reason why this may be? I've plugged in AutoIndex, but that should help.

Thanks.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I don't think Cassiel (or Litany on wc3c.net) is going to come here and put work into something he probably considers a "finished product". I'm quite certain that in his mind everybody other than his select few "elite" friends are capable of anything close to what he is, and he most likely does not value the opinion of a moderator on this site.

I mean, look at how much of his work the rest of the community has seen from Tides of Blood. There aren't any public resources, no demonstrations of things that he considered "difficult" or that would be "helpful" to others.

If you plan on putting this in the Submissions forum again I wouldn't hold your breath waiting for anything.
 
JASS:
    function GetUnitId takes unit u returns integer
        return GetHandleId(u)-0x100000
    endfunction

    struct Id
        static method operator [] takes unit u returns integer
            return GetUnitId(u)
        endmethod
    endstruct

Just can't see nonsense like this in the "approved resources" section, and while I see your point I'm not going to instant-graveyard this without even the slim possibility of him updating it first.
 
Level 15
Joined
Oct 16, 2010
Messages
941
I'm using this in my map, and there are tons of glitches and problems with it. At random points it will just glitch up and give a unit a huge stat bonus and every point from then on it will do the same for every other call. All I am using it for is the damage bonus, but it's still frustrating.

Looking above it seems i'm not the only person experiencing problems like this.
 
Level 3
Joined
Mar 7, 2004
Messages
37
JASS:
    function GetUnitId takes unit u returns integer
        return GetHandleId(u)-0x100000
    endfunction

    struct Id
        static method operator [] takes unit u returns integer
            return GetUnitId(u)
        endmethod
    endstruct

Just can't see nonsense like this in the "approved resources" section, and while I see your point I'm not going to instant-graveyard this without even the slim possibility of him updating it first.
Half the library was syntactic sugar while we waited for vJASS wrappers to be implemented. In the above case, it's unit:Id. All properties are accessible this way, as the first post mentions.

I stopped modding WC3 quite some time ago and, other than the 1.24b switch and circumventing a JassHelper bug, haven't updated the public version of Unit Properties since 2008. Do go ahead and graveyard it.
 
Top