Advanced          Random


Powerup Item that Activates When Touched
Author: DragonGuard1 (sc2mapster.com)Tags: intermediate data  
Source: http://forums.sc2mapster.com/resour...Added 8 years ago 

While I was still working on my old map I needed to have some powerups that activated or got picked up when my character touched them. while searching the forum however I found that there wasn't really any solid example of how it could be done easily.

Example map: (link)

So, as my first post on this forum I've decided to share what I've found out with anyone else that might need this.

Note: You don't have to click a powerup item like you would with lootdrops, touching it with your selected unit will automatically make it "pickup" the powerup for a permanent boost in whatever stat you want. (you could use this for timed buffs as well but I wont be covering that in this tutorial)

In this tutorial ill make a powerup that increases the units speed, you can easily change this to do whatever you want.

Step 1: Creating the behavoir that will apply our stats bonus
Firs create a new behavoir with the following settings:

    * Name: MovementSpeed Increase
    * ID: (just hit suggest)
    * Behavoir Type: Buff
    * Based On: Default Behavoir (CBehavoirBuff)

Now set the following items like this:

    * Behavoir - Buff flags: Uncheck Countdown
    * Behavoir Modification: Go into the Movement tab and find "Movement Speed bonus", here change to whatever value you want, I used 0.5, click OK
    * Stats - Flags: Check Hidden
    * Stats - Maximum stack Count: 10 (or whatever you want to be the maximum number of times a single unit can gain this boost)

Step 2: Creating the needed effects
Now we will have to create 3 different effects, 1 to run our ability, 1 to remove the "powerup item" so it disapears as soon as it gets pickedup/touched and 1 set to bundle these 2 effects together.

Lets start by creating the effect that will apply the boost: Create a new object and give it the following settings:

    * Name: MovementPowerup
    * ID: (hit suggest)
    * Effect Type: Apply Behavoir
    * Based On: Default Effect (CEffectApplyBehavoir)

in its settings set it to the following: Behavoir - Behavoir: Select our above created behavoir, in our case "MovementSpeed Increase".

Now create another effect, this time we will make the effect that removes the powerup item:

    * Name: RemovePickup
    * ID: (click suggest)
    * Effect Type: Damage
    * Based On: CEffectDamage

Under its settings:

    * Effect - Death: Remove
    * Effect - Flags: Kill, No Kill credit
    * Target - Impact Location: Source Unit
    * Target - launch Location: Source Unit

Now that thats done lets create our last effect, the one that keeps these 2 together. Again create a new effect:

    * Name: MovementPowerupSet
    * ID: (click suggest)
    * Effect Type: Set
    * Based On: Default Effect (CEffectSet)

and under its settings:

    * Effect - Effects: first pick our "MovementPowerup" and second the "RemovePickup" (don't think it matters much but just to be on the safe side make sure you run the powerup first before killing it)

Step 3: Creating the Ability that we can give to the pickupitem
In the abilities tab create a new ability with the following settings: Name: MovementPowerup

    * ID: (again just click suggest)
    * Ability Type: Effect - Target
    * Based On: Default Ability (CAbilEffectTarget)

With the settings:

    * Ability - Arc: 360
    * Ability - Auto Cast Filter: Check Player and Neutral and uncheck the rest and make it require Ground and exclude structures. (if you leave the others checked any enemy that touches the powerup will get the bonus instead of you)
    * Ability - Auto Cast Range: 0.1 (increase to make the unit pick it up from further away, with 0.1 he has to walk over it)
    * Effect - Effect: MovementPowerupSet
    * Stats - Flags: Check Autocast, autocast on and Re-Executable, leave the default ones on as well
    * Stats - Range: 0.1 (make this the same value as autocast)

Step 4: Creating the unit that will be our powerup item
Now all that's left is to make our unit that will represent out powerup item. go into the Unit tab and create a new unit: Name: MovementPowerup ID: (suggest) Based On: Default settings (Item) Object Family: Melee Race: Neutral Object Type: Item

Now the only thing you will have to change here is: Ability - Ability: MovementPowerup

Now all that's left is to link a Actor to our unit, I just used a copy of Crate for that but you can pick whatever you want.

Bonus
If you want the item to drop after you killed a unit or anything else just do the following:

Go to Loot and make a new loot object and set it Loot Type to Unit and press OK. Now under Unit in the Loots settings select our MovementPowerup. IMPORTANT: If your working with hostile units, set Spawn Owner to Target, this will make the spawned loot friendly for you, else if there are more enemy units attacking you they will pick up the item instead)

Next go to you unit that you want this item to drop and in its settings find "Unit - Loot". Here select our freshly created Loot item and your ready to go!







Star Depot
Contact      Login      Register