MediKits Conversion

 

 

philip
profile | email

posted 09-03-98 8:51 PM CT (US)
Title: MediKits Conversion
Difficulty: Easy to Moderate
By: Philip (aka Maj.Bitch)
Email: peblair@gv.net // please report any bugs(??)
Date: 8-31-98
Note: Please give credit where credit is due.

=============================================================
This is a modification of the 'Exploding Health Boxes' tutorial
originally posted on QDevels by: Mark "Grey" Davies. Many thanks
to him for his originality and inspiration.

GREAT for getting even with 'health greedy' players.

About:
In this modification, the healh kits are converted to other medic
kits (of higher value) when a player who is already at or above
100 health units attempts to 'pickup' more health by running over
health kits. In this instance, the 10 unit health kits explode
into 10 (2 unit stimpaks) which bounce and scatter about in
random directions. These can then be picked up by other players but
the player who was greedy can't pick these up!! The 25 unit kits
are converted to a 100 unit mega health which bounces around in
a random direction before settling down. Again, other players can
pick up the new health but the initiating player cannot!! That'll
teach those health greedy bastards!!

=============================================================
================= G_ITEMS.C MODIFICATINS ====================
=============================================================

Insert the following code at the very top of Pickup_Health()

// if health > max then explode into Mega or Stimpaks
if (!(ent->style & HEALTH_IGNORE_MAX))
if (other->health >= other->max_health) {
spawn_health_paks(ent,other); // spawn stimpaks
if (!(ent->spawnflags & DROPPED_ITEM))
SetRepawn(ent, 20); /* respawn quicker than normal */
return true; }

=================

At a point above the Pickup_Health() function add the following
new function.

void spawn_health_paks(edict_t *ent, edict_t *other) {
trace_t tr;
gitem_t *item=NULL;
edict_t *dropped=NULL;
vec3_t offset={0,0,0};
int i,k,speed=10;
vec3_t spray[] = { { 25, 00, 40 },
{ 17, -17, 40 },
{ 00, -25, 40 },
{ -17, -17, 40 },
{ -25, 00, 40 },
{ -17, 17, 40 },
{ 00, 25, 40 },
{ 17, 17, 40 },};
vec3_t forward = { 5.0, 5.0, 5.0 };
vec3_t right = { 5.0, 5.0, 5.0 };
vec3_t up = { 5.0, 5.0, 5.0 };
vec3_t dir = { 0.0, 0.0, 0.0 };

if (ent->count == 10)
k=10; // explode small health box into 10 stimpaks
else
k=1; // explode large health box into 1 Mega Health

for(i=1; i <= k; i++) {
VectorSet(offset, spray[i-1][0], spray[i-1][1], spray[i-1][2]);
offset[0] += ((crandom()*16.0) - 8.0);
offset[1] += ((crandom()*16.0) - 8.0);
offset[2] += ((crandom()*16.0) - 8.0);
vectoangles(offset, dir);
AngleVectors(dir, forward, right, up);
speed += (crandom()*10.0);

// Spawn the Item..
dropped = G_Spawn();
dropped->owner = other;

// Set Vector Positioning Info.
VectorSet(dropped->mins, -15, -15, -15);
VectorSet(dropped->maxs, 15, 15, 15);
G_ProjectSource(ent->s.origin, offset, forward, right, dropped->s.origin);
tr = gi.trace(ent->s.origin, dropped->mins, dropped->maxs, dropped->s.origin, ent,
CONTENTS_SOLID);
VectorCopy(tr.endpos, dropped->s.origin);
VectorScale(offset, speed, dropped->velocity);
dropped->velocity[2] = 300; // same as grenade bounce velocity.

if (ent->count==10) {
dropped->count = 2; // 2 = Stimpak Health Increase
dropped->style = HEALTH_IGNORE_MAX;
dropped->model = "models/items/healing/stimpack/tris.md2";
} // if
else {
dropped->count = 100; // 100 = Mega Health Increase
dropped->style = HEALTH_IGNORE_MAX|HEALTH_TIMED;
dropped->model = "models/items/mega_h/tris.md2";
} // else

gi.setmodel(dropped, dropped->model); // set the model
gi.soundindex("items/s_health.wav"); // make stimpak popping sound

// set Item list info..
item = FindItem("Health");
dropped->classname = item->classname;
dropped->item = item;

// Special Characteristic Flags..
dropped->spawnflags = DROPPED_ITEM;
dropped->solid = SOLID_TRIGGER;
dropped->movetype = MOVETYPE_BOUNCE;
dropped->s.renderfx = RF_GLOW;
dropped->s.effects = item->world_model_flags;
dropped->s.effects |= EF_COLOR_SHELL;

// Set think & touch functions..
dropped->touch = drop_temp_touch;
dropped->think = G_FreeEdict;
dropped->nextthink = level.time + 30.0; // 30 sec timer

gi.linkentity(dropped);
} // for
}

=============================================================

That's all. Very Simple but GREAT mod! Try it!!

regards,
Philip
aka Maj.Bitch

JACKofAll

Trades
profile | email

posted 09-03-98 9:03 PM CT (US)
Looks cool, but where is the drop_temp_touch() function? Or do I also need the original Qdevels tutorial?

philip
profile | email

posted 09-03-98 9:19 PM CT (US)
Jack, that function is standard issue Q2. Do a Grep drop_temp_touch on all your *.c files to find out where it's located. Let me know if you've not found it (by email). thanks..

cr0tan
profile | email

posted 09-06-98 10:08 AM CT (US)
I agree with u all but he forgets to tell u to prototype the to funtions at the top of the file. So here's what you do. just put these two lines in.

static void drop_temp_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);

and:

static void drop_make_touchable (edict_t *ent);

Well ther u go.

cr0tan

philip
profile | email

posted 09-06-98 10:28 AM CT (US)
Yep, forgot that. Oops!!

Again, it is hoped that people will know enough about coding to work their own way through any minor stuff which arises during implementation (such as the absence of forward declarations).

These tutorials are not for lamers...

regards,
philip