| 05-03-2005, 04:24 AM | #1 |
OK this is a real mind boggler for you pros out there (i'm more of a graphical person myself) I'm making a map and I really wanted to have a lazer proximity system that would ping the minimap every time someone crossed it. I also want it to be dynamic, so a person could plant one building, then use an ability to connect the laser to a nearby building. After 8 hours, and very little results I gave up. Even my pro scripter (the one who did the majority of scripting for Life of a Peasant) said that I should just give up on it and go with a building that just goes off on proximity, I personally don't give up that easily. This is how far I got though, the first event was A unit casts an ability, that ability is laser trap, set one variable the distance between the 2, one for the angle of the laser, and 2 variables for the units in question (all in an array). A trigger that goes off every second looks for units in range(distance) to (tower 1) with condition that it is (angle) +3 degrees and (angle) -3 degrees. It goes though the actions from there. I would give up if I thought there was no possible way to do this, but I just have to know first. |
| 05-03-2005, 05:30 AM | #2 |
Take your friend's advice, rename it the proximity sensor and move on. That's just my opinion anyway =) |
| 05-03-2005, 07:17 AM | #3 |
This can most certainly be done. It's just a bunch of math, figuring out if a position of a unit is in a rotated rectangle (the rectangle being the line of your laser with a certain width). You can either translate all the relavant points into a polar coordinate system, rotate them by the angle of your rectangle, and then you can easily verify if they are in it by checking if the x and y coordinates are within it's bounds, or, you can verify the proximity of a unit to multiple points along the laser's line, whatever runs faster. You can additionally optimize it by only verifying units that are anywhere near the laser, for example inside a rect defined by the start and end points of the laser. Since you probably do the verification using a rapid periodic trigger, you need to be careful about memory leaks, and that's it. It could even be done in GUI, although I can understand why you posted in the JASS vault, as the request surpasses the difficulty of average triggering. |
| 05-03-2005, 09:38 AM | #4 |
When the laser barrier is being set up, I'd dynamically create a region (not a rect) and add the cells to the rect where it should detect the units (cells are the smallest unit that can be added to a rect, but they're rather tiny and should perfectly work for what you want to do) Then just add a unit enters rect event + a condition entering unit is enemy and that's it. Keep the trigger and rect handle somewhere in game cache or attached to the laser tower, to be able to destroy/remake them when the user dis/re-connects the lasers. |
| 05-03-2005, 11:14 AM | #5 |
Guest | hmmm.... should be possible.... ill have a play around and see if i can work it out for you... but you might wanna take Anitarf's Advice and post it under JASS, it might be a hell of alot easier. |
| 05-03-2005, 11:31 AM | #6 |
ouch, yeah there is no easy way of doing this. The biggest problem is that the ability makes a line in different degrees and at different distances. Didn't I hear somewhere that Regions don't have to be rectangular? all I would have to do in that case is set 2 points of the region with a polar offset, 90 degrees from the direction of the other building in opposite directions then do the same for the other building? |
| 05-03-2005, 12:56 PM | #7 |
Regions don't have to be rectangular, that's why I suggested creating a region on the fly that covers only the line that units shouldn't pass and then use a simple unit enters region event. It's rather easy, actually. |
| 05-03-2005, 04:46 PM | #8 |
OK, so if thats possible, can someone show me 2 things in JASS, an example of how to create a region, and an example of how to resize a regions' points (I think thats all I need since everything else has examples I can pull from regular triggers) |
| 05-03-2005, 04:54 PM | #9 |
I'm just pulling stuff out of my ass here, I don't actually know the triggers for this. Basically your laser sensor is a unit that fires off invisible shockwaves from one unit to the next unit. So everytime you detect a unit has been hit by the shockwave, you ping it's location. Or yes I guess another way would just be to create units in a line from one point to another. |
| 05-03-2005, 05:04 PM | #10 |
Detecting the hit of the shockwave, would be harder than the region thing. I actually think that the region way combined with lightning effects will do the work, you just need to have a loop that adds the points of the line to the region, |
