Can i get some help with this script?

Discussion in 'Fallout General Modding' started by Josan12, Jan 15, 2009.

  1. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Heh, you know Josan, I really don't know much about this. Just thinking out loud.
    Nah, what I was suggesting was that they all go for the same hex. The first critter to reach it gets that bed, so the rest will then go for the next available hex (bed), and so on until they are all taken. What you said would probably work pretty much the same way.
    I have no idea if this will work and what will happen with the ones that don't get a bed. They would keep going on with their normal business I hope (by checking a variable to not going for a bed anymore if all beds are taken).
    I don't like this way much though, with everyone moving at once.
    But I don't know if much can be done without giving them individual scripts.

    I think the trigger for both go in critter_p_proc (by checking the time). What you need is two different sequences. I don't know how to do it but know it can be done.
     
  2. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Wow, thanks Jesse! Help from BIS (RIP) directly!! :D

    Unfortunately i'm a scripting noob and only understand about 50% of what you just said. I've no experience with GVARs (or even LVARs for that matter) so i think i need to go back to basics.

    Can someone (looks pleadingly at Darek) give me the basic framework on a script to make the Arroyo warriors move to the Elders tent at 9pm? If i have something basic to work with i might be able to build up from there....

    :oops:
     
  3. brother_soifran

    brother_soifran Look, Ma! Two Heads!

    396
    Oct 14, 2008
    Gronichonha Brothers Scripters !!!
    You need a manager for your work !!!
    I think only few people have idea of what you are talking about.
    So I allow me to make a movie of this fabulous idea
    and test it in my laboratory.
    Here is what we talk about in this thread...
    We talk about making more "realistic" our favorit univers.

    Schuss

    Brother Soifran

    <div><embed src="http://www.dailymotion.com/swf/x9r4rv_se-coucher-dans-fallout-go-to-sleep_videogames&related=1" type="application/x-shockwave-flash" width="480" height="381" allowFullScreen="true" allowScriptAccess="always"></embed></object>
    Se coucher dans FAllout/ Go to sleep in fallout
    envoyé par soifette - Découvrez plus de sujets sur les jeux vidéo !</div>

    PS:Here are the french translation for this "trait" ;)
    If someone want to apply it in some mod :D

    Code:
    {150}{}{Tu t'allonges et t'endore rapidement...}
    {151}{}{Tu dors durant plusieurs heures.}
    {152}{}{Tu te reveilles douvement et tu te sens un peu mieu.}
    
    {160}{}{ Zzzzzzzz.}
    {161}{}{ zzzzzzz.}
    {162}{}{ Rooonnfflllll ... rrreeeeuuufflll .. zzz.}
    {163}{}{ zzzz .... oui ...tu es si belle ... zzzz ....}
    {164}{}{ Ronflement.}
    {165}{}{ zzzzzzzzz.}
    I have allowed me a personal translation of the line 163 :)
    in english it could be translated by:
    {163}{}{ zzzz .... yes ...You're so niiiicceeee ... zzzz ....}
     
  4. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Thanks Brother - that's a good illustration of what the script does. It's very easy simple script for the dude.

    So, i've figured out how to have critters gather at a certain point at a certain time. Progress!!

    Here's what i have so far:

    Code:
    procedure critter_p_proc begin
    
    if (game_time_hour == 1801) then begin  
    animate_move_obj_to_tile (self_obj, 20716, 1);
    end
    
    if (game_time_hour == 1802) then begin  
    script_overrides;
    reg_anim_clear(self_obj);
    reg_anim_begin();
    reg_anim_animate_reverse(self_obj, 37, -1);
    reg_anim_animate(self_obj, ANIM_fall_back_sf, -1); 
    //animate_set_frame(ANIM_fall_back_sf);
    reg_anim_end();
    
    float_msg(self_obj,"zzzzzzzzz",2);
    
     end
    
    end
    
    Unfortunately, the critters can't seem to play the animation - it just goes into a crazy jitter - presumably because it's trying to play multiple animations at the same time?

    Can anyone see my problem??
     
  5. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Nice start Josan, or at least a start. :)
    I have a feeling it's gonna need a lot of tweaking as we learn how to do it.

    I tried to have the "move to tile" bit in a different procedure than critter_p_proc, I was looking at how they did with the Duntons, but couldn't get it to work that way. So it will have to stay where it is, at least for now.

    You will have to disable the critters normal walking about at the same time as you want them to move to a hex or they wont stay still. This should do for now, but will have to be changed later:
    Code:
    procedure critter_p_proc: 
    change  if ((random(0,200) == 1) and (In_Timed_Event == 0) then begin
    into    if ((random(0,200) == 1) and (In_Timed_Event == 0) and (game_time_hour < 1800) then begin
    I would also suggest starting your move to hex at 1800 sharp.
    So you don't have to wait one minute when testing, but just sleep until it's time.

    I'm not sure why the animation is not working. I tested to use it on only one critter but it was the same. I don't think it's a good way to do it with (game_time_hour == 1802), that may be why it's acting up. Setting a variable when starting the animation (and having a check for it), so it don't play more than once may fix it. Or maybe it can't be placed in critter_p_proc (trying to play them all at the same time). He, I just rested for ten minutes while they were spastic, after that they went down and slept until 24. Wierd.

    Also, now the critters are running to their destination, wouldn't it be better if they walked?
    Code:
    change    animate_move_obj_to_tile (self_obj, 20716, 1); 
    to        animate_move_to_tile (20716);
    Unfortunately I didn't understand much of what you said either, Jesse. :(
     
  6. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Yeah, that's true. They keep trying to run their 'wander' scripts and then running back to the hex! I was hoping the 'script_overrides' and/or 'reg_anim_clear' would stop them trying to continue their default scripts but maybe not ...

    Ermm, i have no idea what you're referring to here. :oops:

    Good idea.

    Yeah, i think you're right. I know from experience the critter_proc runs 100's of times per second. I'm gonna need to learn about GVARs and LVARs then .... and i'm probably gonna need your help as i know so little about anything related to scripting ... :crazy:

    The official editor guide says the final integer in the move_to_tile command is how fast the critter moves. I experimented with it but it didn't seem to affect anything... :(
     
  7. Darek

    Darek is currently unavailable

    Jan 7, 2008
    I guess you just missed my edited post. Read it again, as I posted how to make the critters walk instead of run.

    What I was referring to was what sets the critters to randomly walk around. I assume you are still using acwarior.int as test script?
    In the last part of "procedure critter_p_proc" there is call to check when to start that walking about sequence. By adding "and (game_time_hour < 1800)"
    there will be no moving around between 6pm and 24. That should be enough for testing purposes, but will have to be fixed properly later.
     
  8. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Oh - sorry - gotcha. I missed it but understand now.

    Yes, i'm still using acwarior for testing purposes. And now i understand what you mean. I tend to get mental blocks when it comes to ultra-logical things like scripting - but when someone explains it I can get past it. (i'm mostly an art guy, remember!!) Thanks Darek!! I'll post my progress ....
     
  9. Jesse Heinig

    Jesse Heinig First time out of the vault

    66
    Dec 12, 2008
    Sorry I wasn't super clear - it's been 12 years since I did scripting on Fo1, after all!

    Here's the skinny. Probably the closest script to what you want to do in the actual Fo1 build is the people in Vault 13 lining up to pick up their water rations. Everyone queues up at a specific hex, and if that hex is full (someone else got there first) they just wait at the next available hex, then move in to the hex once it's vacated because the previous occupant left to get water from the ration officer.

    Of course, you want to have beds all over the map, so you need different hexes where people can go. As previously suggested, you could have everyone go for the same bed, then if it's full, abort and go to the next one. This creates the unusual artifact that critters may not consistently use the same bed, and it will look strange when folks are all bee-lining for the same bed and then peel off when someone gets there first.

    For your map, do you expect some of the critters to have specific beds that they always use? If so, just put that bed's target hex for the destination. For critters that look for random beds, you may want to use the system that I tried to describe earlier.

    I wish I could actually write this code, but it's been so long that I'd just hose it up unless I actually practiced implementing it in Fo1 right now, and I'm so sick that I don't have the concentration for it at the moment.

    There's a command called EXPORT (I believe! - again, been so long) that causes a script to make a variable visible to other scripts in the map. This allows you to pass variables to other scripts when something is activated. For instance, check the script for the Vault 13 door control panel in the cave. After the initial few days when it's closed, the script is set up so that if you use the panel, it changes an exported variable. The door, on heartbeat, detects that this variable has changed and then opens. (At least, that's how I initially wrote it.) By using this method you can enable other scripts to see internal variables. This means you can (for instance) have the map heartbeat script keep track of bed locations, and push them onto an exported variable. Then the various people on the map can tell when there is a bed available (the imported variable is not null) and the first critter to see it will grab the destination hex.

    As far as the animation, there was a known problem with the animation sequencer when you change maps, so possibly that, or else the character is trying to run the animation multiple times. (As soon as you start the animation, set a variable so that the character doesn't try to start it again next update.) Check the scripts for the manhole covers in Necropolis; though on retrospect I'm not sure if that will help - the problem there was that the player sprite would be stuck in the "climbing" animation after map change, so I had to call an "animate_stand" to force him back to a standing position on map transition.

    Once I'm not sick any more I'll see if I can work up something more concrete, with some code.
     
  10. Darek

    Darek is currently unavailable

    Jan 7, 2008
    He he, I think it's more to do with our scripting abilities than you. It's really nice seeing an original developer still taking an interest. Any help you could give would be greatly appreciated. :)

    My script idea was mainly to get started.
    Anyway I had the junkies in the Den in mind, where that kind of first serve, random script could fit. Though it would look a bit silly if all of them moved at the same time. I was thinking they could check at certain intervals if they want to sleep, and then look for a bed place. There is a place with a few mattresses there, so they wouldn't run all over the map looking for a bed.
    On maps with beds spread out all over it, I was thinking of having a list of available beds and have the critters randomly pick one, walk up to that bed and then if it's taken look for another one. It would be more realistic if they have a preferred one but that would be pretty hard for critters sharing the same script. Maybe it could be done by using a local variable that gets set to the first bed the critter tries to use?
    Ordinary town people should probably have their own beds (though I don't know how ambitious this is to be).
    I'm also wondering if it's possible to get critters to go to sleep on a different map than what they are currently in, though tat may be to overly complicate things.

    As of now only flat beds can be used. Need to know how to remove and place secret blocking hexes through scripts for other kinds to work. Also getting the critter to face the correct direction before lying down would be good.
    Josan, is it only the dude_obj that has climb animations? I got him to climb up a bunk bed and sleep in it. Would be cool if other critters could do it too (like the mutants in the military base), but I fear not.

    I have seen the export command in several scripts but haven't studied just how it works.
    This sounds like a really nice way to do it. Though a bit complicated for us noobs. ;)
    I was thinking of having a map variable for every bed and set it to used or unused. A bit crude maybe.
    Looking forward to see an example of this (or anything else) if you get the time.
    Hope you get well soon.
     
  11. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Oh yeah, that would be awesome! Thanks Jesse. As Darek says: it's not your poor explanation so much as our (well, my) noob-ness that's holding us back here.

    But to clarify my intentions: way i see it, there's a few different groups of townsfolk to be handled differently:

    a) the 'generic' townsfolk (of which there are often many - 10 or more) such as the 'Den Junkies'. These are the main problem becuase, as we know, they share one script, so will need some kind of randomized way to 'choose' from different beds (hexes) scattered around the map. I think it would be fairly easy to set a random 'bed-time' variable - or just have a 1% chance every critter heartbeat between 1800 and 2200 that the critter will go to bed - thus preventing them all stampeding to the first bed on the list at 2000 (or whatever) and looking ridiculous!!

    b) the smaller group of 'generic' townsfolk' such as Arroyo warriors - of which there are only a few. They can probably just crowd a single hex in their seperate script

    c) unique townsfolk with individual scripts (such as aunt morlis) obviously - as they have their own script there's no problem as we can simply have them move to ther own hex (bed)
     
  12. Jesse Heinig

    Jesse Heinig First time out of the vault

    66
    Dec 12, 2008
    Oh yeah, one other thing. Based on what I recall, the script_overrides() command exists to cause a script to prevent an object from doing what it normally does when you use it in some fashion. For instance, you could (theoretically - I haven't tried this) put a script_overrides() command on a critter so that when the player tries to Steal from the creature, instead of bringing up the usual stealing windows it causes the creature to float a message and run away and then prints the text "Your hand seems to be covered in some kind of unidentifiable goo." Typically you only need to use script_overrides() when you need something to function in a way that is different from how it would normally function. Thus, you don't generally need script_overrides on, say, a heartbeat script, since the heartbeat script is telling the critter what to do anyway.

    Usual caveats apply about 12 years, still sick, etc.
     
  13. Per

    Per Vault Consort Staff Member Admin

    Apr 1, 2004
    This was used in the games for preventing the player from using Steal on robots and animals.
     
  14. lisac2k

    lisac2k Vault Senior Citizen
    Modder

    Oct 26, 2004
    Actually, that can be (and mostly was) set in protos, IIRC. A few exceptions were set in the scripts, though.

    Josan,your idea is commendable, I had some thoughts about something similar years ago, but never pulled it out. Would be glad to see you getting it done right.
     
  15. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Here's a rough idea:

    Code:
    if game time hour == 1800 then begin
    animate move to tile xxxx
    if self obj is at tile xxxx then begin
    (sleeping script)
    else then begin
    animate move to tile xxxy
    if self obj is at tile xxxy then begin
    (sleeping script)
    else then begin
    animate move to tile xxyz
    
    etc etc ...

    Would this work?

    Or does anyone have any ideas how to incorporate an L/G/MVAR to 'track' the list of beds (hexes)?? This is a bit beyond my understanding unless someone was to explain how to use L/G/MVAR's to me ...
     
  16. Darek

    Darek is currently unavailable

    Jan 7, 2008
    @ Josan,
    I played around a bit with critters going to sleep in a normal bed. Balthas wife in Modoc to be exact. Between 10 pm and 6 am she will go (not random). Maybe it would be better to teleport her in 'map_enter_p_proc' too, so you don't have to see her if you arrive in the middle of the night?
    Anyway she just walks up to the bed when the time is right, remove some secret blocking hexes, walks up on the bed, turns around, and go to sleep. Still need to do everything in reverse for when she wakes up.
    EDIT: Now she wakes up and goes back to her normal place after 6 am (she also blocks the bed again).
    Edited again:
    Code:
    mcBalWif.int
    
    procedure critter_p_proc
    begin
    	if ((game_time_hour > 2159) or (game_time_hour < 600)) then begin
    		if (local_var(8) > 6) then begin
    			set_local_var(8, 0);
    		end
    		if (local_var(8) == 0) then begin
    			animate_move_obj_to_tile(self_obj, 12695, 0);
    		end
    		if (tile_distance(tile_num(self_obj), 12695) < 1) then begin
    			destroy_object(tile_contains_pid_obj(12495, 0, 33554499));
    			destroy_object(tile_contains_pid_obj(12295, 0, 33554499));
    			destroy_object(tile_contains_pid_obj(12095, 0, 33554499));
    			animate_move_obj_to_tile(self_obj, 12095, 0);
    			set_local_var(8, 1);
    		end
    		if ((tile_distance(tile_num(self_obj), 12095) < 1) and (local_var(8) == 1)) then begin
    			set_local_var(8, random(2, 3));
    		end
    		if (local_var(8) == 2) then begin
    			anim(self_obj, 1000, 2);
    			set_local_var(8, 4);
    		end
    		if (local_var(8) == 3) then begin
    			reg_anim_func(2, self_obj);
    			reg_anim_func(1, 1);
    			reg_anim_animate_reverse(self_obj, 36, -1);
    			reg_anim_animate(self_obj, 49, -1);
    			reg_anim_func(3, 0);
    			set_local_var(8, 5);
    		end
    		if (local_var(8) == 4) then begin
    			reg_anim_func(2, self_obj);
    			reg_anim_func(1, 1);
    			reg_anim_animate_reverse(self_obj, 37, -1);
    			reg_anim_animate(self_obj, 48, -1);
    			reg_anim_func(3, 0);
    			set_local_var(8, 6);
    		end
    	end
    	else begin
    		if (local_var(8) < 5) then begin
    			set_local_var(8, 8);
    		end
    		if (local_var(8) == 5) then begin
    			reg_anim_func(2, self_obj);
    			reg_anim_func(1, 1);
    			reg_anim_animate(self_obj, 36, -1);
    			reg_anim_func(3, 0);
    			set_local_var(8, 7);
    		end
    		if (local_var(8) == 6) then begin
    			reg_anim_func(2, self_obj);
    			reg_anim_func(1, 1);
    			reg_anim_animate(self_obj, 37, -1);
    			reg_anim_func(3, 0);
    			set_local_var(8, 7);
    		end
    		if (local_var(8) == 7) then begin
    			animate_move_obj_to_tile(self_obj, 12494, 0);
    			if (tile_distance(tile_num(self_obj), 12494) < 1) then begin
    				create_object_sid(33554499, 12495, 0, -1);
    				create_object_sid(33554499, 12295, 0, -1);
    				create_object_sid(33554499, 12095, 0, -1);
    				set_local_var(8, 8);
    			end
    		end
    		if (local_var(8) == 8) then begin
    			animate_move_obj_to_tile(self_obj, 11505, 0);
    		end
    		if ((tile_distance(tile_num(self_obj), 11505) < 1) and (local_var(8) == 8)) then begin
    			anim(self_obj, 1000, 3);
    			set_local_var(8, 0);
    		end
       end
    end
    
    procedure destroy_p_proc
    begin
    	if ((local_var(8) > 0) and (local_var(8) < 8)) then begin
    		create_object_sid(33554499, 12495, 0, -1);
    		create_object_sid(33554499, 12295, 0, -1);
    		create_object_sid(33554499, 12095, 0, -1);
    		set_local_var(8, 0);
    	end
    end
    
    procedure map_enter_p_proc
    begin
    	if ((game_time_hour < 600) and (local_var(8) == 0)) then begin
    		critter_attempt_placement(self_obj, 12695, 0);
    	end
    	if ((game_time_hour > 600) and (local_var(8) > 0)) then begin
    		reg_anim_func(2, self_obj);
    		reg_anim_func(1, 1);
    		reg_anim_animate(self_obj, 37, -1);
    		reg_anim_func(3, 0);
    		critter_attempt_placement(self_obj, 11505, 0);
    		create_object_sid(33554499, 12495, 0, -1);
    		create_object_sid(33554499, 12295, 0, -1);
    		create_object_sid(33554499, 12095, 0, -1);
    		set_local_var(8, 8);
    	end
    end
    
    What's in 'procedure critter_p_proc' to start with needs to be blocked out with /* text */, as it's not compatible with the new stuff (she reacts to the dudes presence), unless you incorporate the new code properly.
    Some of the code looks a bit different cause I used a decompiled script and therefore didn't use any headers.
    Do you see how I used Local variable 8 to make sure each part is only done once?

    You can get the updated script here if you wanna check it out in action (sorry, no video).
     
  17. brother_soifran

    brother_soifran Look, Ma! Two Heads!

    396
    Oct 14, 2008
    Hej min Viking här videon

    first I must explain my small advertissement for continuum tiles ;)
    thanks :)
    Ok now I let you see the darek the red's work :

    Schuss

    Brother Soifran the Gaulois :)

    <embed src="http://www.dailymotion.com/swf/x9thzp_fallout2-npc-sleeping_videogames&related=1" type="application/x-shockwave-flash" width="480" height="381" allowFullScreen="true" allowScriptAccess="always"></embed>
    Fallout2 NPC sleeping
    envoy&eacute; par soifette. - Plus de jeux vidéo !</div>

    PS: Very cool and nice work Darek...
     
  18. Darek

    Darek is currently unavailable

    Jan 7, 2008
    Merci beaucoup frère_soifran. :)
    Oui, je m'appelle 'Serpent Rouge' et je suis un grand viking. ;)

    Anyway, I updated Balthas wife's sleeping script again. She now randomly sleeps on her back or on her belly, and if you enter the map in the middle of the night or daytime, she will be teleported to the proper place (either in bed or standing in her corner), no matter where she was when you left the map earlier. Also fixed so her movement don't break if she's blocked and that if the time changes in between her sequence (pipboy advanced time) she will now know where to be and respond accordingly.
    I also fixed so the bed gets blocked again if you kill her at night time.

    I'm pretty sure what I put in 'procedure destroy_p_proc' and 'procedure map_enter_p_proc' will not break anything, but I'm not sure about the code that was in 'procedure critter_p_proc'. I think I integrated my code properly with the old (turned it off at night), but the problem is that I'm not sure what it's supposed to be doing, so it's hard to test. I haven't noticed anything strange though. If someone with a bit more knowledge about scripts could take a look please?

    Sadly there seems to be two problems that keeps me from doing what I want. The beds don't seem to big enough for two people to sleep next to each other (possibly if both are sleeping on their bellies, haven't tried that yet), and I don't think a critter can lie down on top of another (so no sex scenes ;)).
     
  19. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    Ah! You read my my mind, Darek!! I had the same idea. But of course you did it better ;) :p

    I like your script very much - clever idea with the blocking hex's. I planned to only use flat beds for most critters. But some have their own bedrooms and have raised beds so you found a good solution.

    I have only 2 concerns:

    a) the script is getting quite complex!! and as you can already tell, will probably start to require de-bugging once it gets to a certain level of complexity. I'd be happy at least making a mod that sends critters with their own, unique scripts to bed. But i think it would be best if it was very simple and didn't require blocking hexes as that will take a long time to tailor to each individual script. I think it would better to have them lie on a flat bed - even if it means changing the scenery a little. Where it would look ridiculous to add a flat bed (for example - in Vault 13) we could just bugger it and have the critter 'dissapear' for the night.

    b) of course it doesn't adress our problem of what do do for the 'generic townsfolk'. I've working on this but am severeley hampered by my lack of understanding of scripting.

    c) Can you explain how you solved the problem with the animations?? why do they get stuck in the crazy spasm!?!?

    I'm really keen to see this thing implemented in-game (especially as we have it first-hand from a BIS dev that this was intended!!)

    But because im such a noob scripter it would be better if someone else could write the script and i'm quite prepared to do all the grunt-work trawling through the scripts plugging it in and setting the hexes. Whaddya think, folks?? Thoughts?
     
  20. Josan12

    Josan12 Vault Senior Citizen

    Oct 15, 2007
    I have a question: As part of my resting mod, i want the rooms that you pay for in the game to actually be something useful. Here's my proposal:

    a) make the doors on the pay-for rooms locked under a high difficulty lock (easy change - i can do this)
    b) make the beds in said rooms 'useable' that will heal 999hp (easy change can do this)

    So, when the player pays for their room, they get teleported into the room, past the locked door. They use the bed, and get their healing.
    The problem is - how do they get out without a high lockpick skill??!?!

    Can anyone think of a solution to this? Or another way to acheive my aim? It's got me stumped. :(