Staredit Network > Forums > SC2 Assistance > Topic: Critical Strike tutorial (Starcraft II)
Critical Strike tutorial (Starcraft II)
Apr 30 2010, 7:16 am
By: Neki  

Apr 30 2010, 7:16 am Neki Post #1



Okay, a common staple in RPG maps has always been the coveted Critical Strike ability, and Starcraft II is no different. While there is no inherent critical strike ability present on any unit in Starcraft II (as far as I'm aware), we'll make one from scratch. While Warcraft III had to use somewhat of a attack detection system, Starcraft II can simply let you use a damage detection system, which is more much easier to handle. First thing's first, we'll need to create the damage effect that will happen when a critical strike occurs. Usually I browse the Effect Damage category in the Data Editor of Galaxy, and then just copy one of them (in my case, I'll be using the Dark Templar's damage effect.) If you want the upgrades to apply, make sure to check all the boxes (specifically the upgrade one) when checking the boxes. We'll be doing this to create a new weapon effect to act as the critical strike.


Right click and modify the object, give it something easy to remember by, not a big deal what you name it. We mostly need this for the damage effect itself (outlined in red). Change it to whatever you want, this copy will only be used for your critical strike ability. Once you're done, head over to the trigger editor.
Create a new trigger, and pick the event "Unit Takes Damage". Using this, we can detect when a unit is being damaged, and check what unit is damaging him. Do note that damage falls under several categories, such as melee, ranged, and spells. So you might need to create two instances if your unit acts as both ranged and melee, but we'll make it affect all things for now (my character will have no spells) but make sure to make it only affect the damage effect of your character (the one that comes from your character, in this case, Dark Templar - Warp Blades). This also allows you to specify the specific damage source being applied to any unit, but we'll keep it general for now, your "Unit Takes Damage" should look like this.

After all of that, you're going to need to set some stuff up.

The first part, are our local variables. The first one, unit variable, "Hero" dictates which unit critical strike affects. Second one is simply an integer variable that randomizes between 0-100. Third and fourth one are the unit variables representing the attack and defender, attack variable is equal to the "damaging unit" and the defender variable is equal to the "triggering unit", meaning the unit that triggered this event will be stored here.
The next part is our conditions, random, will dictate when this condition is true. Random <= 14 represents a 15% crit chance, while Random <= 49 represents a 50% crit chance. This will generate a random number every time the trigger is initialized. (Note, you should probably set the random variable to some number that is not in the range after you've executed it).
The next part, the actions, the first three actions are simply for the red "2.0x" to show up. You will need Create Text Tag for the first one, Show Text Tag for the second one and Set Time of Text Tag for the third one, once done, this will show up "2.0x" every time the trigger fires. The last part is the actual damage. You want to use "Create Effect on Unit (From Unit)", and then link the effect that you created in the first part. This acts like a critical strike, only applying the damage. And there you have it! My only problem is chain crits, still looking for a way to put a cooldown on it.

NOTE: I'm not sure if memory leaks are still present in Starcraft II, but to be safe, add a 1.5 second wait after everything is done, and then destroy the last created tag / dark templar - critical strike effect to be safe, for now.

Things to do:
Linking critical strike to an ability (so that it can level up)
Putting on a reasonable cooldown on it.


Attachments:
crit.SC2Map
Hits: 6 Size: 41.47kb

Post has been edited 6 time(s), last time on Apr 30 2010, 9:01 pm by Taylor Swift.



None.

Apr 30 2010, 2:57 pm Swampfox Post #2



Nice tutorial!
Also, it seems we need a tutorial section somewhere :omfg:



None.

Apr 30 2010, 5:59 pm Forsaken Archer Post #3



Add to the wiki please.
Critical strike, go go go.



None.

Apr 30 2010, 6:42 pm Swampfox Post #4



With your permission, Taylor, I'll put it up on the Wiki if you can attach the screenshots to your post. I'm rather bored right now...



None.

Apr 30 2010, 8:11 pm Neki Post #5



Why do you need them attached? Can't you right click and save them? :P Someone should help me find a way to link it to an ability though. I can only find a way to link them once I figure out how veterancy / leveling up works.



None.

Apr 30 2010, 8:35 pm Swampfox Post #6



Oh, duh :D
Hey, I'll start trying to hook it up to an ability and with veterancy levels and stuff as I've been working with veterancy a lot lately. How exactly would YOU want it to work with the veterancy levels?

And does this mean I can post this up on the wiki?



None.

Apr 30 2010, 8:49 pm Neki Post #7



Yeah, post it on the wiki. Well, if you look, I have a local variable == the ability level of some random ability. If we can make critical strike a passive ability that levels up with veterancy/triggers, we'll be able to link it to the trigger and I can dictate the trigger based on what level your ability of critical strike is, not too hard. I just need to find a way to make a passive spell ability that can level up without actually affecting the unit directly.



None.

Apr 30 2010, 9:23 pm Swampfox Post #8



It's up on the Wiki now, so, for any edits, go and hop on the Critical Strike (Tutorials) page and make your changes there.

Alright, I'll try and make it level up as your hero levels up, and be passive.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: Roy, Moose, RIVE