• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Coding an on-hit ability from scratch / DDS

Status
Not open for further replies.
Level 4
Joined
Sep 25, 2005
Messages
71
Okay. So not sure where to start with this one. I don't really aim to just implement a complete DDS here, ideally I'd like to learn how to code some basic functions.

I'm trying to create an ability which is -not- an orb ability (not just trying to object editor a Lightning Orb with a certain ability,) which will proc an effect periodically - when the unit successfully makes an attack against a valid target. For now, let's just say it creates a special effect, does 50. spell damage, has a 100% chance to hit (I'd like to code it in a way that I can basically interchange the chance just in case I ever go down the dark path that is Chance-On-Hit...) but can only happen every 5 seconds.

I'm not sure if this is correct, but I'm trying to code something along the lines of Kunkka' (from DotA) passive.

Starting from the bottom up, what can I use to have an event, register the type and source adequately to detect whether it was from spelldamage (ideally a specific spell,) or from an auto-attack?
 
Someone didn't read the question :)

From the bottom up, you have to first understand that there exists an event:

call TriggerRegisterUnitEvent(trigger,unit,EVENT_UNIT_DAMAGED)

But there does not exist an event "any" unit damaged (whereas there is the event "any" unit dies, etc)

So, using this event, you must create a damage detection system by registering ALL units this way.

Hope this helps!
 
Level 4
Joined
Sep 25, 2005
Messages
71
Someone didn't read the question :)

From the bottom up, you have to first understand that there exists an event:

call TriggerRegisterUnitEvent(trigger,unit,EVENT_UNIT_DAMAGED)

But there does not exist an event "any" unit damaged (whereas there is the event "any" unit dies, etc)

So, using this event, you must create a damage detection system by registering ALL units this way.

Hope this helps!

Sort of. I knew there was no "a unit is damaged" generic EVENT.
So what you're saying is I have to find some way to set every unit as a specific unit (for specific unit damaged,) right?

As for the other two above, I'm not above learning from others' codes, but I'm looking to make a remedial one on my own for a number of reasons: mostly to gain a better understanding of things and for the experience.
 
Sort of. I knew there was no "a unit is damaged" generic EVENT.
So what you're saying is I have to find some way to set every unit as a specific unit (for specific unit damaged,) right?

As for the other two above, I'm not above learning from others' codes, but I'm looking to make a remedial one on my own for a number of reasons: mostly to gain a better understanding of things and for the experience.

You won't learn anything from Nestharus' DDS resource.

Try this:

Create a trigger with no event, but in the actions "do everything" that happens to a unit that gets attacked.

Then create another trigger with 2 events: One whenever a unit enters the map (new unit is created), and another on initialization (all units on the map at the beginning)

In this second trigger, add the action: "add event to trigger (trigger 1) specific unit is attacked".

Make sense?

This is the most common approach. If you get this right I'll tell you more about why it's not perfect and so on.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
When a unit enters the map (Unit doesn't have Locust ability) add it to a Unit Group and add "Triggering Unit enters to Playable map area". Every 15 seconds destroy the trigger, pick every unit in the unit group, if unit is alive, re-add it to the Damage Detection trigger, if it's dead, remove it from the UnitGroup.

When a unit takes damage, set the Damage Source and Damaged Unit to global variables so you can handle them easily.

This, however, detects any kind of damage. You'll have to implement your own Magic Damage system to difference one from another.
 
This is the core of DDS, which is integral to any system working with damage events =). From this, you can actually learn stuff. There are many ways to do this, but the idea of trigger refreshing is here.

http://www.hiveworkshop.com/forums/...ems-using-single-unit-events-like-dds-231167/

I find it ridiculous that you think unit user data, low level understanding of heaps and linked lists are necessary for teaching someone how damage detection works in wc3

Eve of the apocalypse, a very large scale game didn't even refresh triggers until a few months ago. I'd be surprised if dota did too.
 
Status
Not open for further replies.
Top