| 01-02-2010, 08:10 AM | #1 |
This is quite a bit of a request, but here goes anyways: shadow1500's old Shield System was broken by the latest patch, as it used the old return bug, but it found well use in one of the maps I was developing and have returned to. I was wondering if either anyone could update it or perhaps produce one for the benefit of all, if the latter perhaps with the added functionality to perhaps 'heal' the shield by means other than its internal regen, and perhaps a way to set dynamic regeneration, such as being able to base the regen on how much shield strength is remaining. Anyways, this is just a request to anyone who's bored enough to do it, I really don't have anywhere close to the understanding of either JASS or programming to be able to do this myself, nor really the time to take on such a challenge, and I think it could benefit many people. Cheers, -Zyrixion |
| 01-02-2010, 02:00 PM | #2 |
There is a shield system here, http://www.wc3c.net/showthread.php?t...hlight=Adamage. But might be too advanced for you |
| 01-03-2010, 03:51 PM | #3 |
Try the one that has superseded that script. |
| 01-03-2010, 06:01 PM | #4 |
Yeah, I'm afraid that it is a bit out of my league, with nothing to help me figure out what to do with it and how to use it. Which is a shame, because it looks like it would do just what I needed it to. What I liked about the one I mentioned before is the ease of use and implementation. Unless the others are fairly easy to work with as well, and I'm just getting overwhelmed trying to take in the code. I'm pretty good at reading code, but not too good at understanding higher level coding yet. |
| 01-04-2010, 12:37 AM | #5 |
Shield systems aren't easy, and you even want more than a shield system. No one will just code one for fun. You'll have to either learn to use Anitarf's or make your own =/ I did a quick search for you and found this. http://www.hiveworkshop.com/forums/s...Dlist%26r%3D20 |
| 01-04-2010, 01:14 AM | #6 |
I could probably code a shield system using Anitarf's system in 5 minutes if you give me a detailed description of what you want it to do. |
| 01-04-2010, 01:52 AM | #7 | |
Quote:
Using DamageModifiers shouldn't be too hard, there's an example right in the documentation: JASS:struct armour extends DamageModifier // All additional struct members are optional: static integer PRIORITY=0 // Default priority real power // This lets us give different units differently strong armour. // create method is optional, if you don't declare one then you must use // the .allocate parameters (unit, integer) when creating a modifier of this kind. static method create takes unit u, real power returns armour // Note the parameters for .allocate, this is because this struct extends // DamageModifier which asks for these parameters in its create method: local armour this = armour.allocate(u, armour.PRIORITY) set this.power = power return this endmethod // This is the method that runs when damage is dealt to the unit with the modifier. // The damage parameter tells how much damage got to this modifier past any modifiers // with a higher priority that the unit may have. // The value that the method returns tells the system by how much to modify the damage, // a positive return value increases damage while a negative value reduces it. method onDamageTaken takes unit damageSource, real damage returns real // This is a simple modifier that just gives a flat damage reduction. if this.power>damage then return -damage endif return -this.power endmethod // There is no onDamageDealt method so this modifier does not affect the damage that the unit deals. // onDestroy method is optional, in this case we don't need it. endstruct // Simply add an armour to a unit using the create method: call armour.create(u, 10) // Gives unit u 10 armour. Okay, so this example shows how to make an armour that gives a flat damage reduction, but it's easy to convert the code into a shield: JASS:struct shield extends DamageModifier real hp static method create takes unit u, real shieldhp, integer priority returns shield local shield this = shield.allocate(u, priority) set this.hp = shieldhp return this endmethod method onDamageTaken takes unit damageSource, real damage returns real if this.hp>damage then set this.hp=this.hp-damage else set damage=this.hp call this.destroy() endif return -damage endmethod endstruct So far, simple enough. When created, such a shield will block all damage until its hp runs out. Now to make it possible for a shield to only block a percentage of the damage, also, let's allow shields to have unlimited hp: JASS:struct shield extends DamageModifier real hp real factor boolean limited static method create takes unit u, real shieldhp, real blockfactor, integer priority returns shield local shield this = shield.allocate(u, priority) set this.hp = shieldhp set this.limited=not(shieldhp==0.0) set this.factor = blockfactor return this endmethod method onDamageTaken takes unit damageSource, real damage returns real set damage=damage*factor if this.limited then if this.hp>damage then set this.hp=this.hp-damage else set damage=this.hp call this.destroy() endif endif return -damage endmethod endstruct Now let's add hp regeneration (using TimerUtils): JASS:struct shield extends DamageModifier real hp real maxhp real regen real factor boolean limited timer t static real REGEN_PERIOD = 0.1 static method regenerate takes nothing returns nothing local shield this = shield(GetTimerData( GetExpiredTimer() )) set this.hp=this.hp+this.regen*shield.REGEN_PERIOD if this.hp>this.maxhp then set this.hp=this.maxhp endif endmethod static method create takes unit u, real shieldhp, real hpregen, real blockfactor, integer priority returns shield local shield this = shield.allocate(u, priority) set this.hp = shieldhp set this.maxhp = shieldhp set this.regen = hpregen set this.limited=not(shieldhp==0.0) set this.factor = blockfactor set this.t=NewTimer() call SetTimerData( this.t, integer(this) ) call TimerStart( this.t, shield.REGEN_PERIOD, true, function shield.regenerate ) return this endmethod method onDamageTaken takes unit damageSource, real damage returns real set damage=damage*factor if this.limited then if this.hp>damage then set this.hp=this.hp-damage else set damage=this.hp call this.destroy() endif endif return -damage endmethod method onDestroy takes nothing returns nothing call ReleaseTimer( this.t ) endmethod endstruct This code should now be capable of handling most types of shields. Further additions could include stuff like shield special effects and limited shield durations, also, a more sensible implementation of regeneration would use a single timer, but this is all I have time for tonight. |
| 01-09-2010, 03:37 AM | #8 | |
Quote:
I would like a spell similar to Power Word in WoW, where a unit has a temporary "shield" which absorbs damage but does not prevent. So if Attacker deals 40 dmg to Shielded unit, and the Shield prevents 20, the other 20 does get dealt to Shielded Unit |
