Author Topic: Making Q2 SP mod, code fails to compile  (Read 11009 times)

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1373
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #15 on: March 23, 2011, 11:00:26 PM »
Are you sure you copied all functions? Make sure the function exists in perforator.c:
Code: [Select]
void Weapon_Perforator (edict_t *ent)
{
static int pause_frames[] = {25, 33, 42, 50, 0};
static int fire_frames[] = {5, 0};

Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}

Clean and rebuild the project. Link error means the function is called but not defined. A prototype is not a definition.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #16 on: March 24, 2011, 07:45:05 AM »
Yes, the function is in perforator.c.

I`m not sure how I should rebuild it, though. If a prototype is not a definition, then which file should I look into to add the actual definition for Weapon_Perforator?

---

In the meantime, until I can move these functions properly into a completely new weapon, I`ve been toying around with the rocket launcher a bit. I managed to make it so it fires about as fast as a railgun, (1500 ms) faster projectile speed, (1000 ups) reduced damage / no splash, but I`m still trying to find out how to give it a lot of knockback. Does anyone know how weapons like the railgun get their knockback, and what code I should copy-paste to give these properties to the RL? (And eventually, the Perforator?) Also, how can I control the angular velocity of the knockback, so the monsters only get shoved backward instead of flying?

It has been a great learning experience I must admit. Thanks for all your support so far. :headbang:
« Last Edit: March 24, 2011, 12:07:57 PM by EmeraldTiger »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #17 on: March 24, 2011, 01:55:33 PM »
I also thought I`d post some other concepts I was going to do for my mod in addition to the Perforator, if anybody wants to contribute their code to make them work feel free. I`m not looking for modelers right now, I`ll just use placeholders of models made by id (from the original game and mission packs) and re-skin them and stuff.

Stinger Cannon
Similar to the one from the Gloom mod, but optimized for Single Player gameplay. Fires a barrage of missles (rapidfire like the HB, not one-shot) which have rough heatseeking abilities. By rough I mean they aren`t 100% accurate at finding their targets, they can drift off if the Strogg move enough. Very small splash damage area, does about the same damage as the HB per missle.

-----------------------------------

BrainHack
The BrainHack is a item that can be used to scramble a Strogg`s internal artificial intelligience so that it works for you instead of working against you. It won`t work on boss-type Strogg such as the Supertank or Hornet. Use this on a Tank and watch him blast his former Strogg comrades to smithereens! To use you must get within melee distance of the monster and then activate. It will not work otherwise, and until then it is kept in your inventory.

Conservation
Conservation is a power-up (like the Quad) that prevents you from using up ammo when firing weapons. This is especially useful when used in conjunction with a chaingun. Like the quad it expires after 30 sec. Creates a green glow around the carrier (power shield effect).

-----------------------------------

Beta-Class Enforcer
Has more health (175 as opposed to 100) than a normal Enforcer, as well as a power screen (similar to the Brain) which can withstand up to 150 damage. It also fires stinger missles out of it`s nozzle. (chaingun arm)

Beta-Class Gunner
Has more health (300 as opposed to 175) than a normal Gunner, but in addition is able to fire perforator spears (where the grenade launcher was), which if they hit will give you a nice, big push. (how to define knockback?) Their machinegun also does slightly more damage.

Beta-Class Parasite
Has more health (240 as opposed to 175) than a normal Parasite. It still possesses the same laser attack that it had before but it now extends much farther. (maybe 1024 units?) Also when it attacks whatever health you lose from it`s onslaught it will gain, so if you lose 50 health it will gain that 50 health as it is attacking, so you better take it out fast! Of course, to not make it too powerful let`s set a cap of say, 750 health.

Lobber Guard
Just your typical guard, but fitted with a grenade launcher as a prosthetic. 60 health.

I might not be able to do all of this immediately but hopefully some of these concepts can become a reality. I know, it`s a game over a decade old - still kicks butt though. :yessign:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1373
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #18 on: March 24, 2011, 04:02:41 PM »
Yes, the function is in perforator.c.

I`m not sure how I should rebuild it, though. If a prototype is not a definition, then which file should I look into to add the actual definition for Weapon_Perforator?


It has been a great learning experience I must admit. Thanks for all your support so far. :headbang:

Happy to have been some help. :) Enjoy.

Code: [Select]
void Weapon_Perforator (edict_t *ent);
This is a function prototype. It informs the compiler about the types of arguments and return value the function uses. This allows the compiler to properly frame the code generated by other functions that call this function even though the compiler has not yet encountered the actual definition of the function. Proper prototyping allows the compiler to emit diagnostics if the function is called incorrectly. This function receives a pointer to edict_t and returns nothing.

Code: [Select]
void Weapon_Perforator (edict_t *ent)
{
static int pause_frames[] = {25, 33, 42, 50, 0};
static int fire_frames[] = {5, 0};

Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}
This is the function definition. It defines any automatic variables and the operations the function performs, the braces enclose the function body. This function receives a pointer to edict_t and initializes two arrays with some values and then calls Weapon_Generic passing a pointer to ent, some "magic numbers", pointers to the local arrays and a pointer to the function Weapon_Perforator_Fire.

If the prototype and definition are both in the project sources and both files were added to the project (you did remember to add them, right?), then the linker should not fail. Do a Build | Rebuild Solution (ctrl-alt-F7) to make sure you have all the modules built. My guess is you forgot to add the new perforator files to the project and didn't quite delete all the old stuff in p_weapon.c.

« Last Edit: March 24, 2011, 04:05:07 PM by QwazyWabbit »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #19 on: March 24, 2011, 07:40:10 PM »
Yes, the prototype and definition are in perforator.h: (yes I made the perforator files, like you mentioned earlier)

Code: [Select]
/*
*
*  perforator.h

*
*/

//#include "g_local.h"

#ifndef PERFORATOR_H
#define PERFORATOR_H

void Weapon_Perforator_Fire (edict_t *ent);
void Weapon_Perforator (edict_t *ent);
void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick);

#endif

---

Also, here is my perforator.c file:

Code: [Select]
/*
*
*  perforator.c
*
*/

#include "perforator.h"

/*
======================================================================

PERFORATOR

======================================================================
*/

void Weapon_Perforator_Fire (edict_t *ent)
{
vec3_t offset, start;
vec3_t forward, right;
int damage;
int kick;

damage = 50;
kick = 400;
if (is_quad)
{
damage *= 4;
}

AngleVectors (ent->client->v_angle, forward, right, NULL);

VectorScale (forward, -2, ent->client->kick_origin);
ent->client->kick_angles[0] = -1;

VectorSet(offset, 8, 8, ent->viewheight-8);
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
fire_perforator (ent, start, forward, damage, 650, kick);

// send muzzle flash
gi.WriteByte (svc_muzzleflash);
gi.WriteShort (ent-g_edicts);
gi.WriteByte (MZ_RAILGUN | is_silenced);
gi.multicast (ent->s.origin, MULTICAST_PVS);

ent->client->ps.gunframe++;

PlayerNoise(ent, start, PNOISE_WEAPON);

if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
ent->client->pers.inventory[ent->client->ammo_index]--;
}

void Weapon_Perforator (edict_t *ent)
{
static int pause_frames[] = {25, 33, 42, 50, 0};
static int fire_frames[] = {5, 0};

Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}

/*
=================
perforator_touch
=================
*/

void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
vec3_t origin;
int n;

if (other == ent->owner)
return;

if (surf && (surf->flags & SURF_SKY))
{
G_FreeEdict (ent);
return;
}

if (ent->owner->client)
PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);

// calculate position for the explosion entity
VectorMA (ent->s.origin, -0.02, ent->velocity, origin);

if (other->takedamage)
{
T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_PERFORATOR);
}
else
{
// don't throw any debris in net games
if (!deathmatch->value && !coop->value)
{
if ((surf) && !(surf->flags & (SURF_WARP|SURF_TRANS33|SURF_TRANS66|SURF_FLOWING)))
{
n = rand() % 5;
while(n--)
ThrowDebris (ent, "models/objects/debris2/tris.md2", 2, ent->s.origin);
}
}
}

T_RadiusDamage(ent, ent->owner, ent->radius_dmg, other, ent->dmg_radius, MOD_PERFORATOR);

gi.WriteByte (svc_temp_entity);
if (ent->waterlevel)
gi.WriteByte (TE_PERFORATOR_EXPLOSION_WATER);
else
gi.WriteByte (TE_PERFORATOR_EXPLOSION);
gi.WritePosition (origin);
gi.multicast (ent->s.origin, MULTICAST_PHS);

G_FreeEdict (ent);
}

/*
=================
fire_perforator
=================
*/

void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick)
{
edict_t *perforator;

perforator = G_Spawn();
VectorCopy (start, perforator->s.origin);
VectorCopy (dir, perforator->movedir);
vectoangles (dir, perforator->s.angles);
VectorScale (dir, speed, perforator->velocity);
perforator->movetype = MOVETYPE_FLYMISSILE;
perforator->clipmask = MASK_SHOT;
perforator->solid = SOLID_BBOX;
perforator->s.effects |= EF_ROCKET;
VectorClear (perforator->mins);
VectorClear (perforator->maxs);
perforator->s.modelindex = gi.modelindex ("models/objects/rocket/tris.md2");
perforator->owner = self;
perforator->touch = perforator_touch;
perforator->nextthink = level.time + 8000/speed;
perforator->think = G_FreeEdict;
perforator->dmg = damage;
perforator->s.sound = gi.soundindex ("weapons/rockfly.wav");
perforator->classname = "perforator";

if (self->client)
check_dodge (self, perforator->s.origin, dir, speed);

gi.linkentity (perforator);
}

Slightly unrelated note: I managed to add two new key entities to the game, one of them being a yellow key. The yellow key uses the model from the red / blue keys but a new skin. It`s located in models/items/keys/yellow_key. Like all other skins it uses the name "skin.pcx". It also has a tris.md2 in the same folder, like the other keys (copied it from the red / blue key) However, despite the fact that I "followed all the rules" when I go to drop the key through console it shows up as a plain red skinned key. Why? Here is the code for my new key btw: (the code works properly, it`s just the skin not showing up)

Code: [Select]
/*QUAKED key_yellow_key (0 .5 .8) (-16 -16 -16) (16 16 16)
normal door key - yellow
*/
{
"key_yellow_key",
Pickup_Key,
NULL,
Drop_General,
NULL,
"items/pkup.wav",
"models/items/keys/yellow_key/tris.md2", EF_ROTATE,
NULL,
"k_yellowkey",
"Yellow Key",
2,
0,
NULL,
IT_STAY_COOP|IT_KEY,
0,
NULL,
0,
/* precache */ ""
},

The other new key I made was a set of explosive charges. This time I took a model from the Rogue mission pack, the tag token. They accidentally named their skin "skin1.pcx" instead of "skin.pcx" for some reasons, so for compatibility I renamed it without the 1. I put it in models/items/keys/charges/ and have both tris.md2 and the skin.pcx in there, but once again it just drops a red-skinned key (though it still says explosive charges when I pick it up, so the code works) when I type "drop explosive charges". Here`s the code again:

Code: [Select]
/*QUAKED key_explosive_charges (0 .5 .8) (-16 -16 -16) (16 16 16)
explosive charges
*/
{
"key_explosive_charges",
Pickup_Key,
NULL,
Drop_General,
NULL,
"items/pkup.wav",
"models/items/keys/charges/tris.md2", EF_ROTATE,
NULL,
"k_charges",
"Explosive Charges",
2,
0,
NULL,
IT_STAY_COOP|IT_KEY,
0,
NULL,
0,
/* precache */ ""
},

Thanks in advance.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline [BTF]Sigma

  • Phenomenally Prodigious Member
  • **
  • Posts: 3059
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #20 on: March 24, 2011, 08:03:41 PM »
It blows my mind!!!!

I love looking at the guts of a program. Maybe I should go learn me some code.

:bomb:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1373
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #21 on: March 24, 2011, 09:59:51 PM »
Yes, the prototype and definition are in perforator.h: (yes I made the perforator files, like you mentioned earlier)

Code: [Select]
/*
*
*  perforator.h
* 
*
*/

//#include "g_local.h"

#ifndef PERFORATOR_H
#define PERFORATOR_H

void Weapon_Perforator_Fire (edict_t *ent);
void Weapon_Perforator (edict_t *ent);
void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick);

#endif

---

Delete the line in red:
/*
*
*  perforator.h
* 
*
*/

//#include "g_local.h"

#ifndef PERFORATOR_H
#define PERFORATOR_H
Quote

Also, here is my perforator.c file:


Change peforator.c to read:
/*
*
*  perforator.c
*
*/

#include "g_local.h"
#include "perforator.h"

I copy-pasted this the other night and didn't take time to correct it before posting.

Quote

Code: [Select]
/*
*
*  perforator.c
*
*/

#include "perforator.h"

/*
======================================================================

PERFORATOR

======================================================================
*/

void Weapon_Perforator_Fire (edict_t *ent)
{
vec3_t offset, start;
vec3_t forward, right;
int damage;
int kick;

damage = 50;
kick = 400;
if (is_quad)
{
damage *= 4;
}

AngleVectors (ent->client->v_angle, forward, right, NULL);

VectorScale (forward, -2, ent->client->kick_origin);
ent->client->kick_angles[0] = -1;

VectorSet(offset, 8, 8, ent->viewheight-8);
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
fire_perforator (ent, start, forward, damage, 650, kick);

// send muzzle flash
gi.WriteByte (svc_muzzleflash);
gi.WriteShort (ent-g_edicts);
gi.WriteByte (MZ_RAILGUN | is_silenced);
gi.multicast (ent->s.origin, MULTICAST_PVS);

ent->client->ps.gunframe++;

PlayerNoise(ent, start, PNOISE_WEAPON);

if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
ent->client->pers.inventory[ent->client->ammo_index]--;
}

void Weapon_Perforator (edict_t *ent)
{
static int pause_frames[] = {25, 33, 42, 50, 0};
static int fire_frames[] = {5, 0};

Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}

/*
=================
perforator_touch
=================
*/

void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
vec3_t origin;
int n;

if (other == ent->owner)
return;

if (surf && (surf->flags & SURF_SKY))
{
G_FreeEdict (ent);
return;
}

if (ent->owner->client)
PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);

// calculate position for the explosion entity
VectorMA (ent->s.origin, -0.02, ent->velocity, origin);

if (other->takedamage)
{
T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_PERFORATOR);
}
else
{
// don't throw any debris in net games
if (!deathmatch->value && !coop->value)
{
if ((surf) && !(surf->flags & (SURF_WARP|SURF_TRANS33|SURF_TRANS66|SURF_FLOWING)))
{
n = rand() % 5;
while(n--)
ThrowDebris (ent, "models/objects/debris2/tris.md2", 2, ent->s.origin);
}
}
}

T_RadiusDamage(ent, ent->owner, ent->radius_dmg, other, ent->dmg_radius, MOD_PERFORATOR);

gi.WriteByte (svc_temp_entity);
if (ent->waterlevel)
gi.WriteByte (TE_PERFORATOR_EXPLOSION_WATER);
else
gi.WriteByte (TE_PERFORATOR_EXPLOSION);
gi.WritePosition (origin);
gi.multicast (ent->s.origin, MULTICAST_PHS);

G_FreeEdict (ent);
}

/*
=================
fire_perforator
=================
*/

void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick)
{
edict_t *perforator;

perforator = G_Spawn();
VectorCopy (start, perforator->s.origin);
VectorCopy (dir, perforator->movedir);
vectoangles (dir, perforator->s.angles);
VectorScale (dir, speed, perforator->velocity);
perforator->movetype = MOVETYPE_FLYMISSILE;
perforator->clipmask = MASK_SHOT;
perforator->solid = SOLID_BBOX;
perforator->s.effects |= EF_ROCKET;
VectorClear (perforator->mins);
VectorClear (perforator->maxs);
perforator->s.modelindex = gi.modelindex ("models/objects/rocket/tris.md2");
perforator->owner = self;
perforator->touch = perforator_touch;
perforator->nextthink = level.time + 8000/speed;
perforator->think = G_FreeEdict;
perforator->dmg = damage;
perforator->s.sound = gi.soundindex ("weapons/rockfly.wav");
perforator->classname = "perforator";

if (self->client)
check_dodge (self, perforator->s.origin, dir, speed);

gi.linkentity (perforator);
}

Slightly unrelated note: I managed to add two new key entities to the game, one of them being a yellow key. The yellow key uses the model from the red / blue keys but a new skin. It`s located in models/items/keys/yellow_key. Like all other skins it uses the name "skin.pcx". It also has a tris.md2 in the same folder, like the other keys (copied it from the red / blue key) However, despite the fact that I "followed all the rules" when I go to drop the key through console it shows up as a plain red skinned key. Why? Here is the code for my new key btw: (the code works properly, it`s just the skin not showing up)

Code: [Select]
/*QUAKED key_yellow_key (0 .5 .8) (-16 -16 -16) (16 16 16)
normal door key - yellow
*/
{
"key_yellow_key",
Pickup_Key,
NULL,
Drop_General,
NULL,
"items/pkup.wav",
"models/items/keys/yellow_key/tris.md2", EF_ROTATE,
NULL,
"k_yellowkey",
"Yellow Key",
2,
0,
NULL,
IT_STAY_COOP|IT_KEY,
0,
NULL,
0,
/* precache */ ""
},

The other new key I made was a set of explosive charges. This time I took a model from the Rogue mission pack, the tag token. They accidentally named their skin "skin1.pcx" instead of "skin.pcx" for some reasons, so for compatibility I renamed it without the 1. I put it in models/items/keys/charges/ and have both tris.md2 and the skin.pcx in there, but once again it just drops a red-skinned key (though it still says explosive charges when I pick it up, so the code works) when I type "drop explosive charges". Here`s the code again:

Code: [Select]
/*QUAKED key_explosive_charges (0 .5 .8) (-16 -16 -16) (16 16 16)
explosive charges
*/
{
"key_explosive_charges",
Pickup_Key,
NULL,
Drop_General,
NULL,
"items/pkup.wav",
"models/items/keys/charges/tris.md2", EF_ROTATE,
NULL,
"k_charges",
"Explosive Charges",
2,
0,
NULL,
IT_STAY_COOP|IT_KEY,
0,
NULL,
0,
/* precache */ ""
},

Thanks in advance.

Too many other issues to deal with right now. Maybe someone else can offer some advice on this. I am traveling home tomorrow and am not in a position to try to emulate what you are doing wrong on this issue.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #22 on: March 24, 2011, 11:22:15 PM »
Okay, thank you for the code.

I found out how to find references for a line of code in Visual Studio, so I decided to go into g_items.c and highlight the weapon function. It is the line of code giving me trouble. (highlighted)

/*QUAKED weapon_perforator (.3 .3 1) (-16 -16 -16) (16 16 16)
*/
   {
      "weapon_perforator",
      Pickup_Weapon,
      Use_Weapon,
      Drop_Weapon,
      Weapon_Perforator,      
                                "misc/w_pkup.wav",
      "models/weapons/g_rail/tris.md2", EF_ROTATE,
      "models/weapons/v_rail/tris.md2",
/* icon */      "w_railgun",
/* pickup */   "Perforator",
      5,
      5,
      "Slugs",
      IT_WEAPON|IT_STAY_COOP,
      WEAP_PERFORATOR,
      NULL,
      0,
/* precache */ "weapons/rg_hum.wav"
   },

Apparently Weapon_Perforator only brings up one reference in g_items.c, where the prototype is defined (void Weapon_Perforator (edict_t *ent); but brings up no other references. I was expecting it to make a reference to perforator.c, as I did include this section of code with the function Weapon_Perforator in it:

void Weapon_Perforator (edict_t *ent)
{
   static int   pause_frames[]   = {25, 33, 42, 50, 0};
   static int   fire_frames[]   = {5, 0};
   
   Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}

I`m not sure what`s going on. How come even though the function is clearly referred to in perforator.c, as shown above, it refuses to compile until I change it to an default id function like Weapon_RocketLauncher. Seems like my compiler hates me... :p
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline quadz

  • Loquaciously Multiloquent Member
  • ****
  • Posts: 5352
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #23 on: March 24, 2011, 11:50:13 PM »
How come even though the function is clearly referred to in perforator.c, as shown above, it refuses to compile

Did you add perforator.c to the Visual Studio project?

(I.e. right click in the solution/project pane and choose Add...Existing Item...)


:exqueezeme:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
"He knew all the tricks, dramatic irony, metaphor, bathos, puns, parody, litotes and... satire. He was vicious."

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #24 on: March 25, 2011, 06:12:52 AM »
Ahh... I didn`t try that yet.

So I went and added them to my project, but when I did it gave me a laundry list of errors. Apparently there`s something wrong with how I set up the code so far in perforator.c / perforator.h, but I`m not sure what it is. Here it is again, maybe someone knows where I have went wrong?

Code: [Select]
/*
*
*  perforator.h

*
*/

#ifndef PERFORATOR_H
#define PERFORATOR_H

void Weapon_Perforator_Fire (edict_t *ent);
void Weapon_Perforator (edict_t *ent);
void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick);

#endif

Code: [Select]
/*
*
*  perforator.c
*
*/

#include "g_items.c"
#include "g_local.h"
#include "perforator.h"

/*
======================================================================

PERFORATOR

======================================================================
*/

void Weapon_Perforator_Fire (edict_t *ent)
{
vec3_t offset, start;
vec3_t forward, right;
int damage;
int kick;

damage = 50;
kick = 400;
if (is_quad)
{
damage *= 4;
}

AngleVectors (ent->client->v_angle, forward, right, NULL);

VectorScale (forward, -2, ent->client->kick_origin);
ent->client->kick_angles[0] = -1;

VectorSet(offset, 8, 8, ent->viewheight-8);
P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
fire_perforator (ent, start, forward, damage, 650, kick);

// send muzzle flash
gi.WriteByte (svc_muzzleflash);
gi.WriteShort (ent-g_edicts);
gi.WriteByte (MZ_RAILGUN | is_silenced);
gi.multicast (ent->s.origin, MULTICAST_PVS);

ent->client->ps.gunframe++;

PlayerNoise(ent, start, PNOISE_WEAPON);

if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
ent->client->pers.inventory[ent->client->ammo_index]--;
}

void Weapon_Perforator (edict_t *ent)
{
static int pause_frames[] = {25, 33, 42, 50, 0};
static int fire_frames[] = {5, 0};

Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_Perforator_Fire);
}

/*
=================
perforator_touch
=================
*/

void perforator_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
vec3_t origin;
int n;

if (other == ent->owner)
return;

if (surf && (surf->flags & SURF_SKY))
{
G_FreeEdict (ent);
return;
}

if (ent->owner->client)
PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);

// calculate position for the explosion entity
VectorMA (ent->s.origin, -0.02, ent->velocity, origin);

if (other->takedamage)
{
T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_PERFORATOR);
}
else
{
// don't throw any debris in net games
if (!deathmatch->value && !coop->value)
{
if ((surf) && !(surf->flags & (SURF_WARP|SURF_TRANS33|SURF_TRANS66|SURF_FLOWING)))
{
n = rand() % 5;
while(n--)
ThrowDebris (ent, "models/objects/debris2/tris.md2", 2, ent->s.origin);
}
}
}

T_RadiusDamage(ent, ent->owner, ent->radius_dmg, other, ent->dmg_radius, MOD_PERFORATOR);

gi.WriteByte (svc_temp_entity);
if (ent->waterlevel)
gi.WriteByte (TE_PERFORATOR_EXPLOSION_WATER);
else
gi.WriteByte (TE_PERFORATOR_EXPLOSION);
gi.WritePosition (origin);
gi.multicast (ent->s.origin, MULTICAST_PHS);

G_FreeEdict (ent);
}

/*
=================
fire_perforator
=================
*/

void fire_perforator (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int kick)
{
edict_t *perforator;

perforator = G_Spawn();
VectorCopy (start, perforator->s.origin);
VectorCopy (dir, perforator->movedir);
vectoangles (dir, perforator->s.angles);
VectorScale (dir, speed, perforator->velocity);
perforator->movetype = MOVETYPE_FLYMISSILE;
perforator->clipmask = MASK_SHOT;
perforator->solid = SOLID_BBOX;
perforator->s.effects |= EF_ROCKET;
VectorClear (perforator->mins);
VectorClear (perforator->maxs);
perforator->s.modelindex = gi.modelindex ("models/objects/rocket/tris.md2");
perforator->owner = self;
perforator->touch = perforator_touch;
perforator->nextthink = level.time + 8000/speed;
perforator->think = G_FreeEdict;
perforator->dmg = damage;
perforator->s.sound = gi.soundindex ("weapons/rockfly.wav");
perforator->classname = "perforator";

if (self->client)
check_dodge (self, perforator->s.origin, dir, speed);

gi.linkentity (perforator);
}
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline quadz

  • Loquaciously Multiloquent Member
  • ****
  • Posts: 5352
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #25 on: March 25, 2011, 06:59:09 AM »
Here it is again, maybe someone knows where I have went wrong?

Show the compiler errors, please.


 :exqueezeme:

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
"He knew all the tricks, dramatic irony, metaphor, bathos, puns, parody, litotes and... satire. He was vicious."

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1373
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #26 on: March 25, 2011, 07:41:20 AM »
You can't include g_items.c in perforator.c. Remove that line.

fire_perforator calls check_dodge() and it's in g_weapon.c. You need to add a prototype for it in g_locals.h, find the lines that look like this and add it there:


//
// g_weapon.c
//
void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin);
qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick);
void fire_bullet (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int mod);
void fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod);
void fire_blaster (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int effect, qboolean hyper);
void fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius);
void fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held);
void fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius, int radius_damage);
void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick);
void fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius);
void check_dodge (edict_t *self, vec3_t start, vec3_t dir, int speed);


Recompile and post the errors/warnings you get.

We're correcting some bad practices that existed in the legacy code. This prototype shuffling is part of that. You are likely to get more errors/warnings while we straighten it out. Don't panic.

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline EmeraldTiger

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #27 on: March 25, 2011, 07:58:16 AM »
Added, here is my new error list (for evidence finding):

Code: [Select]
1>------ Build started: Project: game, Configuration: Release Win32 ------
1>Compiling...
1>perforator.c
1>.\perforator.c(38) : warning C4013: 'P_ProjectSource' undefined; assuming extern returning int
1>.\perforator.c(60) : warning C4013: 'Weapon_Generic' undefined; assuming extern returning int
1>.\perforator.c(116) : warning C4100: 'kick' : unreferenced formal parameter
1>Linking...
1>   Creating library .\..\release/gamex86.lib and object .\..\release/gamex86.exp
1>perforator.obj : error LNK2019: unresolved external symbol _check_dodge referenced in function _fire_perforator
1>perforator.obj : error LNK2019: unresolved external symbol _P_ProjectSource referenced in function _Weapon_Perforator_Fire
1>..\release\gamex86.dll : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://f:\Quake 2 Folder\Source Code\quake2-3.21\game\intermediates\BuildLog.htm"
1>game - 3 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #28 on: March 25, 2011, 11:40:49 AM »
Maybe you need to include the header file containing the function prototype of _check_dodge in perforator.c

function prototype
function definition
function call

then in C++ the compiler doesn't need the prototypes, is how I remember this

not sure if this helps : ).
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline QwazyWabbit

  • Carpal Tunnel Member
  • ******
  • Posts: 1373
    • View Profile
  • Rated:
Re: Making Q2 SP mod, code fails to compile
« Reply #29 on: March 25, 2011, 03:27:08 PM »
More missing prototypes in in g_local.h, legacy stuff when dealing with old code like this.

Near line 1170 or so, (this will vary), in g_local.h add the following lines:

//
// p_weapon.c
//
void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result);
void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, int *fire_frames, void (*fire)(edict_t *ent));

^-------- this is all one line, web forum is wrapping it.

In g_weapon.c, change this line:

static void check_dodge (edict_t *self, vec3_t start, vec3_t dir, int speed)

to this:

void check_dodge (edict_t *self, vec3_t start, vec3_t dir, int speed)


In p_weapon.c be sure to make the same change:

static void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)

to

void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)

This will make them available for linking from other source modules.

When you have done all this, you should have only 1 warning left but it will compile and link.

« Last Edit: March 25, 2011, 03:30:02 PM by QwazyWabbit »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

 

El Box de Shoutamente

Last 10 Shouts:

Costigan_Q2

November 11, 2024, 06:41:06 AM
"Stay cozy folks.

Everything is gonna be fine."

There'll be no excuses for having TDS after January 20th, there'll be no excuses AT ALL!!!
 

|iR|Focalor

November 06, 2024, 03:28:50 AM
 

RailWolf

November 05, 2024, 03:13:44 PM
Nice :)

Tom Servo

November 04, 2024, 05:05:24 PM
The Joe Rogan Experience episode 223 that dropped a couple hours ago with Musk, they're talking about Quake lol.

Costigan_Q2

November 04, 2024, 03:37:55 PM
Stay cozy folks.

Everything is gonna be fine.
 

|iR|Focalor

October 31, 2024, 08:56:37 PM

Costigan_Q2

October 17, 2024, 06:31:53 PM
Not activated your account yet?

Activate it now! join in the fun!

Tom Servo

October 11, 2024, 03:35:36 PM
HAHAHAHAHAHA
 

|iR|Focalor

October 10, 2024, 12:19:41 PM
I don't worship the devil. Jesus is Lord, friend. He died for your sins. He will forgive you if you just ask.
 

rikwad

October 09, 2024, 07:57:21 PM
Sorry, I couldn't resist my inner asshole.

Show 50 latest
Welcome, Guest. Please login or register.
November 22, 2024, 04:52:30 PM

Login with username, password and session length