Forum

Mathlib v2

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Postby Dr. Shadowborg » Sat May 20, 2006 1:04 am

http://tlb.circa1984.com/dev/mlx20.zip

Quake Archive Mirror
http://quake.errorabove.com/QuakeC/Weapons/mlx20.zip

Mathfrag Final.

Uses min, min3, max, max3, anglemod, randomvec, sqrt, pow.

Four weapons.

Piecemaker (replaces grenade launcher)
Mr. Smartypants (replaces super nailgun)
Ulysses DemiCannon (replaces supershotgun)
Forte Scale Blaster (replaces nailgun)

You can do whatever you want to with this Frik. :wink:

EDIT: above has been updated following the release of MathFrag Final. I'm not going to do any more on this, due to idea burnout.

Besides, I really should get back to Quake: Operation Hellsmash anyway.
Last edited by Dr. Shadowborg on Mon May 22, 2006 3:08 am, edited 2 times in total.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby leileilol » Sat May 20, 2006 1:15 pm

the super nailgun is dancing !
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby FrikaC » Sat May 20, 2006 3:41 pm

Hey cool DrShadowb0rg, I'll try it out later today. Though it would be cool if you could come up with some things using the more interesting match functions, sqrt, pow etc.

I stealithly uploaded a new mathlib yesterday, recheck the link from the first post.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Dr. Shadowborg » Sat May 20, 2006 6:18 pm

FrikaC wrote:Hey cool DrShadowb0rg, I'll try it out later today. Though it would be cool if you could come up with some things using the more interesting match functions, sqrt, pow etc.

I stealithly uploaded a new mathlib yesterday, recheck the link from the first post.


I'll see what I can think up, no guarantees though. :wink:


EDIT: Thought up two, they will be ready sometime tomorrow, day after at the latest.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby Dr. Shadowborg » Mon May 22, 2006 2:08 am

Final version from me posted, see original post for ldownload and quick info.

Condiments and bug reports appreciated.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby leileilol » Mon May 22, 2006 2:40 pm

the reflecting rocks

no more abusing movetype_bounce + gravity 0!
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby Dr. Shadowborg » Mon May 22, 2006 4:55 pm

CheapAlert wrote:the reflecting rocks

no more abusing movetype_bounce + gravity 0!


Actually, the rebounding stuff doesn't use mathlib.qc functions. It's closer to the code that was used in scourge of armagon, only heavily modified to use a function I wrote called ReboVec. I haven't tested it yet, but in theory, ReboVec can even be used to provide richocet vectors for even hitscan type attacks.

Uses of mathlib.qc in the two new weapons:
sqrt: Used in the DemiCannon's damage calculation for direct hits.
pow: Used in the Forte Scale Blaster's damage calculation.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby Lardarse » Mon May 22, 2006 5:37 pm

Is that why it has the same bug as SoA, where the rebound always gets forced closer to the normal than it should be, because you are doing out_vector = in_vector - (normal * 2) and instead you need to do out_vector = in_vector + (normal * (normal * in_vector) * 2) (Thanks to div0 for helping me to work this out)

Also, the spawn weapon feels far too strong, but that's somehting that can be sorted out by almost anyone :-)
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Dr. Shadowborg » Mon May 22, 2006 6:54 pm

Lardarse wrote:Is that why it has the same bug as SoA, where the rebound always gets forced closer to the normal than it should be, because you are doing out_vector = in_vector - (normal * 2) and instead you need to do out_vector = in_vector + (normal * (normal * in_vector) * 2) (Thanks to div0 for helping me to work this out)

Also, the spawn weapon feels far too strong, but that's somehting that can be sorted out by almost anyone :-)


Actually, the formula I'm using is result = olddir+(2*trace_plane_normal) NOT result = olddir-(normal*2).

I tried the formula you posted, however, all it did was cause the deathball to not rebound proper. (i.e. it just kept rebounding into the wall, instead of away from it)

If what you mean by spawn weapon is the Forte Scale Blaster, well... It does need a bit of tweaking I suppose. Right now, it operates under a formula of 4 to the power of self.health/25 / 10. Which is rather ugly and amateurish really, but gets the job done. =P
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby Lardarse » Mon May 22, 2006 8:51 pm

I might have my + and - the wrong way around...

But the basic idea is: instead of just using the normal, you need to scale the normal by the dotproduct of the entry vector and the normal. That way you can do nice shallow bounces that will nearly always hit the enemy exactly where you planned, instead of it sharply kicking away almost perpendicular.
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Sajt » Mon May 22, 2006 9:36 pm

The correct formula is
out = 2N(N dot I) - I
but in that case I (incident vector) points the other way. (away from the plane)


So the formula you want is
out = 2N(N dot I) + I
Where I is velocity, N is trace_plane_normal. I don't think I has to be normalized...


The 2 can be changed to modify bounciness: 1 is no bounce (just slides off surfaces), 1.5 is half bounce (probably similar to Quake grenade), 2 is full bounce, >2 is actually picking up speed with each bounce
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby Lardarse » Mon May 22, 2006 10:59 pm

Thank you. But I think a better way to determine how bouncy you want it, is to seperate the speed from the in vector, then scale the speed before combining it with the out vector.
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Dr. Shadowborg » Mon May 22, 2006 11:09 pm

Lardarse wrote:I might have my + and - the wrong way around...

But the basic idea is: instead of just using the normal, you need to scale the normal by the dotproduct of the entry vector and the normal. That way you can do nice shallow bounces that will nearly always hit the enemy exactly where you planned, instead of it sharply kicking away almost perpendicular.


Indeed, I'd figured that something like that might have happened, so I tried it just before reading your post here. :oops:

Silly me, I should have realized that was what happened immediatly, but I was kind of rushed, having to be somewhere at the time.

Anyway, it works good, so that'll be in the bugfixed version, which will come out sometime in the near future, barring anybody noticing any other bugs...
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby FrikaC » Tue May 23, 2006 3:03 am

I like the mod, but none of the weapons give that 'woah, math' feeling. I'll try to see if I can come up with an idea that does..
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Dr. Shadowborg » Tue May 23, 2006 2:57 pm

FrikaC wrote:I like the mod, but none of the weapons give that 'woah, math' feeling. I'll try to see if I can come up with an idea that does..


True enough. It's pretty hard to come up with something that does though.

In any event, it was pretty much intended as just a quickie example mod, you might say my half-assed attempt to try and help promote mathlib.qc so that it wouldn't get shoved aside and forgotten like it did when it first came out a couple of years ago.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

PreviousNext

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest