Critical Strike

From HIVE
Revision as of 06:16, 21 November 2010 by DevliN (talk | contribs) (1 revision: StarEdit.net Wiki)
Jump to navigation Jump to search

All credit goes to Neki for writing this tutorial. Please give credit to him if you decide to implement this in your map (unless he says otherwise of course :D ).

Overview

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 much easier to handle.

Instructions

1. Damage Effect

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.

DuplicateObject.jpg

ModifyObject.jpg

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.


2. The Trigger

2a. Events

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.

ConfigureEvent.jpg

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

WholeTrigger.jpg


2b. Setting up the Local Variables

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.


2c. Conditions

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).


2d. Actions

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.


To Do

Things to do: Linking critical strike to an ability (so that it can level up)