Xonotic
tests.qc
Go to the documentation of this file.
1 #include "tests.qh"
2 
4 {
5  EXPECT_NE(100, GetResource(this, RES_HEALTH));
6  delete(this.enemy);
7  delete(this);
8 }
9 
10 TEST(Weapons, Hurt)
11 {
12  entity it;
13 
14  noref Client a = it = NEW(Client, "A");
15  WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_1));
16  it.origin = '-100 0 0';
17  it.angles = '0 0 0';
18 
19  noref Client b = it = NEW(Client, "B");
20  WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_2));
21  it.origin = '100 0 0';
22  it.angles = '0 180 0';
23 
24  it = a;
25  PHYS_INPUT_BUTTON_ATCK(it) = true;
26  it.items |= IT_UNLIMITED_AMMO;
27  Weapon wep = WEP_VORTEX;
28  W_GiveWeapon(it, wep.m_id);
30 
31  it = b;
32  PHYS_INPUT_BUTTON_JUMP(it) = true;
33  it.enemy = a;
34 
35  defer(it, wep.switchdelay_raise + 0.1, test_weapons_hurt);
36 
37  SUCCEED();
38 }
39 
40 TEST(Vehicles, Spawn)
41 {
42  entity it;
43 
44  noref Client bot = it = NEW(Client, "Rider");
45  Client_Add(it, NUM_TEAM_1);
46  it.origin = '0 0 100';
47 
48  noref entity v = it = new(vehicle);
49  Vehicle veh = VEH_BUMBLEBEE;
50  it.active = ACTIVE_NOT;
51  vehicle_initialize(it, veh, false);
52  it.nextthink = time;
53 
54  SUCCEED();
55 }
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition: player.qh:147
const int NUM_TEAM_2
Definition: teams.qh:19
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
Definition: selection.qc:243
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
#define EXPECT_NE(val1, val2)
Definition: test.qh:52
TEST(Weapons, Hurt)
Definition: tests.qc:10
RES_HEALTH
Definition: ent_cs.qc:126
#define SUCCEED()
Must be present at the end of a test.
Definition: test.qh:15
entity enemy
Definition: sv_ctf.qh:143
void W_GiveWeapon(entity e, int wep)
Definition: common.qc:33
void test_weapons_hurt(entity this)
Definition: tests.qc:3
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition: player.qh:146
Definition: client.qh:88
vector v
Definition: ent_cs.qc:116
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define WITH(type, name, value, block)
Definition: misc.qh:40
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
const int NUM_TEAM_1
Definition: teams.qh:18
entity vehicle
Definition: impulse.qc:21
const int ACTIVE_NOT
Definition: defs.qh:36
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float autocvar_g_spawnshieldtime
Definition: player.qh:3
float time
Definition: csprogsdefs.qc:16
int m_id
Definition: weapon.qh:42
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)