Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Aesaar on June 12, 2014, 08:47:06 am
-
Basically, a tilefactor setting for beam weapon segments that doesn't tile. The segment appears for the first x meters of a beam and doesn't appear again. So if you wanted a segment to only appear for the first 100m of a beam, you'd have +Tile Factor: 100, 3.
I have no idea how easy this would be to do, but it would allow a lot of possibilities for beam weapons. This would allow for proper directional muzzleflashes on beam weapons, but could also be used for things like making jammed beam weapons in BP look like blowtorches rather than actual beams.
-
Scaled beam fade?
-
There was at one time an ability to specify a maximum length for a section, it was either in meters or percentage, either way if it isn't there now it should be relatively easy to re-implement (and I can say that because I implemented it once).
though your implementation is not good, this has nothing to do with tiling, it should be +max length: or something like that.
-
From an uneducated standpoint it looks like it got disabled because the beam tended to fade out too soon depending on the distance to its target.
-
That's why this needs to be defined on a per segment basis, not for the whole beam weapon. It's specifically so the first x meters of a beam can look different from the rest by applying a segment only for that part.
Bobboau: I'm not a coder. I have no idea how to implement this. This seemed the easiest way to do it, but if there's another, easier way which'll give the same results, I certainly wouldn't mind.
-
what would be really nice is the ability to specify this for start or end, you might want for instance a section that is visible only near the end, and we have enough data to allow that in that a negative max length could mean length from end, not start.
I have no development environment set up so I can't just do it and test it and post a proper patch, but if someone who does have such an environment would like to give this a shot what you would have to change is...
weapons.h
beam_weapon_section_info - you need to add a float, lets call it max_length
weapons.cpp
parse_weapon - at the end of the section parse code (after stuff_float(&bsip->translation); before // if we are actually removing this index then reset it and we'l) add
if ( optional_string("+Max Length:") )
stuff_float(&bsip->max_length);
else
bsip->max_length = 0.0f;
beam.cpp
beam_render -- find the chunk that looks like this:
// calculate the beam points
scale = frand_range(1.0f - bwsi->flicker, 1.0f + bwsi->flicker);
beam_calc_facing_pts(&top1, &bottom1, &fvec, &b->last_start, bwsi->width * scale * b->shrink, bwsi->z_add);
beam_calc_facing_pts(&top2, &bottom2, &fvec, &b->last_shot, bwsi->width * scale * scale * b->shrink, bwsi->z_add);
and change it to this
length = vm_vec_dist(&b->last_start, &b->last_shot); //this line is lower in the function, it needs to be moved above start/end point calculation, it actually could be moved out of the loop entirely
vec3d beam_section_start = b->last_start;
vec3d beam_section_end = b->last_shot;
if(bwsi->max_length > 0.0f){
vm_vec_scale_add2(&beam_section_end, &beam_section_start, &fvec, MIN(length, bwsi->max_length));
}
else if(bwsi->max_length < 0.0f){
vm_vec_scale_add2(&beam_section_start, &beam_section_end, &fvec, -MIN(length, -bwsi->max_length));
}
// calculate the beam points
scale = frand_range(1.0f - bwsi->flicker, 1.0f + bwsi->flicker);
beam_calc_facing_pts(&top1, &bottom1, &fvec, &beam_section_start, bwsi->width * scale * b->shrink, bwsi->z_add); //note beam_section_start
beam_calc_facing_pts(&top2, &bottom2, &fvec, &beam_section_end, bwsi->width * scale * scale * b->shrink, bwsi->z_add); //note beam_section_end
{grrrr... cannot add any formatting to code blocks, can't highlight changes}
-
Use quotes instead