![]() |
#6
|
|||
|
|||
![]()
Much as wolf describes, although it looks like his version adds math function.
Kodiak helped me with the syntax arrangement for the 2Dpoint stuff, the rest I added, the logic test. This is part of the complete code, I call references to process the results. This setup is to detect players with a zone, well in this case 3 trigger zones where I create reaction ranges. You could just have one ofcurse. Effectively this overides all internal mission parameters, except I hijack the ontrigger and trigger, where I use Tpassthough to separate the armies. For 3D, although I haven't tested it yet, I suspect all that needs to be added is the z axis to the internal double getdistancefromto. Point2 would become Point3D. That's all for the from ~ to Note the Ontrigger fires the list for players, if you had specific objects, vehicles, you could(should) list them.(better to do this as objects can disappear causing exceptions references) After the listing of the objects(players in this case) a ForEach is used to test the position against the reference The change for the 2nd part, note the redradarx and redradar1y are the grid reference x,y coords. You would need to add the z coord Point2d RedRadar1 = new Point2d(redradar1x, redradar1y); //this is reference location. Point2d ActorPos = new Point2d(item.Place().Pos().x, item.Place().Pos().y);// this is object location at time of trigger Theory, would become Point3d <name> = new Point3d(coord x, coord y, coord z); Point3d ActorPos = new Point3d(item.Place().Pos().x, item.Place().Pos().y, item.Place().Pos().z); I use ranging tests in the logic following the location tests, you wouldn't need all this, only one test, less than the distance you want to trigger from the (x,y,z) reference position. In my test if the result is true for any of the states, note I set different true or false arrangements, this is processsesd in the final mission loader private void. I also separate the ai trigger processing into separate private void. The advantage of separating final processing is that I can activate the final processing by other conditions other than ontrigger. Code:
internal double getDistanceFromTo(Point2d startPoint, Point2d endPoint) { return startPoint.distance(ref endPoint); } public override void OnTrigger(int missionNumber, string shortName, bool active) { base.OnTrigger(missionNumber, shortName, active); List<Player> plebs = new List<Player>(); if (GamePlay.gpPlayer() != null) plebs.Add(GamePlay.gpPlayer()); if (GamePlay.gpRemotePlayers() != null) plebs.AddRange(GamePlay.gpRemotePlayers()); plebs.ForEach(item => { if (item.Place() != null) { //radar circles Point2d RedRadar1 = new Point2d(redradar1x, redradar1y);// radar trigger(Blue activate) Point2d BlueRadar1 = new Point2d(blueradar1x, blueradar1y);// radar trigger(Red activate) //Player pos Point2d ActorPos = new Point2d(item.Place().Pos().x, item.Place().Pos().y); //test Radars and Player Pos if (item.Army() == 1) { if (getDistanceFromTo(ActorPos, BlueRadar1) > 15000.1) { Rredinblue1 = false; Rredinblue2 = false; Rredinblue3 = false; } if (getDistanceFromTo(ActorPos, BlueRadar1) < 15000) if (getDistanceFromTo(ActorPos, BlueRadar1) > 10000.1) { Rredinblue1 = true; Rredinblue2 = false; Rredinblue3 = false; } if (getDistanceFromTo(ActorPos, BlueRadar1) < 10000) if (getDistanceFromTo(ActorPos, BlueRadar1) > 5000.1) { Rredinblue1 = false; Rredinblue2 = true; Rredinblue3 = false; } if (getDistanceFromTo(ActorPos, BlueRadar1) < 5000) { Rredinblue1 = false; Rredinblue2 = false; Rredinblue3 = true; } } if (item.Army() == 2) { if (getDistanceFromTo(ActorPos, RedRadar1) > 15000.1) { Rblueinred1 = false; Rblueinred2 = false; Rblueinred3 = false; } if (getDistanceFromTo(ActorPos, RedRadar1) < 15000) if (getDistanceFromTo(ActorPos, RedRadar1) > 10000.1) { Rblueinred1 = true; Rblueinred2 = false; Rblueinred3 = false; } if (getDistanceFromTo(ActorPos, RedRadar1) < 10000) if (getDistanceFromTo(ActorPos, RedRadar1) > 5000.1) { Rblueinred1 = false; Rblueinred2 = true; Rblueinred3 = false; } if (getDistanceFromTo(ActorPos, RedRadar1) < 5000) { Rblueinred1 = false; Rblueinred2 = false; Rblueinred3 = true; } } } }); // Radar detection if ((Rredinblue1 | Rredinblue2 | Rredinblue3 | Rblueinred1 | Rblueinred2 | Rblueinred3) == true) { SelectTriggerMission(); } // ai as triggers (AI can be treated separately here as well as player) TriggerProcessing(shortName, active); } Last edited by Smokeynz; 03-26-2012 at 09:09 PM. |
|
|