| 12-31-2009, 10:26 PM | #1 |
I tried looking through JASSHelper but I still don't quite get what the term static does in a struct. In normal programming it means like makes the entire program have access to that method/variables. But I'm confused it's purpose in a struct. If anyone would be so kind as to tell me when it comes in handy? |
| 12-31-2009, 10:36 PM | #2 |
I also have 2 other unrelated questions: 1) What's the best way to keep a units health at 1 (such as disabling health regeneration) and without the use of a timer. 2) Do item abilities stack? (Example, if I put on Item Armor Bonus that adds +4 armor, if I add another ability off the same base Item Armor Bonus, but instead it -4 armor, will the net result be 0 armor gained) |
| 12-31-2009, 11:03 PM | #3 |
It designates a specific character as static; they cannot undergo character development for the course of the novel. ???:struct X static integer INT = 0 integer int = 0 endstruct function yessa takes nothing returns nothing local X this = X.create() set this.int = 7 set X.int = 7 set this = X.create() set this.int = this.int - 6 set X.int = X.int - 6 call BJDebugMsg(I2S(this.int)) // prints "-6" call BJDebugMsg(I2S(X.int)) // prints "1" endfunction A better way to explain:struct Wat static integer N integer count endstruct // Compiles - > globals integer s__Wat_N integer array s__Wat_count endglobals Static makes it essentially a global with the STRUCTNAME.<blah> prefix. It's not instance specific. There's only one. Wikipedia: Class variable Yahoo Answers: What's the difference between static and instance members? --- You can stack item abilities if they are different abilities; Example:
Ability A (+4 armor) Ability B (+4 armor) Ability C (-4 armor) A + C = 0 A + B = 8 A + A = 4 Ax10 = 4 A + B + A + C = 4 B + B + B + B + C + C = 0 BonusMod (item abilities) --- Keeping a unit from regenerating HP could be done with a -100% Unholy Aura Regen, but keeping a unit's HP at exactly 1 is an entirely different thing (assuming you don't want it to die when it takes damage) and therefore DOES require a timer, or a Resistant Skin -50000 ability or Elune's Grace -100% ability. Maybe. This last one is speculation on my part because I don't feel like opening the editor. |
| 12-31-2009, 11:34 PM | #4 | |
Quote:
Okay thanks. I had the Unholy Aura idea in mind but wanted some confirmation. (And no, the unit will be invulnerable so it can't take damage) |
| 01-01-2010, 02:26 AM | #5 |
I just tested it. It's actually killing the unit, and causing an infinite loop. It's set to -1.00 and percent bonus is on true. |
| 01-01-2010, 02:10 PM | #6 |
Why wouldn't you want to use timers...? Anyway, if you can store the unit's current max hp, you can use .: UnitMaxState :. to set its max hp to 1 (then reset it to the stored value at will). |
| 01-03-2010, 09:31 PM | #7 |
Yeah I ended up using a timer for this. Thanks for the help /close |
| 01-04-2010, 06:00 AM | #8 |
> 1) What's the best way to keep a units health at 1 (such as disabling health regeneration) and without the use of a timer. Use Slow Poison on the unit. |
