+ Reply to Thread
Results 1 to 5 of 5

Thread: Expression to Handle 4 different Target Locators (Help)

  1. #1
    Wire Noob Engine Of Darkness's Avatar
    Join Date
    Aug 2007
    Posts
    11

    Thumbs up

    Well the idea is to let 4 different Target Locators target 4 different targets. As you can see, we have XYZ 4 times (for each Locator). This values get floored and added together. I'm then comparing the values to each other, and if one locator got the same values as another, it switches targets.

    Now the problem was, they would switch targets all the time, so I tried to make the program prodecural, which only allows "Locator 2" to choose a target if locator got a target and "Locked" it (and so on). However it still doesn't work right.

    I know there will be some problems (what if you have 4 locators and less than 4 targets). Another one would be that I calculate one value (out of x1 y1 z1 for example) . What happens if one target is at 500 0 0 and another at 0 500 0 ? Right, they try to change their targets (because they got the same value).

    Problem is it doesn't work right at all now, so I would like to get that fixed before I fix those other problems.

    Here's the code (guess what it's good for )
    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>N@DroneAimer
    I@X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4
    O@C1 C2 C3 C4 Htar1 Htar2 Htar3 Htar4 Fire
    floor(X1,1)
    floor(Y1,1)
    floor(Z1,1)
    floor(X2,1)
    floor(Y2,1)
    floor(Z2,1)
    floor(X3,1)
    floor(Y3,1)
    floor(Z3,1)
    floor(X4,1)
    floor(Y4,1)
    floor(Z4,1)
    V1 = X1 + Y1 + Z1
    V2 = X2 + Y2 + Z2
    V3 = X3 + Y3 + Z3
    V4 = X4 + Y4 + Z4
    If V1 != V2 -> C1 = 0;
    If V1 != V3 -> C1 = 0;
    If V1 != V4 -> C1 = 0;
    If V1 == V2 -> C1 = 1;
    If V1 == V3 -> C1 = 1;
    If V1 == V4 -> C1 = 1;
    If C1 == 1 -> Htar1 = 0;
    If C1 == 0 -> Htar1 = 1;
    If V2 != V1 & Htar1 == 1 -> C2 = 0;
    If V2 != V3 & Htar1 == 1 -> C2 = 0;
    If V2 != V4 & Htar1 == 1 -> C2 = 0;
    If V2 == V1 & Htar1 == 1 -> C2 = 1;
    If V2 == V3 & Htar1 == 1 -> C2 = 1;
    If V2 == V4 & Htar1 == 1 -> C2 = 1;
    If C2 == 1 -> Htar2 = 0;
    If C2 == 0 -> Htar2 = 1;
    If V3 != V1 & Htar1 == 1 & Htar2 == 1 -> C3 = 0;
    If V3 != V2 & Htar1 == 1 & Htar2 == 1 -> C3 = 0;
    If V3 != V4 & Htar1 == 1 & Htar2 == 1 -> C3 = 0;
    If V3 == V1 & Htar1 == 1 & Htar2 == 1 -> C3 = 1;
    If V3 == V2 & Htar1 == 1 & Htar2 == 1 -> C3 = 1;
    If V3 == V4 & Htar1 == 1 & Htar2 == 1 -> C3 = 1;
    If C3 == 1 -> Htar3 = 0;
    If C3 == 0 -> Htar3 = 1;
    If V4 != V1 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 0;
    If V4 != V2 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 0;
    If V4 != V3 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 0;
    If V4 == V1 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 1;
    If V4 == V2 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 1;
    If V4 == V3 & Htar1 == 1 & Htar2 == 1 & Htar3 == 1 -> C4 = 1;
    If C4 == 1 -> Htar4 = 0;
    If C4 == 0 -> Htar4 = 1;
    If Htar1 == 0 | Htar2 == 0 | Htar3 == 0 | Htar4 == 0 -> Fire = 0;
    If Htar1 == 1 & Htar2 == 1 & Htar3 == 1 & Htar4 == 1 -> Fire = 1;
    </div>

    I figure the code might not be the best optimized one, however optimizing should be done once it works at all.

    Oh and please, don&#39;t post already "done and working" Code, because I want to learn how to do this right, and not learn how to copy and paste.

    Edit:

    Q&A:

    Q: Why don&#39;t you use the Target Locators option for this?
    A: Because it doesn&#39;t work right at all, atleast the time I tried to do that with aVoNs Dronelauncher.

  2. #2
    Wire Amateur barri167's Avatar
    Join Date
    Feb 2007
    Posts
    79

    Default

    "If" isn&#39;t used in the expression gate.

  3. #3
    Wire Noob Engine Of Darkness's Avatar
    Join Date
    Aug 2007
    Posts
    11

    Default

    Forget about it, that will never work... The target locator can&#39;t aim at targets to far away, the two targets which are nearest to the locator are the only ones picked. it&#39;s not "next target" but "next target to the locator". Which results in only "2 targets" which can be targeted at.

    Bugfix please?

  4. #4
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default

    "floor(V)" does nothing

    "V = floor(V)" however does.

    (aka, a variable can only change through assignment)

    but why are you flooring the values? (except for debugging reasons)

  5. #5
    Wire Noob Engine Of Darkness's Avatar
    Join Date
    Aug 2007
    Posts
    11

    Default

    I wanted to compare one number to another (so I floored all inputs (x1 y1 z1...) and added them to another value (V1 for example). I then compared V1 to V2 (which was x2, y2, z2 added together) and so on.

    Well later I figured that there will be problems when you have a target at 0 500 0 and 500 0 0 , because the "V" numbers would be the same (and V1 would think "oh I got the same target as V2") so scrap that.

    I did "floor" because it was described like this in the wiki (yes, I actually read). I interpret this: "floor n, d Returns n, rounded down d places. floor(135.2,1) = 130" the following way:
    x1 is 324

    floor(x1,1)

    The Wiki reads "returns n" and n equals X1, which was 324 when we "called" the function and is 320 when we use the x1 value again. If it doesn&#39;t work (at all) like this I wonder how I got numbers without places after the comma. However now that you said it I remember that it shouldn&#39;t work like this (I should know better with some C++/PHP... knowledge )

    However you can also close this topic for now, the way how next target works, is making this way to complicated (as I said, it targets the "next one" from the targets locators position, and if you got 2 entitys, well it will target the one or the other. A 3rd one a dozen metres away is most likely not recognized.

    I was working on this with the impression that "next target" meant next target in some sort of "list" not literally "the next one from the locator".

    For now I wrote myself another E-Gate, for only 1 Launcher, but it is more deadly then what I did before (automated fire when it has a target, when no target the drones will "shutdown" after 3 seconds, about 0.2 seconds (or faster) to lock onto a new target (drones won&#39;t get shutdown then)

    Actually I&#39;m uploading a video (reminds me of something I have to ask aVoN... bugs me that you can&#39;t count how much drones are flying (in singleplayer))

+ Reply to Thread

Similar Threads

  1. Target Finder Question/Expression Help
    By blt950 in forum Installation and Malfunctions Support
    Replies: 8
    Last Post: 12-03-2008, 04:47 AM
  2. Target Locked @ Target Finder
    By Walas in forum Ideas & Suggestions
    Replies: 3
    Last Post: 06-21-2008, 10:11 AM
  3. Why wont target finder target props..?
    By Xtensity in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 05-08-2008, 06:01 AM
  4. Expression and Target Finder Bug
    By TBbadmofo in forum Installation and Malfunctions Support
    Replies: 3
    Last Post: 02-26-2008, 05:19 AM
  5. Updated Target Finder: Target the other team(s)
    By philxyz in forum Wiremod Addons & Coding
    Replies: 7
    Last Post: 01-21-2008, 04:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots