| 07-03-2005, 01:17 AM | #1 |
I'm trying to make it so when a unit takes damage, if the unit that hit him is a hero then 1 is added to a variable. This is used because in my map the more you attack people, the more your strength goes up, instead of gaining strength every level. Also when the hero TAKES damage his agility goes up. The intelligence part doesn't matter for this question. I used to have it all in GUI but the problem with that is that there is no Unit Takes Damage event, and if I use Unit is Attacked then the player can just right click on an enemy and press stop before he actually attacks, which allows for very fast strength gaining when he's not actually hitting anything. So I converted the trigger to JASS, and changed the event to EVENT_UNIT_DAMAGED, however, I don't know what the correct condition would be for this. Here is my current script. Code:
function Trig_Strength_Copy_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetAttacker(), UNIT_TYPE_HERO) == true ) ) then
return false
endif
if ( not ( IsUnitAlly(GetAttacker(), Player(10)) == false ) ) then
return false
endif
return true
endfunction
function Trig_Strength_Copy_Actions takes nothing returns nothing
set udg_HeroStrength[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] = ( udg_HeroStrength[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] + 1 )
endfunction
//===========================================================================
function InitTrig_Strength_Copy takes nothing returns nothing
set gg_trg_Strength_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Strength_Copy, EVENT_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Strength_Copy, Condition( function Trig_Strength_Copy_Conditions ) )
call TriggerAddAction( gg_trg_Strength_Copy, function Trig_Strength_Copy_Actions )
endfunctionI need to change the GetAttacker part to whatever the correct code is to get the damaging unit. I would also like to know how to get the damaged unit for my agility trigger. And, I really don't know much about JASS, just enough to keep my maps from leaking too much, so I just converted my former trigger to JASS then edited the EVENT_PLAYER_UNIT_ATTACKED part to EVENT_UNIT_DAMAGED, which I think is the correct event but if I'm wrong just let me know. And by the way, the error it gives me is Invalid argument type (unitevent) which I'm pretty sure is just because the conditions need to be changed. But again, if I'm wrong about that just let me know so I can fix it. Thanks for the help, and sorry for making this post so long, but I wanted to make sure you understand what I'm asking =P. |
| 07-03-2005, 06:30 AM | #2 |
Oh, make no mistake, your event is wrong, it's nonexistent, actually. The only damage event that exists originaly in warcraft is the specific unit event, and it's avaliable in GUI. Of course, to make that work, you need to add a specific unit event to the trigger whenever a unit enters the map, or, to avoid a trigger getting filled up with events if a lot of units are spawning and dying, you would have to create a new trigger for every unit and then destroy it when that unit leaves play, but you would need to use JASS to do that. |
| 07-03-2005, 06:39 AM | #3 |
Ah..well like I said, I don't really know anything about JASS =P. Ok, well maybe I'll try to get some kind of specific unit thing going..or just hope nobody finds out that they can just press stop over and over again and get like a million strength ; ). Thanks. |
