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

[Trigger] Running over pedestrians?

Status
Not open for further replies.
Level 15
Joined
Dec 12, 2006
Messages
1,664
Alright, I need a trigger to work like this: a car (unit) makes contact with a pedestrian (unit). When it does, the pedestrian is knocked back out of the way, and takes a bit of damage. This needs to be MPI and MUI. I already used search, so don't pester me about it... Thanks in advance.
 
Last edited:
Level 17
Joined
Jan 21, 2007
Messages
2,014
The knockback would be found almost everywhere, but for the checking for the units...

Events
Every 0.3 seconds of game time
Conditions
Actions
Pick all units matching unittype of matching unit is equal to Car
Set VariableCar to Car
Pick all units in range 100 of VariableCar matching unittype of matching unit is equal to Pedestrian.
Set VariablePed to Pedestrian

Then set the custom value(or whatever you want there) of the Pedestrian to the angle it have in comparison to the Car.

[Insert Knockback system here]
 
Level 15
Joined
Dec 12, 2006
Messages
1,664
Could you explain exactly how to get it so that when the FRONT of the car touches the pedestrian, the knockback occurs? I mean in detail?
 
Level 9
Joined
Oct 28, 2007
Messages
435
Sorry, but your angle calculation has some mayor bugs. Use this: The reason y you use this is because warcraft doesn't know your comparing 2 angles. I posted here about an attacking system from how make a unit deal damage from behind.
About the attack system. It has some bugs:

If the attacking unit has the facing angle of 1 and the facing angle of the attacked unit is 359, it will not deal the damage, because Warcraft will think it is comparing two reals while you are actually comparing angles. Let me explain:

The attacked unit's facing angle is 1
The attacking unit's facing angle is 359

Thus it will check:

Is 1 Greater than, or equal to 359 - 52.5 which it is not


So what you should do is a lot more complex

I use 5 real variables but you can use less, but it is harder to explain using less.

Facing1
Facing2
AngleClockwise
AngleAntiClockwise
Differance

Okay.
Firstly I set the variables.

set Facing1=((Facing of (Attacked unit))
set Facing2=((Facing of (Attacking unit))



// Here I'm just calculating the differance between the angles
set AngleClockwise=Facing1-Facing2
set AngleAntiClockwise=(Facing1+360)-Facing2


if AngleClockwise is less than 0 then
set AngleClockwise=AngleClockwise*-1 // If the angle is negative this makes it positive
endif

if AngleAntiClockwise is less than 0 then
set AngleAntiClockwise=AngleAntiClockwise*-1 // If the angle is negative this makes it positive
endif

// Now Finnally

if AngleAntiClockwise is greater than AngleClockwise then
set Differance=AngleClockwise
else
set Differance=AngleAntiClockwise
endif


// This entire piece of code finds the differance between angles, now you can just add

if Differance is less than X then

// Replace X with a number between 1-90 degrees
//X based on how easely you should be able to have the bonus damage. I prefer 45 degrees


// Your damge actions are placed here ->


endif


Or should the modulo function to make shure the car is facing in the direction of the unit.

set Facing1 = Facing angle of attacking unit
set Facing2 = Facing angle of attacked unit

if( Modulo Real(Facing2 + 120, 360) < Facing 1 and Modulo Real(Facing2 + 240, 360) < Facing 2)
//the unit is attacking from behind, do stuff
endif

You should in both cases use instead of facing of attacked unit, the angle between the car and the target and instead of the facing of the attacking unit, the facing of the car.

Also: Don't use a predric timer running every 0.3 seconds. Rather have a trigger: Collision and whenever a car is created add the event to that trigger that if the unit comes within range of that unit the trigger runs.
 
Level 9
Joined
Oct 28, 2007
Messages
435
Arg Sorry. I uderwent some surgery on my jaw... so... anyway the conditions should be:

  • (((Facing of udg_CarUnit + 120) mod 360) Less than (Angle from udg_TempPoint1 to udg_TempPoint2
  • ((Angle from udg_TempPoint1 to udg_TempPoint2) mod 360) Less than Facing of udg_CarUnit
set your TempPoint1 and 2 to the position of your car unit and the position of the other units.
 
Last edited:
Level 15
Joined
Dec 12, 2006
Messages
1,664
Can you remake the WHOLE trigger with GUI? Not just one line? Because, as it stands, I'm still confused. Better yet, can you put it into a map for me please? It shouldn't take TOO long, I'm sure.

Oh, and I hope your jaw is all in one piece. Surgery on the jaw? Must've hurt.
 
Level 9
Joined
Oct 28, 2007
Messages
435
Dam.... I really don't know how I would make this whole system in gui.... My gui knowledge really suck (I forgot most of the stuff when I learned jass)....

I could make the system.... Using the actions of a gui trigger so its easy to edit what it does when you come into impact with a unit???? and then make the rest in Jass?

Sorry for taking so long on a reply....
 
Status
Not open for further replies.
Top