SithLord1993 Posted February 2, 2016 Posted February 2, 2016 (edited) Hallo, I have a problem with an "if" function. I want to make a script where when luke will be has less than 50 HP then he will change into a Kyle. I put "if" function in many ways and it not working, Here is the Code: ( //Generated by BehavEd rem ( "luke1" ); affect ( "luke1", /*@AFFECT_TYPE*/ FLUSH ) { camera ( /*@CAMERA_COMMANDS*/ ENABLE ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref3", ORIGIN)$, 0 ); camera ( /*@CAMERA_COMMANDS*/ PAN, < 0.000 90.000 0.000 >, < 0.000 0.000 0.000 >, 0 ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref4", ORIGIN)$, 16000 ); set ( /*@SET_TYPES*/ "SET_WALKING", /*@BOOL_TYPES*/ "true" ); set ( /*@SET_TYPES*/ "SET_NAVGOAL", "nav1b" ); wait ( 16000.000 ); task ( "lukedial1" ) { sound ( /*@CHANNELS*/ CHAN_AUTO, "sound/chars/luke1/lukedia1.mp3" ); } dowait ( "lukedial1" ); //$"default"@6 set ( /*!*/ "SET_BEHAVIOR_STATE", /*!*/ "BS_DEFAULT" ); set ( /*!*/ "SET_CHASE_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_LOOK_FOR_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_IGNOREALERTS", /*!*/ "false" ); set ( /*!*/ "SET_WALKING", /*!*/ "false" ); set ( /*!*/ "SET_RUNNING", /*!*/ "false" ); wait ( 2000.000 ); set ( /*@SET_TYPES*/ "SET_SABERACTIVE", /*@BOOL_TYPES*/ "true" ); wait ( 20000.000 ); camera ( /*@CAMERA_COMMANDS*/ DISABLE ); if ( $get( FLOAT, "SET_HEALTH")$, $<$, $50$ ) { set ( /*@SET_TYPES*/ "SET_PLAYERMODEL", "Kyle" ); } } )What should I Do? Edited February 2, 2016 by Circa code tags
Ramikad Posted February 2, 2016 Posted February 2, 2016 It depends on how you use the script. If you set it up so that it only runs once, it will do its tasks and perform only one check for Luke's health. You can either loop that health check so that every X seconds it will check his health, but in my opinion the best solution is to separate it into a new script that you'll then set to Luke's painscript. It would then work like this: every time he is hit, the script will run and check his health, and the "fatal hit" that would lower his health below 50 will turn him into Kyle. At that point you should also probably set his painscript to none, so that it won't loop over and over. Asgarath83 and therfiles like this
SithLord1993 Posted February 2, 2016 Author Posted February 2, 2016 (edited) Heh, I am not on this "level" of programming, is it for you a problem to show me that step by step? I would be greatful This is second script: rem ( "kyle_check" ); loop ( 1 ) { if ( $get( FLOAT, "SET_HEALTH")$, $<$, $50$ ) { set ( /*@SET_TYPES*/ "SET_PLAYERMODEL", "Kyle" ); } Edited February 2, 2016 by Circa CODE TAGS
Ramikad Posted February 2, 2016 Posted February 2, 2016 Sure. Simply delete that last snippet checking for his health, so that the script would look like this: ( //Generated by BehavEd rem ( "luke1" ); affect ( "luke1", /*@AFFECT_TYPE*/ FLUSH ) { camera ( /*@CAMERA_COMMANDS*/ ENABLE ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref3", ORIGIN)$, 0 ); camera ( /*@CAMERA_COMMANDS*/ PAN, < 0.000 90.000 0.000 >, < 0.000 0.000 0.000 >, 0 ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref4", ORIGIN)$, 16000 ); set ( /*@SET_TYPES*/ "SET_WALKING", /*@BOOL_TYPES*/ "true" ); set ( /*@SET_TYPES*/ "SET_NAVGOAL", "nav1b" ); wait ( 16000.000 ); task ( "lukedial1" ) { sound ( /*@CHANNELS*/ CHAN_AUTO, "sound/chars/luke1/lukedia1.mp3" ); } dowait ( "lukedial1" ); //$"default"@6 set ( /*!*/ "SET_BEHAVIOR_STATE", /*!*/ "BS_DEFAULT" ); set ( /*!*/ "SET_CHASE_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_LOOK_FOR_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_IGNOREALERTS", /*!*/ "false" ); set ( /*!*/ "SET_WALKING", /*!*/ "false" ); set ( /*!*/ "SET_RUNNING", /*!*/ "false" ); wait ( 2000.000 ); set ( /*@SET_TYPES*/ "SET_SABERACTIVE", /*@BOOL_TYPES*/ "true" ); wait ( 20000.000 ); camera ( /*@CAMERA_COMMANDS*/ DISABLE ); } ) Then make a new script that only does the check on his health, like this: ( //Generated by BehavEd if ( $get( FLOAT, "SET_HEALTH")$, $<$, $50$ ) { set ( /*@SET_TYPES*/ "SET_PLAYERMODEL", "Kyle" ); set ( /*@SET_TYPES*/ "SET_PAINSCRIPT", "" ); } ) Name it, for example, luke_health_check. Now, if you're making the map yourself and you have a direct control on the NPC_Spawner / NPC_Luke in Radiant, select it and simply input: Key: painscriptValue: <script path after "scripts/", if there's any>/luke_health_check Otherwise, if you're not mapping it yourself, you can do it through your main script, like this: ( //Generated by BehavEd rem ( "luke1" ); affect ( "luke1", /*@AFFECT_TYPE*/ FLUSH ) { camera ( /*@CAMERA_COMMANDS*/ ENABLE ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref3", ORIGIN)$, 0 ); camera ( /*@CAMERA_COMMANDS*/ PAN, < 0.000 90.000 0.000 >, < 0.000 0.000 0.000 >, 0 ); camera ( /*@CAMERA_COMMANDS*/ MOVE, $tag( "ref4", ORIGIN)$, 16000 ); set ( /*@SET_TYPES*/ "SET_WALKING", /*@BOOL_TYPES*/ "true" ); set ( /*@SET_TYPES*/ "SET_NAVGOAL", "nav1b" ); wait ( 16000.000 ); task ( "lukedial1" ) { sound ( /*@CHANNELS*/ CHAN_AUTO, "sound/chars/luke1/lukedia1.mp3" ); } dowait ( "lukedial1" ); //$"default"@6 set ( /*!*/ "SET_BEHAVIOR_STATE", /*!*/ "BS_DEFAULT" ); set ( /*!*/ "SET_CHASE_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_LOOK_FOR_ENEMIES", /*!*/ "true" ); set ( /*!*/ "SET_IGNOREALERTS", /*!*/ "false" ); set ( /*!*/ "SET_WALKING", /*!*/ "false" ); set ( /*!*/ "SET_RUNNING", /*!*/ "false" ); wait ( 2000.000 ); set ( /*@SET_TYPES*/ "SET_SABERACTIVE", /*@BOOL_TYPES*/ "true" ); wait ( 20000.000 ); camera ( /*@CAMERA_COMMANDS*/ DISABLE ); set ( /*@SET_TYPES*/ "SET_PAINSCRIPT", "<path again, if any>/luke_health_check" ); } ) If everything works correctly, every time Luke is hit that luke_health_check will verify if his health decreased below 50. Once it is, it sets the character model to Kyle and resets the painscript, so that it won't run any more checks every time Kyle is hit.Hope this helps.
SithLord1993 Posted February 2, 2016 Author Posted February 2, 2016 Something's working But...Error:SV_Getuserinfo:Bad Index 124??
SithLord1993 Posted February 2, 2016 Author Posted February 2, 2016 Or I should make Affect luke1 first and then add 'if' function and th restof them?
SithLord1993 Posted February 3, 2016 Author Posted February 3, 2016 Every time when Lukes health is less than 50 game crashes, i dont know why
therfiles Posted February 3, 2016 Posted February 3, 2016 You should make a simple script to verify that the SET_PLAYERMODEL thing even works on NPC. I know it works for the player, but I'm not 100% sure it does for NPCs. If it doesn't we can do some other dark magic. Ramikad likes this
Ramikad Posted February 3, 2016 Posted February 3, 2016 You should make a simple script to verify that the SET_PLAYERMODEL thing even works on NPC. I know it works for the player, but I'm not 100% sure it does for NPCs. If it doesn't we can do some other dark magic. This, apparently the SET_PLAYERMODEL command doesn't work on NPCs. The only dark magic I can think of, is that as soon as the health drops below 50, an already spawned Kyle is teleported to the exact origin and angles of the original Luke entity, which is erased in the meantime. therfiles likes this
Asgarath83 Posted February 3, 2016 Posted February 3, 2016 This, apparently the SET_PLAYERMODEL command doesn't work on NPCs. The only dark magic I can think of, is that as soon as the health drops below 50, an already spawned Kyle is teleported to the exact origin and angles of the original Luke entity, which is erased in the meantime. and player Kyle get Playermodel Luke with Icarus. yes, should be work.
therfiles Posted February 3, 2016 Posted February 3, 2016 @@Ramikad you read my mind, good sir! It won't be pretty, but maybe if the Luke NPC froze in a specific animation and then the Kyle NPC ported to that place in that same animation and angle direction. That might make a rough transition smoother. The only other (weird) way was if you somehow fused Kyle and Luke's actual .GLM models together and then used two .skins to toggle between them.
SithLord1993 Posted February 3, 2016 Author Posted February 3, 2016 With my luck all i wanted to do with that "Set Playermodel" function was check is that 'If' function is working I replaced setplayermodel with Setdismemberlimb and gues what, its working perfectly! Thank you all for your help and Time! You are great Masters of this! one more time thank you!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now