• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code [HELP]Changing weapon hitting angle

Dinamix

Grizzled Veteran
Mar 23, 2012
199
1
I found weapon wich hits 360 angle. How to change to 160?
I think calculation is here ,but i dont understand how it calculates.
Code:
IsSoundPlayed = false;
for(dalpha=5;dalpha<=32728;dalpha+=180)
{
	tempalpha=PointRot.Yaw+dalpha;
	if(tempalpha>65535) // if angle more then 360
		AdditionalHit(tempalpha-65535);
	else
		AdditionalHit(tempalpha);
	AdditionalHit(PointRot.Yaw+dalpha);
	tempalpha=PointRot.Yaw-dalpha;
	if(tempalpha<0) // if angle negative
		AdditionalHit(65535+tempalpha);
	else
		AdditionalHit(tempalpha);
}			
clearHitted();
 
Code:
IsSoundPlayed = false;
for(dalpha=5;dalpha<=32728;dalpha+=180)
{
    tempalpha=PointRot.Yaw+dalpha;
    [COLOR=yellow]if(tempalpha>65535) // if angle more then 360[/COLOR]
[COLOR=yellow][/COLOR][COLOR=yellow]        AdditionalHit(tempalpha-65535);[/COLOR]
    else
        AdditionalHit(tempalpha);
    AdditionalHit(PointRot.Yaw+dalpha);
    tempalpha=PointRot.Yaw-dalpha;
    if(tempalpha<0) // if angle negative
        [COLOR=yellow]AdditionalHit(65535+tempalpha);[/COLOR]
    else
        AdditionalHit(tempalpha);
}            
clearHitted();
I pressume it's where I highlighted yellow. Can someone confirm?
 
Upvote 0
Code:
IsSoundPlayed = false;
for(dalpha=5;dalpha<=32728;dalpha+=180)
{
    tempalpha=PointRot.Yaw+dalpha;
    [COLOR=yellow]if(tempalpha>65535) // if angle more then 360[/COLOR]
[COLOR=yellow][/COLOR][COLOR=yellow]        AdditionalHit(tempalpha-65535);[/COLOR]
    else
        AdditionalHit(tempalpha);
    AdditionalHit(PointRot.Yaw+dalpha);
    tempalpha=PointRot.Yaw-dalpha;
    if(tempalpha<0) // if angle negative
        [COLOR=yellow]AdditionalHit(65535+tempalpha);[/COLOR]
    else
        AdditionalHit(tempalpha);
}            
clearHitted();
I pressume it's where I highlighted yellow. Can someone confirm?
If you are correct ,then why it does need dalpha?
 
Upvote 0
I would go with something like this:
Code:
IsSoundPlayed = false;
for(dalpha=5;dalpha<=32728;dalpha+=180)
{
	tempalpha = ((PointRot.Yaw+dalpha) & 65535) % 58240.f;
	if( tempalpha>29120 )
		tempalpha-=58240;
	AdditionalHit(tempalpha);

	tempalpha = ((PointRot.Yaw-dalpha) & 65535) % 58240.f;
	if( tempalpha>29120 )
		tempalpha-=58240;
	AdditionalHit(tempalpha);
}			
clearHitted();
 
Upvote 0
I would go with something like this:
Code:
IsSoundPlayed = false;
for(dalpha=5;dalpha<=32728;dalpha+=180)
{
	tempalpha = ((PointRot.Yaw+dalpha) & 65535) % 58240.f;
	if( tempalpha>29120 )
		tempalpha-=58240;
	AdditionalHit(tempalpha);

	tempalpha = ((PointRot.Yaw-dalpha) & 65535) % 58240.f;
	if( tempalpha>29120 )
		tempalpha-=58240;
	AdditionalHit(tempalpha);
}			
clearHitted();

Correct, exact code I would have used. Thanks for helping these guys out Marco :D !
 
Upvote 0