PDA

View Full Version : New ammo refill algorithm


Simon Logic
12-15-2006, 11:28
Try this one. It's very... smooth =) Very hope it will be introduced as an alternative to existent one (and ammo_refill config var will have three modes: 0, 1 and 2).

csdm_misc.sma. Replace hook_CurWeapon(id) with this one (case 1 is hacked for the testing; it should be 2 but g_AmmoRefill value is normalized into 1 or 0):

public hook_CurWeapon(id)
{
if (!g_AmmoRefill || !csdm_active())
{
return
}

new wp = read_data(2)

if(g_WeaponSlots[wp] == SLOT_PRIMARY || g_WeaponSlots[wp] == SLOT_SECONDARY)
{
server_print("[CSDM_DEBUG] g_AmmoRefill = %d", g_AmmoRefill)
new ammo_back = cs_get_user_bpammo(id, wp)

switch(g_AmmoRefill) {
case 1: { // new smooth algorithm =)
new ammo_clip = read_data(3)
new ammo_back_new = g_MaxClipAmmo[wp] - ammo_clip

if(ammo_back_new > g_MaxBPAmmo[wp])
ammo_back_new = g_MaxBPAmmo[wp]

if(ammo_back_new > ammo_back)
cs_set_user_bpammo(id, wp, ammo_back_new)
}
default:
if(ammo_back < g_MaxBPAmmo[wp])
{
cs_set_user_bpammo(id, wp, g_MaxBPAmmo[wp])
}
}
}
}


And add this to csdm.inc (constants should be revised!):

// Ammo per clip lookup table
stock g_MaxClipAmmo[] = {
-1,
13,
-1,
10,
1,
7,
-1,
30,
30,
-1,
30,
20,
25,
30,
35,
30,
12,
20,
10,
30,
100,
8,
30,
30,
20,
-1,
7,
30,
30,
-1,
50
}


PS. Thanx AlMod for asking for my help ;)

BAILOPAN
12-16-2006, 14:18
Can you explain what this does differently?

Simon Logic
12-18-2006, 13:01
Well, the main differ is that it's smooth (beautiful) in gameplay. Plus it's very good for item mode because you can still take items (and reduce lag a little?) =)

Suppose you have the following clip/backpack ammo: 30/40. Max clip ammo is 30 for current weapon. Player is constantly shooting. Here is a table of changing quantity of ammo as a result for my algorithm:

clip/backpack

29/40
28/40
... (here goes original CS algorithm)
0/40
30/10 (reloaded)
29/10
.. (here goes original CS algorithm)
20/10 (it's a treshold: 20 + 10 = max_clip_ammo for current weapon)
19/11
18/12
... (my algorithm)
0/30
30/0 (realoaded)
29/1
28/2
...
etc.

Simon Logic
12-19-2006, 20:18
Implementation, fixes and further ideas you can find here (CSDM 2.1d topic):

http://forums.alliedmods.net/showpost.php?p=417453&postcount=49

Shaman
12-23-2006, 12:49
You can do this:

Do these once:
-Do not display bullet amount on users screen
-Disable buying bullets
Do these every second:
-Get users weapons
-For all weapons -> Set bullet amount to 50
On weapon pick:
-Get picked weapon
-For picked weapon -> Set bullet amount to 50

No weapon can spend 50 bullets in a second so bullets will not end. Users will not see bullets so they will not ask "Why AWP has 50 bullets?" or "Why my weapon reloads every second?".

Simon Logic
12-23-2006, 15:28
No weapon can spend 50 bullets in a second so bullets will not end. Users will not see bullets so they will not ask "Why AWP has 50 bullets?" or "Why my weapon reloads every second?".
Firstly, this is admin's job to inform players about server rules: MOTD, amx_message, web page etc.
Secondly, it's impossible to hide HUD items because they are drawn by your CLIENT. We can just fake them.

Shaman
12-23-2006, 17:21
Secondly, it's impossible to hide HUD items because they are drawn by your CLIENT. We can just fake them.

So vittu is a liar???:
http://img150.**************/img150/8541/shmonitor2ok4.th.jpg (http://img150.**************/my.php?image=shmonitor2ok4.jpg)
Original post:http://forums.alliedmods.net/showpost.php?p=308109&postcount=1

Simon Logic
12-25-2006, 05:51
Thanx for information. "HideWeapon" event is not described on http://wiki.amxmodx.org/index.php/Half-Life_1_Game_Events

But this is a bad practice to hack client's HUD. Super Hero is more specific mod than CSDM (imho).

Also
If using the REPLACE_HUD option, clients radar is also removed from the hud. If lots of hud messages are being displayed at the same time the monitor may flash briefly, but does not happen enough to be concerned.