/* =============== cancelBuildFire =============== */ void cancelBuildFire( gentity_t *ent ) { vec3_t forward, end; trace_t tr; gentity_t *traceEnt; int bHealth; if( ent->client->ps.stats[ STAT_BUILDABLE ] != BA_NONE ) { ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; return; } //repair buildable if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); VectorMA( ent->client->ps.origin, 100, forward, end ); trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, MASK_PLAYERSOLID ); traceEnt = &g_entities[ tr.entityNum ]; if( tr.fraction < 1.0 && ( traceEnt->s.eType == ET_BUILDABLE ) && ( traceEnt->biteam == ent->client->ps.stats[ STAT_PTEAM ] ) && ( ( ent->client->ps.weapon >= WP_HBUILD2 ) && ( ent->client->ps.weapon <= WP_HBUILD ) ) && traceEnt->spawned && traceEnt->health > 0 ) { if( ent->client->ps.stats[ STAT_MISC ] > 0 ) { G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); return; } bHealth = BG_FindHealthForBuildable( traceEnt->s.modelindex ); traceEnt->health += HBUILD_HEALRATE; ent->client->pers.statscounters.repairspoisons++; level.humanStatsCounters.repairspoisons++; if( traceEnt->health > bHealth ) traceEnt->health = bHealth; if( traceEnt->health == bHealth ) G_AddEvent( ent, EV_BUILD_REPAIRED, 0 ); else G_AddEvent( ent, EV_BUILD_REPAIR, 0 ); } } else if( ent->client->ps.weapon == WP_ABUILD2 ) meleeAttack( ent, ABUILDER_CLAW_RANGE, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_DMG, MOD_ABUILDER_CLAW ); //melee attack for alien builder }
/* =============== cancelBuildFire =============== */ void cancelBuildFire( gentity_t *ent ) { // Cancel ghost buildable if( ent->client->ps.stats[ STAT_BUILDABLE ] != BA_NONE ) { ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; return; } if( ent->client->ps.weapon == WP_ABUILD ) meleeAttack( ent, ABUILDER_CLAW_RANGE, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_DMG, MOD_ABUILDER_CLAW ); }
void FragTrap::vaulhunter_dot_exe( std::string const & target ) { if (_energy >= 25) { int i = rand() % 10; if (i > 5) i /= 2; if ( i == 1) meleeAttack( target ); else if ( i == 2) rangedAttack( target ); else if (i == 3) blablaAttack( target ); else if (i == 4 ) footAttack( target ); else if ( i == 5 ) beatchAttack( target ); } else std::cout << "You don't have enough energy's Points" << std::endl; }
/* =============== FireWeapon =============== */ void FireWeapon( gentity_t *ent ) { if ( ent->client ) { // set aiming directions AngleVectors( ent->client->ps.viewangles, forward, right, up ); CalcMuzzlePoint( ent, forward, right, up, muzzle ); } else { AngleVectors( ent->turretAim, forward, right, up ); VectorCopy( ent->s.pos.trBase, muzzle ); } // fire the specific weapon switch ( ent->s.weapon ) { case WP_ALEVEL1: meleeAttack( ent, LEVEL1_CLAW_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW ); break; case WP_ALEVEL1_UPG: meleeAttack( ent, LEVEL1_CLAW_U_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW ); break; case WP_ALEVEL3: meleeAttack( ent, LEVEL3_CLAW_RANGE, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW ); break; case WP_ALEVEL3_UPG: meleeAttack( ent, LEVEL3_CLAW_UPG_RANGE, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW ); break; case WP_ALEVEL2: meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW ); break; case WP_ALEVEL2_UPG: meleeAttack( ent, LEVEL2_CLAW_U_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW ); break; case WP_ALEVEL4: meleeAttack( ent, LEVEL4_CLAW_RANGE, LEVEL4_CLAW_WIDTH, LEVEL4_CLAW_HEIGHT, LEVEL4_CLAW_DMG, MOD_LEVEL4_CLAW ); break; case WP_BLASTER: blasterFire( ent ); break; case WP_MACHINEGUN: bulletFire( ent, RIFLE_SPREAD, RIFLE_DMG, MOD_MACHINEGUN ); break; case WP_SHOTGUN: shotgunFire( ent ); break; case WP_CHAINGUN: bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN ); break; case WP_FLAMER: flamerFire( ent ); break; case WP_PULSE_RIFLE: pulseRifleFire( ent ); break; case WP_MASS_DRIVER: massDriverFire( ent ); break; case WP_LUCIFER_CANNON: LCChargeFire( ent, qfalse ); break; case WP_LAS_GUN: lasGunFire( ent ); break; case WP_PAIN_SAW: painSawFire( ent ); break; case WP_GRENADE: throwGrenade( ent ); break; case WP_LOCKBLOB_LAUNCHER: lockBlobLauncherFire( ent ); break; case WP_HIVE: hiveFire( ent ); break; case WP_TESLAGEN: teslaFire( ent ); break; case WP_MGTURRET: bulletFire( ent, MGTURRET_SPREAD, MGTURRET_DMG, MOD_MGTURRET ); break; case WP_ABUILD: case WP_ABUILD2: buildFire( ent, MN_A_BUILD ); break; case WP_HBUILD: buildFire( ent, MN_H_BUILD ); break; default: break; } }
/* =============== FireWeapon =============== */ void FireWeapon( gentity_t *ent ) { if( ent->client ) { // set aiming directions AngleVectors( ent->client->ps.viewangles, forward, right, up ); CalcMuzzlePoint( ent, forward, right, up, muzzle ); } else { AngleVectors( ent->turretAim, forward, right, up ); VectorCopy( ent->s.pos.trBase, muzzle ); } // fire the specific weapon switch( ent->s.weapon ) { case WP_ALEVEL1: case WP_ALEVEL1_UPG: meleeAttack( ent, LEVEL1_CLAW_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW ); break; case WP_ALEVEL3: case WP_ALEVEL3_UPG: meleeAttack( ent, LEVEL3_CLAW_RANGE, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW ); break; case WP_ALEVEL2: meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW ); break; case WP_ALEVEL2_UPG: meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW ); break; case WP_ALEVEL4: meleeAttack( ent, LEVEL4_CLAW_RANGE, LEVEL4_CLAW_WIDTH, LEVEL4_CLAW_DMG, MOD_LEVEL4_CLAW ); break; case WP_BLASTER: blasterFire( ent ); break; case WP_MACHINEGUN: bulletFire( ent, RIFLE_SPREAD, RIFLE_DMG, MOD_MACHINEGUN ); break; case WP_SHOTGUN: shotgunFire( ent ); break; case WP_CHAINGUN: bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN ); break; case WP_FLAMER: flamerFire( ent ); break; case WP_PULSE_RIFLE: pulseRifleFire( ent ); break; case WP_MASS_DRIVER: massDriverFire( ent ); break; case WP_LUCIFER_CANNON: LCChargeFire( ent, qfalse ); break; case WP_LAS_GUN: lasGunFire( ent ); break; case WP_PAIN_SAW: painSawFire( ent ); break; case WP_GRENADE: if(ent->client->pers.grenades >= 4) { ent->client->ps.persistant[ PERS_CREDIT ] += GRENADE_PRICE; trap_SendServerCommand( ent-g_entities, va( "print \"^1You have dropped 4 grenades allready, please detonate(Right click Blaster) them in order to drop more.\n\"" ) ); } else { ent->client->pers.grenades += 1; throwGrenade( ent ); } break; case WP_LOCKBLOB_LAUNCHER: lockBlobLauncherFire( ent ); break; case WP_HIVE: hiveFire( ent ); break; case WP_TESLAGEN: teslaFire( ent ); break; case WP_MGTURRET: bulletFire( ent, MGTURRET_SPREAD, MGTURRET_DMG, MOD_MGTURRET ); break; case WP_ABUILD: case WP_ABUILD2: buildFire( ent, MN_A_BUILD ); break; case WP_HBUILD: case WP_HBUILD2: buildFire( ent, MN_H_BUILD ); break; default: break; } }
void Player::update() { //setting font to avoid segfault damageText.setFont(font); if (timer->getElapsedTime().asSeconds() > nextMove) { sf::Vector2i deltaPosition(0, 0); //adding 1 to position if key is pressed if (moving[Direction::RIGHT]) deltaPosition.x += 1; if (moving[Direction::LEFT]) deltaPosition.x -= 1; //preventing diagonal movement if (!moving[Direction::RIGHT] && !moving[Direction::LEFT]) { if (moving[Direction::UP]) deltaPosition.y -= 1; if (moving[Direction::DOWN]) deltaPosition.y += 1; } //attempting to move if position should be changed if (deltaPosition.x != 0 || deltaPosition.y != 0) { if (move(deltaPosition)) { //resetting move timer since player has moved. amount reset based off of speed nextMove = timer->getElapsedTime().asSeconds() + 0.25 - stats[StatName::SPEED] / 1000.0; //repositioning damage text damageText.setPosition(position.x * tileSize + tileSize/3, position.y * tileSize + 20); } } } //end of movement //checking if attack cooldown in over if (timer->getElapsedTime().asSeconds() > nextAttack) { //ATTACKING RIGHT if (attacking[Direction::RIGHT]) { direction = Direction::RIGHT; updateVertices(); //MELEE ATTACK if (equipedWeapon.getType() == Weapon::Type::MELEE) { if (meleeAttack(position+sf::Vector2i(1, 0))) nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); } } //ATTACKING LEFT else if (attacking[Direction::LEFT]) { direction = Direction::LEFT; updateVertices(); nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); //MELEE ATTACK if (equipedWeapon.getType() == Weapon::Type::MELEE) { if (meleeAttack(position+sf::Vector2i(-1, 0))) nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); } } //ATTACKING UP else if (attacking[Direction::UP]) { direction = Direction::UP; updateVertices(); nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); //MELEE ATTACK if (equipedWeapon.getType() == Weapon::Type::MELEE) { if (meleeAttack(position+sf::Vector2i(0, -1))) nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); } } //ATTACKING DOWN else if (attacking[Direction::DOWN]) { direction = Direction::DOWN; updateVertices(); nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); //MELEE ATTACK if (equipedWeapon.getType() == Weapon::Type::MELEE) { if (meleeAttack(position+sf::Vector2i(0, 1))) nextAttack = timer->getElapsedTime().asSeconds() + equipedWeapon.getHitTime(); } } } //end of attacking }
/* =============== cancelBuildFire =============== */ void cancelBuildFire( gentity_t *ent ) { vec3_t forward, end; trace_t tr; gentity_t *traceEnt; vec3_t mins, maxs; int bHealth; // int damage = 20; // int hHealth; G_UnlaggedOn( ent, muzzle, LEVEL0_BITE_RANGE ); trap_Trace( &tr, muzzle, mins, maxs, end, ent->s.number, MASK_SHOT ); G_UnlaggedOff( ); if( ent->client->ps.stats[ STAT_BUILDABLE ] != BA_NONE ) { ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; return; } //repair buildable if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); VectorMA( ent->client->ps.origin, 1000, forward, end ); trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, MASK_PLAYERSOLID ); traceEnt = &g_entities[ tr.entityNum ]; if( tr.fraction < 1.0 && ( traceEnt->s.eType == ET_BUILDABLE ) && ( traceEnt->biteam == ent->client->ps.stats[ STAT_PTEAM ] ) && ( ( ent->client->ps.weapon >= WP_HBUILD2 ) && ( ent->client->ps.weapon <= WP_HBUILD ) ) && traceEnt->spawned && traceEnt->health > 0 ) { if( ent->client->ps.stats[ STAT_MISC ] > 0 ) { G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); return; } bHealth = BG_FindHealthForBuildable( traceEnt->s.modelindex ); traceEnt->health += HBUILD_HEALRATE; ent->client->pers.statscounters.repairspoisons++; level.humanStatsCounters.repairspoisons++; if( traceEnt->health > bHealth ) traceEnt->health = bHealth; if( traceEnt->health == bHealth ) G_AddEvent( ent, EV_BUILD_REPAIRED, 0 ); else G_AddEvent( ent, EV_BUILD_REPAIR, 0 ); } //never mind about this part onwards: doesn't work. //I just keep it here. else if ( tr.fraction < 1.0 && ( traceEnt->s.eType != ET_BUILDABLE ) && (traceEnt->biteam == ent->client->ps.stats[ STAT_PTEAM ] ) && ( ( ent->client->ps.weapon >= WP_HBUILD2 ) && ( ent->client->ps.weapon <= WP_HBUILD ) )) //same stats except not a buildable { if( ent->client->ps.stats[ STAT_MISC ] > 0 ) { G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); return; } traceEnt->health += HBUILD_HEALRATE; ent->client->pers.statscounters.repairspoisons++; level.humanStatsCounters.repairspoisons++; /* hHealth = ( ent->health > client->ps.stats[ STAT_HEALTH ]); //client not declared etc.... just an example of what i want * for max health, but it isn't needed as vampire mode's 150%maxhealth is on. */ /* Play sounds for 'maxhealth reached' and stuff like that if( traceEnt->health == maxHealth ) G_AddEvent( ent, EV_BUILD_REPAIRED, 0 ); else G_AddEvent( ent, EV_BUILD_REPAIR, 0 ); */ } else if ((traceEnt->biteam != ent->client->ps.stats[ STAT_PTEAM ] ) && ( ( ent->client->ps.weapon >= WP_HBUILD2 ) && ( ent->client->ps.weapon <= WP_HBUILD ) )) //same stats except not on human team) { if( ent->client->ps.stats[ STAT_MISC ] > 0 ) { G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); return; //Following is 'unreachable' according to the compiler // traceEnt->health -= 20; //do sum dmg! //damage //same for this part - but i just keep it in case server crashes due to a ckit killing. // G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK, MOD_TRIGGER_HURT ); } } } else if( ent->client->ps.weapon == WP_ABUILD2 ) meleeAttack( ent, ABUILDER_CLAW_RANGE, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_DMG, MOD_ABUILDER_CLAW ); //melee attack for alien builder2 else if( ent->client->ps.weapon == WP_ABUILD ) meleeAttack( ent, ABUILDER_CLAW_RANGE, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_DMG, MOD_ABUILDER_CLAW ); //melee attack for alien builder }
/* =============== FireWeapon2 =============== */ void FireWeapon2( gentity_t *ent ) { if( ent->client ) { // set aiming directions AngleVectors( ent->client->ps.viewangles, forward, right, up ); CalcMuzzlePoint( ent, forward, right, up, muzzle ); } else { AngleVectors( ent->s.angles2, forward, right, up ); VectorCopy( ent->s.pos.trBase, muzzle ); } // fire the specific weapon switch( ent->s.weapon ) { case WP_ALEVEL0: meleeAttack( ent, LEVEL0_SCRATCH_RANGE, 2, LEVEL0_SCRATCH_DMG, MOD_LEVEL0_BITE ); break; case WP_ALEVEL1_UPG: poisonCloud( ent ); break; case WP_ALEVEL2_UPG: areaZapFire( ent ); break; case WP_LUCIFER_CANNON: LCChargeFire( ent, qtrue ); break; //standard weapons w/o secondary just use melee //dictionary: //meleeAttack( ent, [range], [width], [damage], MOD_[means of death] ); //note: keep width 20 for humans otherwise it will not hit the target in vents. case WP_BLASTER: meleeAttack( ent, BLASTER_MELEE_RANGE, 20, BLASTER_MELEE, MOD_BLASTER ); break; case WP_SHOTGUN: meleeAttack( ent, SHOTGUN_BLAST_RANGE, 20, SHOTGUN_BLAST, MOD_SHOTGUN ); //acts like a forward explosion break; case WP_PULSE_RIFLE: lasGunFire( ent, LASGUN_SPREAD*2 ); break; case WP_CHAINGUN: bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN ); break; case WP_LOCKBLOB_LAUNCHER: throwGrenade( ent ); break; case WP_MGTURRET: shotgunFire( ent ); shotgunFire( ent ); shotgunFire( ent ); break; case WP_ABUILD: case WP_ABUILD2: case WP_HBUILD: case WP_HBUILD2: cancelBuildFire( ent ); break; default: break; } }