Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Help!
#1

How do I make "Highest signal" selections?

Archive: 8 posts


Im making a threat table for my LastHope game. Illbe using a timer/ sequencer, basically a % to turn on a follow either player 1-4. How do imake it so each follower will only turn on its timer is the highest % relatively speaking?2012-04-18 15:25:00

Author:
RonPierce
Posts: 131


Okay, I'll explain better what I'm looking for. I want to add a threat table that works like this:
It's timer based on a scale of 10sec, which is 10,000 "threat units" max (will be incredibly hard to manage to cap this, which is why I chose such a high number. There will be 4 1 per possible player controlled character. 1 builds up when "Player1Threat#" hits, 2 when "Player2Threat#" and so on. These would be connected to a follow tag to follow that person, but I only want it to follow the highest meter, not turn each of them on with just any amount of threat(they'd end up just standing still I believe). How do I do this? This is for a top-down rpg.
2012-04-18 20:32:00

Author:
RonPierce
Posts: 131


To summarize for who is confused by your description: you have a timer that represents a value between 0 and 100%. This value is 'threat' and based on the amount you want 1 out of X (number of players present) to be followed using a unique follower.

What confuses me is what is the relationship between the amount of threat and a particular player. In MMORPG terms, threat is something not the enemy has, but a player has. It is a value that represents attention from an enemy. If you, player 1, has 75% of threat on an enemy, the enemy focuses on you instead of player 2 with a measly 20% threat. If player 2 does something, like an overpowered attack - or player 1 fails to do his tanking duties - player 2's threat can outgrow that of player 1 and the enemy will shift attention.

Say each player has an analog signal going - the timer - and this is wired to a tag 'threat', red for p1, blue for p2, etc. Now, you can stick logic on the enemy that measures these tags with sensors, set to sig strength, wire them into an OR, which lets through the strongest one, then subtract that from each individual signal again using combiners and then check which of them is exactly 0 (positional sequencer with full canvas battery). Now you know who has the strongest threat and you can attach actions to that.

This does not take into account that in an MMORPG a player can have separate, different amounts of threat per enemy.
2012-04-18 20:35:00

Author:
Antikris
Posts: 1340


Well, there is no way to store personal data per enemy on the character, atleast not with some silly amounts of useless coding. Instead I reversed it, since there are always only up to 4 players, I want to make it so each of the players attacks will have a tag that will add x amount of threat (much like health bars). Then I want it to use a follower either "FollowP1" "FollowP2" "FollowP3" or "FollowP4" based on if the player 1,2,3 or 4 threat is highest.

Edit, also didn't make is personal threat, because otherwise attacking 1 enemy would be that amount of threat to every nearby enemy, and that's not ideal.

I think ORs might be the answer, but I'm just not entirely sure how to do it... I'm having a hard time piecing this one together. I dont have a lot of signal strength knowledge.
2012-04-18 20:39:00

Author:
RonPierce
Posts: 131


Well, there is no way to store personal data per enemy on the character, atleast not with some silly amounts of useless coding. Instead I reversed it, since there are always only up to 4 players, I want to make it so each of the players attacks will have a tag that will add x amount of threat (much like health bars). Then I want it to use a follower either "FollowP1" "FollowP2" "FollowP3" or "FollowP4" based on if the player 1,2,3 or 4 threat is highest.

Edit, also didn't make is personal threat, because otherwise attacking 1 enemy would be that amount of threat to every nearby enemy, and that's not ideal.

Well, yeah, you can stick 4 threat meters on every enemy. That will do. Take my setup and replace the 4 sensors with 4 signals that build up with their respective player's attacks. The logic determining which of these signals is the strongest is the same.

Screenie coming.
2012-04-18 20:42:00

Author:
Antikris
Posts: 1340


okay, screenie would be amazing, so it's a little easier to follow. I'm a visual learner unfortunately so reading it just sort of boggled me, but seeing it I'd surely get it. Be sure to include any additional info I might need if you have any "signal strength" tweaks.2012-04-18 20:46:00

Author:
RonPierce
Posts: 131


Okay, so here is an example of the logic that would be on an enemy. The timers (actually counters in this case) represent analog threat values that each player has on this enemy. Clearly player 3 is doing the right thing. You can see in the output on the right that signal is lit up; attach your enemy attack logic to there so it will go after this player.

http://i8.lbp.me/img/ft/c083367055df5cff67a246e9c5373db7db888dd6.jpg

Some details: the sequencers are set to positional and a battery on them spans the entire canvas; these serve as a way to determine a signal is not 0 and obviously we are inverting that with a NOT gate behind it.

Feedback loops

Timers or counters are the easiest way to envision an anlog signal, but in practice these are cumbersome tools to actually manipulate that signal with. So, I figured I'd add another screenie: a feedback loop.

http://i9.lbp.me/img/ft/db9156f59633545a3ec43f85490ae9195311d1fc.jpg

What you see here is a setup that allows a signal to go in circles and thus be stored, like a timer or counter does. In this screenshot I make a signal loop on the left chip and be broadcasted over a green tag. This gets picked up on another chip using a tag sensor set to signal strength; wired to a combiner into a 0.1s timer set to speed scale (and the timer wired into the negative of the combiner), this will serve as a display of that looped signal on the other chip. You can even use four of these as a 'threat meter' in the game if you'd like to.

The left chip, you would have 4 of these setups; one for each player. They replace the timers from the first screenie.

The wire you see entering the purple XOR gate** serves as a way to instantly BREAK the loop and thus reset the resulting signal to 0.

Subtracting

The wire going into the red combiner SUBTRACTs something from the looped signal; you'd wanna send an analog signal to this, for instance a pulse of 1% every second of a player's inactivity - causing threat to go down when not fighting. If you have more sources that are supposed to subtract from the loop, you don't need to wire them all to this combiner; instead, put an array of these combiners after one another, linking each output to the positive input of the next. With that setup you can subtract values simultaneously.

Adding

The wire leading into the blue combiner will ADD to the loop signal. It works just like the subtraction mentioned above. Except of course we can only subtract with combiners: that is why we first invert the signal, then subtract the value we want to add, then invert it again; the result will be as if we added it. If you want to create an array of combiners for addition, do so in between those two NOT gates.

Overriding

Lastly, the signal leading into the purple OR gate** serves to OVERRIDE the current loop signal with a higher value instantly. Of course, in order to immediately set it to a lower value than the current loop signal, you'd have to reset it (feed the XOR) and then feed an analog pulse to this OR gate here.

Loop duration and pulsing

Remember that this looped signal takes 1 frame cycle to loop; if you want to set, add or subtract (to) this signal, do so with 1 frame pulses and not a continuous signal. Else the looped signal will run to 100% or 0% within just a few frames time. A simple way to create a 1 frame pulse of an analog signal is to wire a battery (set to for instance 50%) to an AND gate** and pulse the other input of that AND gate; this can be a self-resetting 1-shot counter fed by a button or any other event. The AND gate, being that when both inputs are active, will let the weakest signal through. Since the pulse on one gate is 100%, it will let through the 50% battery signal for the duration of 1 frame.

Flooring at 0

I didn't mention the signal splitter yet; it is there so that the resulting signal for the loop will always be capped to 0; you see, in case the signal is for instance 10% and you subtract 15%, then the result will be 0% positive combined with 5% negative; this will disrupt the system in a sense that when sent over the tag, this -5% gets normalized to 5%. If we only let the positive part of the loop through after having done all additions and subtractions, we are making sure that 0% will be the ultimate floor of this loop. ***

More...

Check out CompherMC's video tutorials (1 (http://www.youtube.com/watch?v=c4GaCQ1eRVE), 2 (http://www.youtube.com/watch?v=k0sbxogAcDo)) if you like to know more about feedback loops.

** An OR gate lets through the strongest of any incoming signals. An AND gate lets through the weakest of all simultaneous signals. A XOR gate lets through a signal unscathed unless two or more inputs receive a signal; then it shuts down.

*** An example of this normalization is also visible in the top screenie: the OR gate passes the strongest signal which gets subtracted from weaker signals, resulting in negative values; when wired to a positional sequencer (to measure whether not 0), this negative signal is normalized into a positive result, making the position of the sequencer to move to the right as if it were fed a positive signal.
2012-04-18 21:28:00

Author:
Antikris
Posts: 1340


Jeez, did you really make all that just for me? o.O That was impressive, thanks! That's exactly what I needed!!!2012-04-19 02:43:00

Author:
RonPierce
Posts: 131


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.