I'm thinking in a new map, but before I begin making it I need to know if it's possible. I know how to move brushes, triggers..., but is there any way to move prefabs without stamping them? Thanks.
no you can't move prefabs as if they are one ent, i think they are 'stamped' when compiling anyway. Need to stamp it and make sure the things you want to move are script_model / script_brushmodel and work from there like you normally would..
Ok. Thank you. So, let's say I want to move a perk. I have to move every single brush or model the prefabs has, right? And I saw there's a script_struct in the prefab, I think for the music. Is it possible to move those things? I haven't tested it yet.
yes, you would have to move every single piece seperately. Dont think you can move structs, maybe just like triggers you can give them a new .origin, but i dont think moveto() for example will work on a struct. Change it into an _origin and adjust the perk-script to work with that is also an option.
I've just tested it and it's not necessary to change to an _origin. I could move them by changing the .origin. But I need to move them relatively. So, is it possible to accede to the X, Y and Z of a vector separately? Or is it possible to operate with vectors? Like:
Code Snippet
Plaintext
struct.origin += (x,y,z)
Or similar. Double Post Merge: September 06, 2015, 12:57:11 pm
Dont think you can move structs, maybe just like triggers you can give them a new .origin
I think you can link a struct to an ent using linkto.At least I do in my perk randomize.I link everything to one item, then just move that one item. I am 99 percent sure it was working right anyway, lol.
And I never stamp anything, I script it dynamically and use auto kvps with the w, when making prefabs. I don't stamp cause if you have multiple ents linked with the auto kvp, and stamp, it sequences them, and fs up the kvps.
Last Edit: September 06, 2015, 05:11:38 pm by MakeCents
And I never stamp anything, I script it dynamically and use auto kvps with the w, when making prefabs. I don't stamp cause if you have multiple ents linked with the auto kvp, and stamp, it sequences them, and fs up the kvps.
Sorry, I haven't understood anything here . Too hard for me.
So, can I link anything to a brush? This would make my work easier.
Sorry, I haven't understood anything here . Too hard for me.
So, can I link anything to a brush? This would make my work easier.
You can link ent's together, so they will move as one. I've had issue's with this in the past in coop game's where for clients not every ent would move, while for the host everything looked fine. I managed to fix it in the end, but cant remember what the problem was..
Yeah, I knew those. I'm sure they work with triggers, zones and zombies, but do them work with everything?
I'll make a script example and prefabs for you later tonight, with an explanation. Double Post Merge: September 07, 2015, 06:05:44 amWell, I regret to inform that this whole time I thought I was moving the struct, and I wasn't, so blunt was right on the linkto buisness not working for them. Which means I'll have to adjust that in the future for my randomizer. I made something to move the struct the way blunt said in the script.
I made a pefab, explained below, then a script, and then I made a video, which I placed at the bottom to see what it is doing. This script prob won't work for what you are doing, you may need to be more specific, but it shows how you can move one item and everything goes with it. I inserted the prefab and pressed space to copy it three times.
PREFAB I set up a prefab, with an ent, then linked a trigger, and then linked a struct to the trigger and a couple more ents so you can see it is all linked.
SCRIPT Then I made a function to get an array of my ents (GetMyParts). Next I thread a function on each ent that gets the target ent and links it to the ent. If that target ent also has a target, then get it and link it too but calling the same function on it, and so on and so on. Then I made a function just to do something to show that it is working. It will play an fx after moving at the struct position. The functions below are to "move" a struct or array of structs. It spawns an ent where the struct is, links to the ent that you will move, and then moves the struct to the ent after it moves, then deletes it.
Code Snippet
Plaintext
//thread GetMyParts(); GetMyParts(){//get all the models to move parts = getentarray("exampleparts", "targetname"); array_thread(parts,::LinkParts); } LinkParts(){//decide to link and/or get more ents to link if(!isDefined(self.target)) return; myEnts = GetEntArray(self.target,"targetname"); if(isDefined(myEnts) && myEnts.size>0){ array_thread(myEnts,::LinkParts, self); array_thread(myEnts,::LinkThem,self); } } LinkThem(linkToMe){//enable link for trigs and link everything if(isDefined(self.classname) && isSubStr(self.classname,"trigger")){ self SetCursorHint("HINT_NOICON");//I only do this hear, cause it isn't done else where self setHintString("Press &&1 to do something");//I only do this hear, cause it isn't done else where self thread MakeMeDoSomething(linkToMe); self enableLinkTo(); } self linkto(linkToMe); } MakeMeDoSomething(moveMe){//just to move it and test if(!isDefined(moveMe)) return; while(1){ self waittill("trigger"); self MoveMyStructs(moveMe, 200); wait(5); self MoveMyStructs(moveMe, -200); } } //Functions that "move" structs MoveMyStructs(moveMe, move){//struct moving functions structs = undefined; if(isdefined(self.target)) structs = GetStructArray(self.target,"targetname"); if(isDefined(structs) && structs.size>0) for(i=0;i<structs.size;i++) moveMe BeforeMoveStructs(structs[i]); moveMe MoveTo(moveMe.origin + (0,0,int(move)),.01); wait(.1); if(isDefined(structs) && structs.size>0) for(i=0;i<structs.size;i++) moveMe AfterMoveStructs(structs[i]); } BeforeMoveStructs(struct){//struct moving functions ent = spawn("script_origin",struct.origin); ent.origin = struct.origin; ent linkto(self); struct.ent = ent; } AfterMoveStructs(struct){//struct moving functions struct.origin = struct.ent.origin; struct.ent delete(); struct.ent = undefined; PlayFx(level._effect["poltergeist"], struct.origin); }
Wow! Thank you! I need to take a time to study your code, but it looks like I can do what I want. Double Post Merge: September 07, 2015, 10:34:53 amI don't understand everything but it works as I want. I think I'm going to use it editing it a bit. Well, thank you for the help and for that tut.
Last Edit: September 07, 2015, 10:34:53 am by Soy-Yo