YesNoOk
avatar

Reading p1 commands as p2 outside of a custom state (Read 16002 times)

Started by shadowuy, May 11, 2022, 03:06:33 pm
Share this topic:
Reading p1 commands as p2 outside of a custom state
#1  May 11, 2022, 03:06:33 pm
  • avatar
  • *
    • Uruguay
Hello, i created a menu that modifys certain aspects of the gameplay. I can get the menu to show up and work when p1 is in anystate and i can get it to work with p2 imput when p2 is in a custom state. But what i need is that P2 is able to activate the menu outside of the custom state. P2 commands seems to only be working when p1 puts p2 in a custom state. Could someone be so kind to help me?
Re: Reading p1 commands as p2 outside of a custom state
#2  May 11, 2022, 03:58:17 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
And this is when P1 and P2 are the same character, right?

I'm kind of puzzled how your menu activation could possibly only trigger for P1 and not P2.
Would you copy/paste all the relevant code?

Re: Reading p1 commands as p2 outside of a custom state
#3  May 11, 2022, 06:20:03 pm
  • avatar
  • *
    • Uruguay
Hello, thank you for your reply.  I use a helper to get p2 ID ans save it in a root variable at the beginning of the round. Also the menu only last for the round because i only use helper variables. Also player 1 and player 2 are two different characters. All the code is in player 1.
[Statedef 5446, MENU OFF AND INITIALIZE]
movetype= I
velset = 0,0
ctrl = 0
poweradd = 0
sprpriority = 7
facep2 = 0
anim = 551121010

[state VARIABLE HUB]
type = null
trigger1 = (prevstateno != 5445) && (time = 0)
trigger1 = var(0) := 1
trigger1 = var(1) := 1
trigger1 = var(2) := 4
trigger1 = var(3) := 1
trigger1 = var(4) := 1
trigger1 = var(5) := 1
trigger1 = var(6) := 300 
trigger1 = var(7) := 1
trigger1 = var(8) := 300
trigger1 = var(9) := 10
trigger1 = var(10) := 10
trigger1 = var(11) := 500
trigger1 = var(12) := 1

[state 5446 GOES TO MENU ON]; basically this part doesnt activate.
type = changestate
triggerall = time != 0
trigger1 = Root, command = "start" && root,ailevel = 0
trigger2 = playerid(root,var(17)),command = "start"  && playerid(root,var(17)),ailevel = 0
value = 5445

all this code is inside the helper called "menu".


try number 2 failed: I tried using the cond exploit to get variables value from a helper created by p2 but failed. It seems that player 2 gets frozen when p1 superpause its active.  At least recognises the variable and activates the menu but because it freeses p2 i cant use its helper to use p2 keys to control the menu. playerid(root,var(17)),Cond(numHelper(3876), Helper(3876), Cond(1, var(0) = 1, 0), 0)

Try number 3 failed:  playerid(root,var(17)),Cond(1,root,command = "start", 0) doesnt seem to work also...

Last Edit: May 11, 2022, 07:30:30 pm by shadowuy
Re: Reading p1 commands as p2 outside of a custom state
#4  May 11, 2022, 08:03:29 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
The redirects to "Root" would be more reliable if you are able to replace those with redirects to PlayerID... assuming you are able to capture and store their ID to a Variable.

I'd recommend using something like this in State 5900 so it triggers only 1 time.

type = Null
triggerall = !time
trigger1 = numenemy = 1 && !PlayerIDExist(var(55))
trigger1 = var(55) := enemy(1),ID
trigger2 = numenemy = 2 && !PlayerIDExist(var(56))
trigger2 = var(55) := enemy(2),ID

and so on.

Re: Reading p1 commands as p2 outside of a custom state
#5  May 14, 2022, 06:24:40 pm
  • avatar
  • *
    • Uruguay
Hey sorry for the late response. Thank you for the code i tried it but it wont trigger past the the first trigger. I fixed it buy splitting it in 2 varsets though. Also enemy(0) its the first enemy not 1. Back to topic, yeah still doesnt work, so i decided to make p2 release a helper when start button is press by him.  That helper let player 1 know that p2 preseds the start button. So p1 summons a helper that puts p2 in a custom state and shows up the menu. This way i could make it work. Thank you for your help so far.
Re: Reading p1 commands as p2 outside of a custom state
#6  May 15, 2022, 07:26:20 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Er... I made some pretty bad code there :P  I apologize.

This should capture the PlayerID of all opponents as vars, so you can redirect to them locally rather than via Root.

type = Null
triggerall = !time
trigger1 = numenemy
trigger1 = var(55) := enemy(0),ID
trigger2 = numenemy > 1
trigger2 = var(56) := enemy(1),ID
trigger3 = numenemy > 2
trigger3 = var(57) := enemy(2),ID
and so on.


Anyway, maybe this thing you were trying would work if written as such:

playerid(root,var(17)),Cond(1,playerid(root,var(17)),command = "start", 0)

Have you use DisplaytoClipboard to ensure the root is capturing the player ID correctly in var(17)?


Have you tried just assuming the PlayerID and using it directly rather than the redirection, for debugging? (May not be "58")

trigger2 = playerid(58),command = "start"  && playerid(58),ailevel = 0


Lastly, does helper state 5445 possibly have something changestating out instantly with p2 activating it? (I'm starting to think this is the culprit).

Last Edit: May 15, 2022, 07:36:29 pm by altoiddealer