Hobby Mod in progress: Request for help in using Energy


(Mierk) #1

Hi there. I have been working on a small mod that will primarily be used for a small group of friend. I don’t really have aspirations to make a very elaborate mod, but I would like to implement some things that seem to be beyond my knowledge at the moment.

Here is a small list of what I have in place now:

[ul]
[li]Medic: Self-healing gives 25% of the value of a health pack (I HATE self-healing rambo medics)
[/li][li]Panzer: Splash radius and damage reduced
[/li][li]Head Shots will now display a message to the target and the attacker (as well as play an indicator sound for each - I just have to find the right sound :slight_smile: )
[/li][li]Grenade carrying capacity was changed for a few classes
[/li][li]Light Weapons Soldier: Cluster Grenades
[/li][/ul]
It is with this last point that I am having an issue with. As it is now, I have alterred the fire_grenade() function to check to see whether or not the player is a soldier, and whether or not his primary weapon is a THOMPSON or MP40. If so, I set bolt->classname = “cgrenade”… which I then look for in MissileImpact and ExplodeMissile (I think those are the names of the functions… I’m not at my dev workstation right now) What I would like to do is also check to see if the soldier has enough “Energy” to throw it, and if he does, throw the grenade and consume 100% of his energy.

I’ve looked at other functions that consume energy and can’t quite wrap my head around it. If someone could shed a light on how this is done, I would appreciate it greatly. If anyone is interested in play-testing this little mod, please contact me @ mierk@ratjam.com

Thanks!

-Mierk


(Svartberg.) #2

Good luck with your mod, you have some good ideas.

There should be a spawn function which assigns everyone with their weapons, there should be losta cases there, look for the pc_soldier condition and the smg condition (case MP40 : or something) and add an add_weapon() function to the case (wp_mp40) there or something.
As for the energy thing, look for the current energy takers, like the panzerfaust, or airstrike, and copy paste those lines.


(Pamper) #3

Easy. Just wrap this around your special grenade-thrower (after you’ve allready checked that he’s a soldier)

  if( level.time - ent->client->ps.classWeaponTime > level.soldierChargeTime[ent->client->sess.sessionTeam-1] ) {
   ent->client->ps.classWeaponTime = level.time - level.soldierChargeTime[ent->client->sess.sessionTeam-1];

Note that level.soldierChargeTime[ent->client->sess.sessionTeam-1] refers to a server-set option for how much energy soliders need to fire a PF. That’s equal to 20000 by default, so you could just use that number instead.


(Mierk) #4

Thanks for your help and encouragement.

I was able to pick that code out of the PF routines and get it to work for the clusters. The issue that has me stalled now is that instead of simply “not firing” the grenade when the button is pressed, it now… doesn’t throw the grenade but does start the grenade ticking and decrement your inventory. Does anyone know how i would trap that?

Thanks!