Thanks.Actually there were two issues. R1ch pointed out that the 'owner' can't shoot its own items. But there was a further issue, that some number of frames after the trap lands, its Think routine would clear its mins,maxs size.After working around those issues, I can now damage the trap... however, when the mins,maxs aren't cleared, one can't quite reach the trap to where it thinks it has sucked the player in.That's where it currently stands... I'll either try messing with its clip flags so the player doesn't clip against it (if possible), or I guess i'll fudge it and add an epsilon to its kill distance...But anyway... been fun so far... quadz
/*=================X-Buster=================*/void xbuster_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf){ if (other == self->owner) return; if (self->owner->client) PlayerNoise(self->owner, self->s.origin, PNOISE_IMPACT); if (other->takedamage) { T_Damage (other, self, self->owner, self->velocity, self->s.origin, plane->normal, self->dmg, 1, DAMAGE_ENERGY, MOD_BUSTER); } else { gi.WriteByte (svc_temp_entity); gi.WriteByte (TE_BLASTER); gi.WritePosition (self->s.origin); if (!plane) gi.WriteDir (vec3_origin); else gi.WriteDir (plane->normal); gi.multicast (self->s.origin, MULTICAST_PVS); } //if count was true if (self->radius_dmg == 1) G_FreeEdict(self); //simply destroy ent else remove_shot(self); //decrement shot and remove object}void cblaster_pass (edict_t *ent){ vec3_t v; VectorCopy(ent->cutterangle, v); VectorNormalize(v); //restore original velocity vectoangles(v, ent->s.angles); VectorCopy(v, ent->movedir); VectorScale(v, 700, ent->velocity); //if count was true if (ent->radius_dmg == 1) ent->think = G_FreeEdict; //simply destroy ent else ent->think = remove_shot; ent->nextthink = level.time + 1;}void cblaster_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf){ vec3_t origin; int n; int rdam, damr; rdam = 45; damr = 45; if (other == ent->owner) return; if (other->takedamage) { int newdmg; newdmg = ent->dmg - other->health; //calculate new damage by subtracting other health from damage T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_BUSTER); ent->dmg = newdmg; //we did the damage so change the damage for next touch if (ent->dmg > 0) //if there still is any dmg left then don't destroy bolt { ent->think = cblaster_pass; ent->nextthink = level.time + 0.01; //return so it doesnt get destroyed 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);// T_RadiusDamage(ent, ent->owner, rdam, other, damr, MOD_BLASTER); gi.WriteByte (svc_temp_entity); gi.WriteByte (TE_TELEPORT_EFFECT); gi.WritePosition (origin); gi.multicast (ent->s.origin, MULTICAST_PHS); if (ent->radius_dmg == 1) G_FreeEdict(ent); //simply destroy ent else remove_shot(ent); //decrement shot and remove object}void sblaster_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf){ vec3_t origin; int n; int rdam, damr; rdam = 80; damr = 100; if (other == ent->owner) return; if (other->takedamage) { int newdmg; newdmg = ent->dmg - other->health; //calculate new damage by subtracting other health from damage T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_SABRE_BLAST); ent->dmg = newdmg; //we did the damage so change the damage for next touch if (ent->dmg > 0) //if there still is any dmg left then don't destroy bolt { ent->think = cblaster_pass; ent->nextthink = level.time + 0.01; //return so it doesnt get destroyed 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); T_RadiusDamage(ent, ent->owner, rdam, other, damr, MOD_SABRE_BLAST); gi.WriteByte (svc_temp_entity); gi.WriteByte (TE_PLAIN_EXPLOSION); gi.WritePosition (origin); gi.multicast (ent->s.origin, MULTICAST_PHS); //if count was true if (ent->radius_dmg == 1) G_FreeEdict(ent); //simply destroy ent else remove_shot(ent); //decrement shot and remove object}void fire_cblaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int type, qboolean count){ edict_t *bolt; trace_t tr; VectorNormalize (dir); bolt = G_Spawn(); bolt->svflags = SVF_DEADMONSTER; VectorCopy (start, bolt->s.origin); VectorCopy (start, bolt->s.old_origin); vectoangles (dir, bolt->s.angles); VectorScale (dir, speed, bolt->velocity); //copy beginning velocity to temp variable in case we need to continue moving VectorCopy(dir, bolt->cutterangle); bolt->movetype = MOVETYPE_FLYMISSILE; bolt->clipmask = MASK_SHOT; bolt->solid = SOLID_BBOX; VectorClear (bolt->mins); VectorClear (bolt->maxs); bolt->s.modelindex = gi.modelindex ("models/objects/plasma/tris.md2"); bolt->touch = xbuster_touch; bolt->s.effects |= EF_COLOR_SHELL; if (type == 0) { bolt->s.renderfx |= (RF_SHELL_RED|RF_SHELL_GREEN); } else if (type == 1) { VectorSet(bolt->mins, -2, -2, -2); VectorSet(bolt->maxs, 2, 2, 2); bolt->s.effects |= EF_BLASTER; bolt->s.modelindex = gi.modelindex ("models/objects/plasma2/tris.md2"); bolt->s.renderfx |= (RF_SHELL_GREEN); } else if (type == -1) { VectorSet(bolt->mins, -8, -8, -8); VectorSet(bolt->maxs, 8, 8, 8); bolt->s.modelindex = gi.modelindex ("models/objects/sblast/tris.md2"); bolt->s.effects = EF_BLASTER; bolt->touch = sblaster_touch; } else { //if we have charge upgrade and charged above 2 if (self->client->pers.enhance == ENH_CHARG && type > 2) { bolt->s.effects |= EF_ROCKET; bolt->s.renderfx |= (RF_SHELL_RED); } else { bolt->s.effects |= EF_GRENADE; bolt->s.renderfx |= (RF_SHELL_BLUE); } VectorSet(bolt->mins, -8, -8, -8); VectorSet(bolt->maxs, 8, 8, 8); bolt->s.modelindex = gi.modelindex ("models/objects/plasma3/tris.md2"); bolt->touch = cblaster_touch; } //if we decided not to count (blaster2 or tank) if (!count) { bolt->radius_dmg = 1; //mark as not counting bolt->think = G_FreeEdict; //set think to only remove without counting down } else { bolt->radius_dmg = 0; //mark as counting bolt->think = remove_shot; //set think to remove shot and count down } bolt->owner = self; bolt->nextthink = level.time + 3; //for plasma type 3 damage will be used as health bolt->dmg = damage; bolt->classname = "bolt"; gi.linkentity (bolt); tr = gi.trace (self->s.origin, NULL, NULL, bolt->s.origin, bolt, MASK_SHOT); if (tr.fraction < 1.0) { VectorMA (bolt->s.origin, -10, dir, bolt->s.origin); bolt->touch (bolt, tr.ent, NULL, NULL); }}
//peewee start //phase shield //if target is a client if (targ->client) { //if target has a phase shield and //we are still alive if (targ->client->pers.enhance == ENH_PHASE && targ->health > 0) { //make unable to take damage targ->takedamage = false; targ->solid = SOLID_NOT; //set time limit targ->client->pers.blast_time = level.time + 1.5; } }
//phase shield else if (ent->client->pers.enhance == ENH_PHASE) { if (ent->client->pers.blast_time < level.time) { //remove partially invisible //ent->s.effects = 0; ent->s.renderfx = 0; ent->solid = SOLID_BBOX; //make able to take damage again ent->takedamage = true; } } //peewee end
//------------------------------// CUTTER//------------------------------void cutter_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);void cutter_think (edict_t *ent){ //decrement time ent->health--; //if time runs out if (ent->health == 0) { //decrement shot and remove object remove_shot(ent); return; //stop thinking } else //otherwise ent->nextthink = level.time + 0.1; //keep thinking //dont start spin for 0.4 seconds if (ent->health < 26) { //add spin vec3_t v, f; v[PITCH] = ent->cutterangle[PITCH]; //if a player shot this if (ent->owner && ent->owner->client) { //adjust curve for left hand if (ent->owner->client->pers.hand == LEFT_HANDED) v[YAW] = ent->cutterangle[YAW] -= 25; else v[YAW] = ent->cutterangle[YAW] += 25; } else //otherwise use the same spin v[YAW] = ent->cutterangle[YAW] += 25; v[ROLL] = ent->cutterangle[ROLL]; AngleVectors (v, f, NULL, NULL); VectorScale(f, 650, f); VectorCopy(f, ent->velocity); VectorCopy(v, ent->cutterangle); } //if we are currently not solid if (ent->count) { //decrement timer ent->count--; //if timer is zero if (ent->count == 0) { //make it touchable again ent->solid = SOLID_BBOX; ent->touch = cutter_touch; } }}void cutter_pass (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf){ return;}void cutter_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf){ if (other == ent->owner) return; if (other->takedamage) { //we hit someone so do damage T_Damage (other, ent, ent->owner, ent->velocity, ent->s.origin, plane->normal, ent->dmg, 0, 0, MOD_CUTTER); //make cutter not solid so that it will pass through players ent->solid = SOLID_NOT; ent->touch = cutter_pass; //tell cutter think that we are nonsolid by starting counter ent->count = 3; //cutter hit so start spinning ent->nextthink = level.time; } else { //decrement shot and remove object remove_shot(ent); }}void fire_cutter (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, qboolean charged){ edict_t *bolt; trace_t tr; VectorNormalize (dir); bolt = G_Spawn(); bolt->svflags = SVF_DEADMONSTER; VectorCopy (start, bolt->s.origin); VectorCopy (start, bolt->s.old_origin); vectoangles (dir, bolt->s.angles); VectorScale (dir, speed, bolt->velocity); bolt->movetype = MOVETYPE_FLYMISSILE; bolt->clipmask = MASK_SHOT; bolt->solid = SOLID_BBOX; VectorClear (bolt->mins); VectorClear (bolt->maxs); bolt->s.modelindex = gi.modelindex ("models/objects/cutter/tris.md2"); bolt->touch = cutter_touch; if (charged) { bolt->s.effects |= EF_COLOR_SHELL; bolt->s.renderfx |= (RF_SHELL_GREEN); } bolt->owner = self; bolt->count = 0; //clear notsolid counter bolt->health = 30; //initialize health timer bolt->nextthink = level.time + 0.1; bolt->think = cutter_think; bolt->s.sound = gi.soundindex ("weapons/cutter.wav"); bolt->dmg = damage; bolt->classname = "bolt"; //copy forward before adding spin VectorCopy(bolt->s.angles, bolt->cutterangle); //give cutter some spin VectorSet(bolt->avelocity,0, -2000 ,0); gi.linkentity (bolt); tr = gi.trace (self->s.origin, NULL, NULL, bolt->s.origin, bolt, MASK_SHOT); if (tr.fraction < 1.0) { VectorMA (bolt->s.origin, -10, dir, bolt->s.origin); bolt->touch (bolt, tr.ent, NULL, NULL); }}