HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

2 questions, about a spell and items

07-07-2005, 03:10 AM#1
TaintedReality
First question is, how do I get the amount of damage a unit did on his attack? Or how much damage he would do if he did attack. I'd like to use this in some abilities with my melee chars. I think there's a way to do this but you have to use the specific unit event..and thats going to be too much work if I want to use that.

Second question is, is there any way to make an item system where random buffs/abilities are applied to the item? Or would I have to make out all the items before? For example, when someone kills a unit and a sword is supposed to drop, I want the sword to have a random damage type bonus(or something like that). I know I could do this by just making all the possible bonuses for each type and quality of weapon..but if there's any way to get this to work it would save a lot of time and make the whole system easier to work with. Thanks for the help.
07-07-2005, 05:17 AM#2
Limb_Smasher
1. no one responded to my thread about this so i dont know

2.i dont how this will work in your map whether it be too much or something like that, and i just thought of this so it hasnt been tested or anything of that sort. ok my idea is that you create one sword (using your sword example). and it dropped off a guy. you could then make a trigger saying something like these.
Code:
Preping The Abilities
    Events
        Map initialization
    Conditions
    Actions
        Set NumberOfAbilities = 4
        Set ItemAbility[1] = +10 Damage
        Set ItemAbility[2] = 20% Increased Attack Speed
        Set ItemAbility[3] = Vampiric Aura
        Set ItemAbility[4] = +15 Damage

Code:
The Sword
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Sword
    Actions
        Set randomint = (Random integer number between 1 and NumberOfAbilities)
        Unit - Add ItemAbility[randomint] to (Triggering unit)

something along those lines. if you were gonna add abilities to the items youd have to create another so it could be actively used. NumberOfAbilities is a integer variable, ItemAbility an arrayed ability variable, and randomint is an integer variable. Bad thing... a unit could pick an item up and drop it until they got what they wanted...:\

hope this helps
07-07-2005, 05:38 AM#3
EdwardSwolenToe
There is no real way to get a unit's attack. The best you could do is use a unit is damaged event. But that accounts for all damage, and not just attack.
07-07-2005, 06:13 AM#4
TaintedReality
Ohh so using the Unit - Add Ability works for items too. Well that makes things a lot easier :). I'll just have it happen when a unit dies and the item is created. Thanks.

Edit: I found a way that I believe would work to find the unit's damage. However, it might be kind of unflexible, but it still would work with a lot of abilities. You would need to edit it so there are no leaks,its multiinstanceable, etc. I just threw this up really quick as a base.

Code:
StartAbility
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Explosive Strike
    Actions
        Set CastingUnit = (Casting unit)
        Set TargetUnit = (Target unit of ability being cast)
        Set Running = True
        Unit - Order CastingUnit to Attack TargetUnit

Code:
GetAttackDmg
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacking unit) Equal to CastingUnit
        (Attacked unit) Equal to TargetUnit
        Running Equal to True
    Actions
        Set StartLife = (Integer((Life of TargetUnit)))
        Wait 2.00 seconds
        Set EndLife = (Integer((Life of TargetUnit)))
        Set UnitDamage = (StartLife - EndLife)
        Set Running = False
        Trigger - Run FinishAbility <gen> (ignoring conditions)

Code:
FinishAbility
    Events
    Conditions
    Actions
        Special Effect - Create a special effect attached to the origin of TargetUnit using Objects\Spawnmodels\Human\FragmentationShards\FragBoomSpawn.mdl
        Unit - Order CastingUnit to damage TargetUnit for 50.00 using attack type Spells and damage type Normal.

This would just be for a simple ability that adds 50 damage to the unit's normal damage, along with an explosion speciall effect. However, you could edit this to do double damage, steal health/mana, deal damage based on an alternate attribute, etc. Also, I think it is cool that the hero has to go through the attack animation and wait for the attack to finish. Hopefully this works, I haven't really tested it out yet but I should soon when I start to create my warrior class.
07-07-2005, 10:37 AM#5
Guest
The best way to get a unit's attack is probably take the HP of the unit it is attacking. After it delivers the damage, subtract the old HP from the new HP. There are also many other ways, but they are extremely innefficient. That way is the best I've got since I don't know any JASS :D
07-07-2005, 06:33 PM#6
Limb_Smasher
Quote:
Originally Posted by Lord_Carbo
The best way to get a unit's attack is probably take the HP of the unit it is attacking. After it delivers the damage, subtract the old HP from the new HP. There are also many other ways, but they are extremely innefficient. That way is the best I've got since I don't know any JASS :D

but that wouldnt work if you were attacking random units, could it? because the event is "when a unit is attacked." isnt that the second the unit is attacked?
07-07-2005, 07:41 PM#7
TaintedReality
I just thought of something else. Instead of using the casting unit to attack the target, make a copy of the casting unit with the same attributes and items, but no model. Also, set his attack time to as fast as possible. The problem I found with the code I wrote up there was that if something else was damaging him during that 2 second period it could really screw things up. Then just have the casting unit go through and attack animation, but not really attack. Maybe that will work better.
07-13-2005, 01:21 PM#8
Guest
The generated Item add abilities to the unit who carrying it.
That must use item match condition.
So the same Item-type item can give diffrent abilities.
Just use custom value of item and spell_1[ ],spell_2[ ]
In mapinti U set the spell_1[1]=ItemAbilities1,spell_1[2]=ItemAbilities2,......
spell_2[1]=ItemAbilitiesX,.......
itemtype[1]=Itemtype1,......
spell_1[ ] for base Ability , just like Dam,Def.
Spell_2[ ] for plus Ability, just like Increased Attack Speed,+ attrib X,etc.
So when a creep died, judge his lev, generate a random value LEV based his lev,
then generate the value of Id_spell_1[Id_item],Id_spell_2[Id_item],Id_Itemtype[Id_item],
Creat the Itemtype[Id_item],
set the custom value of item to Id_item.
Id_item++

event:a unit aquire an item.
conditions:----
action:Aq_Item=custom value of item
add spell_1[Id_spell_1[Aq_item]] to the Triggering unit
add spell_2[Id_spell_2[Aq_item]] to the Triggering unit
Aq_Item=0

event:a unit lost an item.
conditions:----
action:Aq_Item=custom value of item
remove spell_1[Id_spell_1[Aq_item]] from Triggering unit
remove spell_2[Id_spell_2[Aq_item]] from Triggering unit
Aq_Item=0

The real sys is more complex.