Krailer Posted April 12, 2007 Share Posted April 12, 2007 I want to be able to change the player skin, but using my 100% save game. So I tried this code with Darkpact: :PUNK0001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump if false ££PUNK0247: request_model #VWMYCR038B: load_requested_models00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK09C7: change_player_skin $PLAYER_CHAR to 181 I compiled the darpactor scm and loaded the save game. Everything worked as it was supposed to; I was imediately prompted to save the game, saved to a new slot, and the new skin was in effect. Then I exited the game, added the code to the bottom of the original scm and compiled. Using the compiled scm, I loaded the save game. The game loaded fine, but the skin change had no effect at all. Then I decided to add a small sphere for to skin change to take place. I haven't made anything similar before, so this may be just plain wrong: :PUNK0001: wait 0 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump if false ££PUNK0247: request_model #VWMYCR038B: load_requested_models00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK00D6: if 0 00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2489.807 -1681.762 13.3362 radius 1.2 1.2 1.2 004D: jump_if_false ££PUNK09C7: change_player_skin $PLAYER_CHAR to 181 Now 2 things went wrong: 1) I wasn't prompted to save when I loaded the save game with the darkpactor scm. Why isn't Darkpact working anymore? 2) Since the game didn't crash, I decided to test the sphere's effect. As soon as the player entered the sphere, it changed the skin but it stopped being controllable. Note that the player wasn't static, I simply couldn't control it anymore. Any help? Link to comment Share on other sites More sharing options...
spaceeinstein Posted April 13, 2007 Share Posted April 13, 2007 Is that the whole code? Your code doesn't seem to end anywhere. Link to comment Share on other sites More sharing options...
Krailer Posted April 13, 2007 Author Share Posted April 13, 2007 Well I did try using the end_thread opcode, which seems to make no difference. I hardly ever use it with Darkpact, because most of the times I'm only adding some opcodes to get small changes in the saved game (e.g. weapon pickups, car spwaning points, gang weapons, etc.). I do have very little knowledge about coding and this is really my first attempt to make an entire thread, so I'm problably missing a lot of necessary steps. Link to comment Share on other sites More sharing options...
random_download Posted April 13, 2007 Share Posted April 13, 2007 I might be wrong but I think you may need to refresh the player to see the skin change. Looks like this is it. Also, with your loop to load the model the convention is to load the model, then do a loop to see if it is loaded like: request_model #VWMYCRload_requested_models:labelwait 10if 0model #VWMYCR availablejf ££label This way you don't request the model several times. To create a sphere I always use 03bc and 03bd, because doing it the way you did, although it should work, can make the sphere flicker if the wait in the loop is too long. Link to comment Share on other sites More sharing options...
Krailer Posted April 13, 2007 Author Share Posted April 13, 2007 I'm not sure if that opcode (0353) is mandatory for the skin to work, as the first code I used made it show up when I loaded the Darkpactor It did lost its effect when I loaded the original scm with the injected code, though. Anyway the opcode exists and it's described as being necessary, so it doesn't hurt to use it and may prevent unexpected results. Thanks for pointing it out. Back to the code itself, I pretty much had it with the damn sphere. I tried using 03BC and 03BD but the result was the same, I lost control of the player character as soon as it entered the sphere. As an alternative I made it to be activated by a keypress, like this... :PUNK10001: wait 250 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump if false ££PUNK10247: request_model #VWMYCR038B: load_requested_models:PUNK20001: wait 250 ms00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK2:PUNK30001: wait 250 ms00D6: if 000E1: key_pressed 0 10004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 181 :PUNK40001: wait 250 ms0353: refresh_actor_skin0002: jump ££PUNK1 ...and I got it to work with a saved game. Yet if anyone knows of a way to make the code more compact and/or consistant, I'll appreciate the input. I also have another couple of questions. I tried using a combination of keys to activate the skin, like this: :PUNK30001: wait 250 ms00D6: if 100E1: key_pressed 0 1000E1: key_pressed 0 11004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 181 Have I missed anything in there? Pressing both keys together didn't work. And if I wanted to revert to the original player character, what would be the best to way to do it, if possible at all? Link to comment Share on other sites More sharing options...
ceedj Posted April 13, 2007 Share Posted April 13, 2007 I do this (SA Studios code, but you get the idea) theScript << BareElseIf << eli << PlayerKey << 6 << Then; // Reset the Player SkintheScript << fade << 1000 << 0;theScript << wait << 1000;theScript << change_player_skin << PLAYER_CHAR << 0; // the 0 is the original skintheScript << fade << 1000 << 1;theScript << wait << 500;theScript << setli << PlayerKey << 0;theScript << jump << FreezeClock; I do the fade just to make it look pretty. EDIT: Note that I don't have a player_defined check, this is because the process is a bit different for the c++ hook I'm using. You should probably add another just in case. Link to comment Share on other sites More sharing options...
Krailer Posted April 13, 2007 Author Share Posted April 13, 2007 By original skin I actually meant the clothes that the character was wearing before changing to the punk skin. I'm not sure if that's what you mean as well, or if you are referring to the default CJ skin. But since the purpose is to still be able to use the wardrobe, it gets the job done just the same and probably makes things a lot simpler. I'll give it a try. Thanks for the help. Link to comment Share on other sites More sharing options...
ceedj Posted April 13, 2007 Share Posted April 13, 2007 In SA Studios, it does return to the player to the state he was in before the skin was changed. So if Carl is wearing a bandanna and has a jacket on, it will return Carl to that state upon resettting the skin to normal. I THINK this will work the same with standard code, but TBH, I've not coded much for SA outside of c++. Try it, and let us know if it works. And no problem, glad we could help. Link to comment Share on other sites More sharing options...
Krailer Posted April 13, 2007 Author Share Posted April 13, 2007 Yep, it does work! :PUNK10001: wait 250 ms>run once stuff<>run once stuff<>run once stuff<:PUNK20001: wait 250 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump if false ££PUNK20247: request_model #VWMYCR038B: load_requested_models:PUNK30001: wait 250 ms00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK3:PUNK40001: wait 250 ms00D6: if 000E1: key_pressed 0 10004D: jump_if_false ££PUNK409C7: change_player $PLAYER_CHAR skin_to 181 :PUNK50001: wait 250 ms00D6: if 000E1: key_pressed 0 11004D: jump_if_false ££PUNK509C7: change_player $PLAYER_CHAR skin_to 0 :PUNK60001: wait 250 ms0353: refresh_actor_skin0002: jump ££PUNK2 I changed it slightly to keep the first label out of the loop and put there a bunch of standalone opcodes that weren't working when inside the loop. And since the loop is happening between labels 2 and 5, do I really need that wait in the first label, or would a wait 0 be more suitable? Link to comment Share on other sites More sharing options...
ceedj Posted April 14, 2007 Share Posted April 14, 2007 (edited) Streamlined a bit... :PUNK10001: wait 250 ms>run once stuff<>run once stuff<>run once stuff<:PUNK20247: request_model #VWMYCR038B: load_requested_models:PUNK30001: wait 250 ms00D6: if 20256: player $PLAYER_CHAR defined80DF: NOT actor $PLAYER_ACTOR driving;; to check if the player is driving0248: model #VWMYCR available004D: jump if false ££PUNK200D6: if 000E1: key_pressed 0 10004D: jump_if_false ££PUNK409C7: change_player $PLAYER_CHAR skin_to 181 :PUNK400D6: if 000E1: key_pressed 0 11004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 0 0002: jump ££PUNK3 EDIT: Added a wait I forgot about. Tested and works, though in my test I used Prev/Next weapon keys (I can't figure out what controls are the straffing ones...) EDIT 2: Removed 0353:, fixed 80DF to refelect ACTOR, not player. Edited April 14, 2007 by ceedj Link to comment Share on other sites More sharing options...
PLPynton Posted April 14, 2007 Share Posted April 14, 2007 a little, might be offtopic question. what about 0353 opcode, that is a nop right? just as 0352 is in SA. or does it work without parameter? Link to comment Share on other sites More sharing options...
ceedj Posted April 14, 2007 Share Posted April 14, 2007 Interesting. Must have forgotten about that. I don't think 0353 works, like you said, but giving it no parameters doesn't crash the game. Are all the NOPs like that? Anyway, yeah, likely not needed. Link to comment Share on other sites More sharing options...
PLPynton Posted April 14, 2007 Share Posted April 14, 2007 yeap they all are like that. Link to comment Share on other sites More sharing options...
Krailer Posted April 14, 2007 Author Share Posted April 14, 2007 Streamlined a bit... :PUNK10001: wait 250 ms>run once stuff<>run once stuff<>run once stuff<:PUNK20247: request_model #VWMYCR038B: load_requested_models:PUNK30001: wait 250 ms00D6: if 20256: player $PLAYER_CHAR defined80DF: NOT actor $PLAYER_ACTOR driving;; to check if the player is driving0248: model #VWMYCR available004D: jump if false ££PUNK200D6: if 000E1: key_pressed 0 10004D: jump_if_false ££PUNK409C7: change_player $PLAYER_CHAR skin_to 181 :PUNK400D6: if 000E1: key_pressed 0 11004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 0 0002: jump ££PUNK3 EDIT: Added a wait I forgot about. Tested and works, though in my test I used Prev/Next weapon keys (I can't figure out what controls are the straffing ones...) EDIT 2: Removed 0353:, fixed 80DF to refelect ACTOR, not player. Hmm... it's strange, I can't get that to work, the game crashes after loading. I'm not sure if the fact I'm using darkpact makes any difference, though. Link to comment Share on other sites More sharing options...
Bigun Posted April 15, 2007 Share Posted April 15, 2007 (edited) Hmm... it's strange, I can't get that to work, the game crashes after loading. I'm not sure if the fact I'm using darkpact makes any difference, though. About the code: [the current] :PUNK2 is unneeded, and also you should only request the model just before you're going to use it. There isn't a loop in PUNK1 so it doesn't need a wait. Put a name_thread in PUNK1. In PUNK3 there is an if player defined check AND a check if the player is driving. That is pointless because SCM ifs don't short-circuit - if the player isn't defined, it continues to next condition, then crashes when it hits $PLAYER_ACTOR. Thats why you must separate the if player defined check and put it before any use of $PLAYER_CHAR/ACTOR (but you only need 1 check per every wait). Note, that you can combine the player defined check with the keypress check - technically it doesn't have to do with the player and it won't crash the game if he's undefined, so its good. About Darkpact: Are you putting it in correctly? I'm not entirely sure because I haven't used it in a while, but there are clear instructions with it/on Dem's website so read that and make sure. IIRC you put the new thread in the end of MAIN (before mission 0), and the create_thread inside the "darkpact code area" (designated by comments) in some mission label. This is also where you could put 1/2-liners such as pickups, car generators etc. Edited April 15, 2007 by Bigun Link to comment Share on other sites More sharing options...
ceedj Posted April 15, 2007 Share Posted April 15, 2007 In PUNK3 there is an if player defined check AND a check if the player is driving. That is pointless because SCM ifs don't short-circuit - if the player isn't defined, it continues to next condition, then crashes when it hits $PLAYER_ACTOR. Thats why you must separate the if player defined check and put it before any use of $PLAYER_CHAR/ACTOR (but you only need 1 check per every wait). Apologies for that. I don't run into this problem with the hooks I use. My bad. Link to comment Share on other sites More sharing options...
Krailer Posted April 15, 2007 Author Share Posted April 15, 2007 Ok, I tried to compact the code the more I could, to leave space to add more stuff later if I need to. It looks like this now, if there's anything else that can be improved, let me know: :PUNK10001: wait 0 ms>run once stuff<:PUNK20001: wait 250 ms0247: request_model #VWMYCR038B: load_requested_models00D6: if 10256: player $PLAYER_CHAR defined0248: model #VWMYCR available004D: jump_if_false ££PUNK200D6: if 000E1: key_pressed 0 10004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 181:PUNK30001: wait 250 ms00D6: if 000E1: key_pressed 0 11004D: jump_if_false ££PUNK209C7: change_player $PLAYER_CHAR skin_to 00002: jump ££PUNK2 While I think Darkpact is an excellent tool, I have to disagree about the instructions, which aren't all that clear, at least for beginners. At first I was renaming the "DARKPACT" labels to match my thread's name adding the new code at the end of MAIN, in the original scm. I was having strange effects after loading the darkpactor scm (as being repeatedly prompted to save) but since things were working after loading the original scm (with the code injected), I though it was fine. But then I saved the game again and tried to load the saved game, and it crashed. Then I tried adding the new code in the MAIN section of the darkpactor scm and to the bottom of the original scm, and the game crashed after loading the latter. So finally, I added the new code in the MAIN sections of both the darkpactor scm and the original scm. The game runs fine now, allowing to save and load games normally. About using the combination of 2 keys, any help? Link to comment Share on other sites More sharing options...
PLPynton Posted April 15, 2007 Share Posted April 15, 2007 About using the combination of 2 keys, any help? what do you mean by that? key A&B pressed like this? why does it not work by your side? 00D6: if 100E1: key_pressed 0 A00E1: key_pressed 0 B004D: jump_if_false ££PUNK3 or do you mean key A&B pressed together toggles skin (to the second one)? or do you mean custom keyboard keys like Y_Less did while ago with memory reading? Link to comment Share on other sites More sharing options...
Krailer Posted April 15, 2007 Author Share Posted April 15, 2007 Like in your first example, I mentioned it a few posts back. I did this... :PUNK30001: wait 250 ms00D6: if 100E1: key_pressed 0 1000E1: key_pressed 0 11004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 181 ...and it doesn't work. Pressing both keys together has no effect at all. Link to comment Share on other sites More sharing options...
PLPynton Posted April 15, 2007 Share Posted April 15, 2007 i have seen something like that before (was 3 key press) and the reason was that i have had to reassign the keys for these controls in control configuration. maybe some of the keyboards does not support some key kombinations and that is hardware limitation (like you can not detect release of key B when pressing firstly key A and holding, then B...) try to redefine controls for a test period: CONVERSATION_YES, CONVERSATION_NO Link to comment Share on other sites More sharing options...
Krailer Posted April 15, 2007 Author Share Posted April 15, 2007 (edited) It's still strange that the keys work individually, but not when combined together. But now that I think of it, I'm using a joypad but I have assigned the CONVERSATION_YES and CONVERSATION_NO to the keyboard, which works finr for normal gameplay. I'll try to assign them to joypad buttons to see if makes a difference with this mod. Thanks. EDIT: Yep, I guess that was it. Re-assigning those controls to the pad buttons solved the issue, it works perfectly now. Thanks again. Edited April 15, 2007 by Krailer Link to comment Share on other sites More sharing options...
PLPynton Posted April 15, 2007 Share Posted April 15, 2007 i am glad i could help. Link to comment Share on other sites More sharing options...
Bigun Posted April 16, 2007 Share Posted April 16, 2007 Ok, I tried to compact the code the more I could, to leave space to add more stuff later if I need to. It looks like this now, if there's anything else that can be improved, let me know I know the code has been changed a bit since that post but anyway, for starters, re-read my previous post. You haven't fixed some of the stuff I mentioned there. Note that your code WILL work as-is, but it could be better. Also, haven't you been experiencing problems? IIRC if you're using a ped skin, and your muscle or fat changes, it becomes glitchy, since it changes the model but only CJ's model can be manipulated like that. You should "disable" fat and muscle change in a way, while using a non-CJ model. A simple way out of it, could be to run a looping thread that keeps re-setting the player's muscle and fat while using a non-CJ model. It might work and it might not, and while being kind of a cheap solution perhaps, its clean and good [if it works ]. Link to comment Share on other sites More sharing options...
PLPynton Posted April 16, 2007 Share Posted April 16, 2007 yes, that is good point. even due the fact player model will be "refreshed" thru script sometimes there is one more: entering most of EnEx'es (these yellow portals) will force model refresh as well. Link to comment Share on other sites More sharing options...
Krailer Posted April 16, 2007 Author Share Posted April 16, 2007 I know the code has been changed a bit since that post but anyway, for starters, re-read my previous post. You haven't fixed some of the stuff I mentioned there. Note that your code WILL work as-is, but it could be better. Ok, this is how it looks now: :PUNK103A4: name_thread 'PUNK'>run once stuff<:PUNK20001: wait 250 ms0247: request_model #VWMYCR038B: load_requested_models00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK200D6: if 20256: player $PLAYER_CHAR defined00E1: key_pressed 0 800E1: key_pressed 0 10004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 181:PUNK30001: wait 250 ms00D6: if 100E1: key_pressed 0 900E1: key_pressed 0 11004D: jump_if_false ££PUNK209C7: change_player $PLAYER_CHAR skin_to 00002: jump ££PUNK2 About the glitch, I became aware of it some time ago when I played the LC mod. Right now I'm countermeasuring its effect with some changes in the ar_stats.dat file. I also though about changing the code in order to prevent the player from entering wardrobes (both in safehouses and shops) and barber shops when using the ped skin, and also from changing to the ped skin when inside such places. But that would probably involve messing with the code outside the MAIN area, making it incompatible with Darkpact. Link to comment Share on other sites More sharing options...
Bigun Posted April 16, 2007 Share Posted April 16, 2007 But that would probably involve messing with the code outside the MAIN area, making it incompatible with Darkpact. That doesn't make it un-DP-compatible. In fact only changes to the MAIN area make savegames uncompatible. Bout your code. Hurray for copy-pasting, why is that >run once stuff< line still there? Also, don't include request_model in a loop. You only need to request it once. You should only start requesting the model once its needed (after player pressed the keys), not have it always loaded. Also there isn't much point in keeping to check if a model is available once it is, even though that may save a bit of space there is no reason to as it will always remain loaded until you release_model it (which you should do on models after the opcodes where you've used them). Why do you have different keys for changing back to player and back to ped? Is it because of preference or because if you use same keys for both it will keep looping and changing player model because the key checks are satisfied? If so tell me as you can simply workaround that. Link to comment Share on other sites More sharing options...
Krailer Posted April 16, 2007 Author Share Posted April 16, 2007 You're making my head hurt... About the Darkpact (un)compatibility, I meant messing with the code outside the MAIN area as in changing the missions. The code I'm currently using was actually pasted inside the MAIN area (at the end) of the original scm, before injecting the code with Darkpact. How can I keep request_model outside the loop, if I should only request the model after the keys are pressed? The key press check has to be inside the loop, right? As for the different keys, I used them for the second reason you mentioned. Not that I actually experienced the looping problem, I just assumed it would happen so I never tried to use the same keys. I did forget to use 0249 after using the model, fixed now, thanks for pointing that out. Link to comment Share on other sites More sharing options...
PLPynton Posted April 16, 2007 Share Posted April 16, 2007 (edited) :PUNK103A4: name_thread 'PUNK':PUNK20001: wait 250 ms00D6: if 20256: player $PLAYER_CHAR defined00E1: key_pressed 0 800E1: key_pressed 0 10004D: jump_if_false ££PUNK200D6: if 002F2: is_actor $PLAYER_ACTOR modelID 181004D: jump_if_false ££PUNK309C7: change_player $PLAYER_CHAR skin_to 00002: jump ££PUNK2:PUNK30247: request_model #VWMYCR:PUNK40001: wait 0 ms00D6: if 00248: model #VWMYCR available004D: jump_if_false ££PUNK409C7: change_player $PLAYER_CHAR skin_to 1810249: release_model #VWMYCR ;I HAVE ADDED THAT thanx to SteaVor0002: jump ££PUNK2 Edited April 16, 2007 by PLPynton Link to comment Share on other sites More sharing options...
SteaVor Posted April 16, 2007 Share Posted April 16, 2007 (edited) EDIT: Arrgh, PLPynton, you beat me! It took some time to get used to that ugly MB code. Anyways, here's the relevant bit of my post: Heres the right order for this kind of stuff: At first we're waiting for the keys being pressed. Until then we're not introducing anything that has to do with skin change or model requesting. As soon as the keys have been pressed, we can go on to the next part of the code, in this case we check if the player already has the new skin (then the condition returns true) or still the original one(it returns false -> code continues at PUNK3). If it's true, then the skin will be changed back to the original one and the code returns to the keypress loop again. If it's false, we request the model and order the game to load it(you forgot this line, Pynton) - just once, it's not inside a loop! Then (in the next label) we just loop until it's available and can be applied to the model. release_model is missing, Pynton ! That's it. @Bigun, did you want to do it the same way, or did you want to use a toggle to solve the keypress problem? Edited April 16, 2007 by SteaVor Link to comment Share on other sites More sharing options...
Krailer Posted April 16, 2007 Author Share Posted April 16, 2007 (edited) Ah, I see now. For some reason I was convinced that anything between labels 2 and 4 would be included in the loop. But labels 3 and 4 will run only if the player current skin isn't 181. Engineous, indeed. I guess still have a lot to learn. Just out of curiosity, why haven't you used 038B and 0249? EDIT: Oops, I missed your post SteaVor while I was typing this reply. Thanks for the detailed explanation. Edited April 16, 2007 by Krailer Link to comment Share on other sites More sharing options...
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