While i was still working on my old map i needed to have some powerups that activeded 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.
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 u 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: Deffault 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 thats 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 thats 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!
Thanx for the tutorial! It helped me alot (powerups rock!) but I did have an issue with getting the remove effect to work. I finally got it to work by using PickupRemove(Unnamed) instead of making a new effect to use in the set. Don't know why this one works and the custom one doesn't since all the settings are identical as far as I can see, but I just thought I'd share incase anyone else was haveing the same problem.
Maybe i will use them in my map, but just 1 thing. Is there a way to limit the behavior on a time? I want these Powerups to stay like 30 sec and then be removed.
Is there a way to play a sound when the powerup is picked up and is there a way to have a effect on the unit as long the powerup is up? (Like the unit glows for 20 sec, while buff is active)
While i was still working on my old map i needed to have some powerups that activeded 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.
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 u 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:
Now set the following items like this:
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:
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:
Under its settings:
Now that thats done lets create our last effect, the one that keeps these 2 together. Again create a new effect:
and under its settings:
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
With the settings:
Step 4: Creating the unit that will be our powerup item
Now all thats 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 thats 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!
@DragonGuard1989: Go
Cool method. I need to dabble in powerups soon..
Thanks for the tutorial, i'll be using this in my map
Thanx for the tutorial! It helped me alot (powerups rock!) but I did have an issue with getting the remove effect to work. I finally got it to work by using PickupRemove(Unnamed) instead of making a new effect to use in the set. Don't know why this one works and the custom one doesn't since all the settings are identical as far as I can see, but I just thought I'd share incase anyone else was haveing the same problem.
Thanks for the turtorial. Well done.
Maybe i will use them in my map, but just 1 thing. Is there a way to limit the behavior on a time? I want these Powerups to stay like 30 sec and then be removed.
Thanks!
Ok it was just the "duration" ;)
Other Question:
Is there a way to play a sound when the powerup is picked up and is there a way to have a effect on the unit as long the powerup is up? (Like the unit glows for 20 sec, while buff is active)
?! :)