3 #include "playerstats.fdh"
9 if (player
->hp
> player
->maxHealth
) player
->hp
= player
->maxHealth
;
12 void AddXP(int xp
, bool quiet
)
14 Weapon
*weapon
= &player
->weapons
[player
->curWeapon
];
15 bool leveled_up
= false;
20 while(weapon
->xp
> weapon
->max_xp
[weapon
->level
])
22 if (weapon
->level
< 2)
24 weapon
->xp
-= weapon
->max_xp
[weapon
->level
];
30 weapon
->xp
= weapon
->max_xp
[weapon
->level
];
35 statusbar
.xpflashcount
= 30;
37 if (player
->curWeapon
== WPN_SPUR
)
47 effect(player
->CenterX(), player
->CenterY(), EFFECT_LEVELUP
);
55 player
->XPText
->AddQty(xp
);
59 void SubXP(int xp
, bool quiet
)
61 Weapon
*weapon
= &player
->weapons
[player
->curWeapon
];
62 bool leveled_down
= false;
69 if (weapon
->level
> 0)
72 weapon
->xp
+= weapon
->max_xp
[weapon
->level
];
82 if (player
->curWeapon
== WPN_SPUR
)
85 if (leveled_down
&& !quiet
&& !player
->hide
)
87 effect(player
->CenterX(), player
->CenterY(), EFFECT_LEVELDOWN
);
92 void c------------------------------() {}
95 // add an item to the inventory list (generates an error msg if inventory is full)
96 void AddInventory(int item
)
98 if (player
->ninventory
+1 >= MAX_INVENTORY
)
99 { staterr("<<<AddInventory: inventory is full>>"); game
.running
= 0; return; }
101 player
->inventory
[player
->ninventory
++] = item
;
103 RefreshInventoryScreen();
106 // remove an item from the inventory list (does nothing if it's not in there)
107 void DelInventory(int item
)
114 slot
= FindInventory(item
);
115 if (slot
== -1) break;
117 for(i
=slot
;i
<player
->ninventory
-1;i
++)
119 player
->inventory
[i
] = player
->inventory
[i
+1];
121 player
->ninventory
--;
124 RefreshInventoryScreen();
127 // find which slot an item is in (returns -1 if player does not have it)
128 int FindInventory(int item
)
130 return CheckInventoryList(item
, player
->inventory
, player
->ninventory
);
133 // checks if the inventory list given contains the given item.
134 // if so, returns the index of the item. if not, returns -1.
135 int CheckInventoryList(int item
, int *list
, int nitems
)
139 for(i
=0;i
<nitems
;i
++)
140 if (list
[i
] == item
) return i
;
147 void c------------------------------() {}
151 // adds "ammo" ammo to the specified weapons ammo and maxammo,
152 // and if you don't have it already, gives it to you.
153 void GetWeapon(int wpn
, int ammo
)
155 if (!player
->weapons
[wpn
].hasWeapon
)
157 player
->weapons
[wpn
].ammo
= 0; // will be filled to full by AddAmmo below
158 player
->weapons
[wpn
].maxammo
= ammo
;
159 player
->weapons
[wpn
].level
= 0;
160 player
->weapons
[wpn
].xp
= 0;
161 player
->weapons
[wpn
].hasWeapon
= true;
162 player
->curWeapon
= wpn
;
165 { // missile capacity powerups
166 player
->weapons
[wpn
].maxammo
+= ammo
;
173 // AM- command. Drops specified weapon.
174 void LoseWeapon(int wpn
)
176 player
->weapons
[wpn
].hasWeapon
= false;
178 // lost current weapon?
179 if (wpn
== player
->curWeapon
)
181 // in case he has no weapons left at all
182 player
->curWeapon
= WPN_NONE
;
184 // find a new weapon for him
185 for(int i
=0;i
<WPN_COUNT
;i
++)
187 if (player
->weapons
[i
].hasWeapon
)
189 player
->curWeapon
= i
;
197 void TradeWeapon(int oldwpn
, int newwpn
, int ammo
)
199 int oldcurwpn
= player
->curWeapon
;
201 // ammo 0 = no change; used when you get missiles are upgraded to Super Missiles
203 ammo
= player
->weapons
[oldwpn
].maxammo
;
205 GetWeapon(newwpn
, ammo
);
208 // switch to new weapon if the weapon traded was the
209 // one we were using. Otherwise, don't change current weapon.
210 if (oldwpn
== oldcurwpn
)
211 player
->curWeapon
= newwpn
;
213 player
->curWeapon
= oldcurwpn
;
216 // adds "ammo" ammo to the specified weapon, but doesn't go over the limit.
217 void AddAmmo(int wpn
, int ammo
)
219 player
->weapons
[wpn
].ammo
+= ammo
;
220 if (player
->weapons
[wpn
].ammo
> player
->weapons
[wpn
].maxammo
)
221 player
->weapons
[wpn
].ammo
= player
->weapons
[wpn
].maxammo
;
224 // sets all weapons to max ammo. AE+ command.
225 void RefillAllAmmo(void)
227 for(int i
=0;i
<WPN_COUNT
;i
++)
229 if (player
->weapons
[i
].hasWeapon
)
230 player
->weapons
[i
].ammo
= player
->weapons
[i
].maxammo
;