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

Bump Spell

Status
Not open for further replies.
Level 3
Joined
Jun 17, 2012
Messages
46
Hey I need a spell that makes it so whenever the unit collides with another unit, he knocks it back and deals damage to it if the unit has nowhere to go (being crushed into a wall, for example). See the screenshot below for clarification.
 

Attachments

  • Screenshot.png
    Screenshot.png
    522.8 KB · Views: 142
Level 3
Joined
Jun 17, 2012
Messages
46
Well the thing showed is meant to be a unit to make it easier to be triggered, because the box is supposed to move and crush the villager into the wall upon collision.
 
Level 8
Joined
Jul 25, 2009
Messages
194
A quick way u could make the spell is import a knockback spell and then set the speed of knockback slightly fasyer than the crushing units movement speed but make the duration of knockback short. Then do something like
Event - unit comes within 80 of crushing unit
condition - triggering unit is alive true
action -
set tempunitgeoup= units within 90 of triggering umit matching unit type of matchkng unit = crushing unit type and matching unit is alive true
set temp_pos = pos triggering unit
pick every unit in tempunitgroup anddo axtions
Set temp_point2 = temp_pos offset by 25 towards (facing of picked unit x -1)
create dummy for owner of picked unit at temp_point2
Order dumy cast knockback on triggering unit
Remove dumy
clear point leaks
Call remove tempunitgroup

Trigger 2 -
Event-unit comes within 20 of crushing unit
condition-triggering unit is alive true
Action-
Set tempunitgroup = units within 30 of triggering unit matching
Unit type of matching unit = crushing unit type and matching unit is alive true
pick every unit in tempunitgroup and do action
Cause picked unit to deal damage to triggering unit
Call destroy tempunitgroup


Hope.this works
srry for the spelling. I wrote this on my phone lol

These triggers only work if the crushing unit is facing the same direction as it is moving
 
Level 3
Joined
Jun 17, 2012
Messages
46
So if the one villager shown in the screenshot is the only unit who's going to be affected by it, it should work fine?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Definitely. Gimme a sec while I whip up something.

EDIT: Attached is a very simple bump trigger that will work for only 1 bumping unit.

  • Bump 1
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set loc = (Position of bumpUnit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Region centered at loc with size (bumpCollisionSize, bumpCollisionSize)) matching ((Matching unit) Not equal to bumpUnit)) and do (Actions)
        • Loop - Actions
          • Set loc2 = (Position of (Picked unit))
          • Set loc3 = (loc2 offset by bumpExtraDistance towards (Angle from loc to loc2) degrees)
          • Set x = (X of loc3)
          • Set y = (Y of loc3)
          • Set u = (Picked unit)
          • Custom script: call SetUnitX(udg_u, udg_x)
          • Custom script: call SetUnitY(udg_u, udg_y)
          • Unit - Cause bumpUnit to damage u, dealing 10.00 damage of attack type Spells and damage type Normal
          • Custom script: call RemoveLocation(udg_loc2)
          • Custom script: call RemoveLocation(udg_loc3)
      • Custom script: call RemoveLocation(udg_loc)
Here's the variables, where you can fine-tune it to suit your needs:
  • Bump Settings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set bumpExtraDistance = 32.00
      • Set bumpCollisionSize = 200.00
      • Set bumpUnit = Rifleman 0001 <gen>
Notes
- Checks in a square around the bumping unit, sides of size bumpCollisionSize
- bumpExtraDistance is how far the unit is bumped. This bump is instant, so you can reduce this for a smoother bump.

You'll probably want to trigger the block's movement somehow.
 

Attachments

  • SimpleBump001.w3x
    17.2 KB · Views: 41
Level 3
Joined
Jun 17, 2012
Messages
46
Wow thanks man I'll try it out, I'll let you know if it works!

EDIT: I get an error that says "Undeclared function SetUnit"

EDIT2: Figured it out, testing now.

EDIT3: It works decently well, except the person shoves the block, instead of the other way around. Also would there be a way for the shove to go more smoothly, instead of the villager just getting teleported a certain distance away?
 
Last edited:
Level 8
Joined
Oct 26, 2008
Messages
387
EDIT3: It works decently well, except the person shoves the block, instead of the other way around. Also would there be a way for the shove to go more smoothly, instead of the villager just getting teleported a certain distance away?

The only function that can create this "dashing" effect is moving the unit instantly (teleporting) it, however, moving it a very small distance, in a very short of time, it creates the visual illusion of it moving, now every 0,03 seconds the unit is moved 32 range, which should create a smoot effect... if it doesnt try to reduce the number 32 to 20 for instance.
 
Level 8
Joined
Jul 25, 2009
Messages
194
I thought about that but I don't think there's a way to make an event that says when a unit comes within __ of unit.

yea it exists
  • Events
    • Unit - A unit comes within 100.00 of other unit
the entering unit can be detected using triggering unit.

And the other unit can be detected by something like
Set UnitGroup = units within 110.00 of triggering unit matching unit type of matching unit = unit type of other unit.
  • Custom script: set Other_Unit = FirstOfGroup(udg_UnitGroup)
it only works if the other unit is preset in game but if u dont want it at the beginning then you can make the unit hidden and make it appear when you need it
 
Level 3
Joined
Jun 17, 2012
Messages
46
@Starmaster yea thanks I lowered the number and that fixed the problem (I had it at 50)
@rulerofiron Ahhh thanks that fixed it
@coolyoshi1 ohh I didn't know you could do that.
 
Status
Not open for further replies.
Top