drbrain / hscore

The ASSS modules by Hyperspace for customizable ships and items.

Clone this repository (size: 1.3 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/drbrain/hscore/
commit 778: 52ef572e0da9
parent 776: b529bb65caee
branch: hscore
Added ?bountytype.
drbrain
5 months ago

Changed (Δ1.4 KB):

raw changeset »

hscore_rewards.c (66 lines added, 11 lines removed)

Up to file-list hscore_rewards.c:

@@ -26,6 +26,9 @@ typedef struct PData
26
26
	int min_shared_money_to_notify;
27
27
28
28
	int periodic_tally;
29
30
	int edit_ppk;
31
	int show_exp;
29
32
} PData;
30
33
31
34
typedef struct AData
@@ -125,6 +128,36 @@ local void Ckillmessages(const char *com
125
128
	}
126
129
}
127
130
131
local helptext_t bountytype_help =
132
"Targets: none\n"
133
"Args: none\n"
134
"Toggles the bounty displayed on players";
135
136
local void Cbountytype(const char *command, const char *params, Player *p, const Target *target)
137
{
138
	PData *pdata = PPDATA(p, pdkey);
139
140
	if (pdata->edit_ppk == 0)
141
	{
142
		pdata->edit_ppk = 1;
143
		pdata->show_exp = 0;
144
		chat->SendMessage(p, "Set to display reward money.");
145
	}
146
	else
147
	{
148
		if (pdata->show_exp == 0)
149
		{
150
			pdata->show_exp = 1;
151
			chat->SendMessage(p, "Set to display reward exp.");
152
		}
153
		else
154
		{
155
			pdata->edit_ppk = 0;
156
			chat->SendMessage(p, "Set to display player bounty");
157
		}
158
	}
159
}
160
128
161
local int GetPersistData(Player *p, void *data, int len, void *clos)
129
162
{
130
163
	PData *pdata = PPDATA(p, pdkey);
@@ -134,6 +167,8 @@ local int GetPersistData(Player *p, void
134
167
	persist_data->min_kill_money_to_notify = pdata->min_kill_money_to_notify;
135
168
	persist_data->min_kill_exp_to_notify = pdata->min_kill_exp_to_notify;
136
169
	persist_data->min_shared_money_to_notify = pdata->min_shared_money_to_notify;
170
	persist_data->show_exp = pdata->show_exp;
171
	persist_data->edit_ppk = pdata->edit_ppk;
137
172
138
173
	return sizeof(PData);
139
174
}
@@ -147,6 +182,8 @@ local void SetPersistData(Player *p, voi
147
182
	pdata->min_kill_money_to_notify = persist_data->min_kill_money_to_notify;
148
183
	pdata->min_kill_exp_to_notify = persist_data->min_kill_exp_to_notify;
149
184
	pdata->min_shared_money_to_notify = persist_data->min_shared_money_to_notify;
185
	pdata->show_exp = persist_data->show_exp;
186
	pdata->edit_ppk = persist_data->edit_ppk;
150
187
}
151
188
152
189
local void ClearPersistData(Player *p, void *clos)
@@ -156,6 +193,8 @@ local void ClearPersistData(Player *p, v
156
193
	pdata->min_kill_money_to_notify = 0;
157
194
	pdata->min_kill_exp_to_notify = 0;
158
195
	pdata->min_shared_money_to_notify = 20;
196
	pdata->edit_ppk = 0;
197
	pdata->show_exp = 0;
159
198
}
160
199
161
200
local PlayerPersistentData my_persist_data =
@@ -502,7 +541,7 @@ local void killCallback(Arena *arena, Pl
502
541
		{
503
542
			chat->SendMessage(killer, "You received %d exp for killing %s.", experience, killed->name);
504
543
		}
505
		else if (money && notify_for_money && exp == 0)
544
		else if (money && notify_for_money && experience == 0)
506
545
		{
507
546
			chat->SendMessage(killer, "You received $%d for killing %s.", money, killed->name);
508
547
		}
@@ -554,18 +593,32 @@ local int edit_ppk_bounty(Player *p, Pla
554
593
{
555
594
	if (t->p_ship != SHIP_SPEC)
556
595
	{
557
		int index = p->pid * bounty_map.size + t->pid;
558
		ticks_t gtc = current_ticks();
559
		if (bounty_map.timeout[index] < gtc)
596
		PData *pdata = PPDATA(t, pdkey);
597
		if (pdata->edit_ppk)
560
598
		{
561
			int minBonusPlayers = cfg->GetInt(p->arena->cfg, "Hyperspace", "MinBonusPlayers",  4);
562
			int bonus = p->arena->playing >= minBonusPlayers;
563
			int money = calculateKillMoneyReward(p->arena, t, p, pos->bounty, bonus);
564
			bounty_map.bounty[index] = 	money;
565
			bounty_map.timeout[index] = gtc + 100;
599
			int index = p->pid * bounty_map.size + t->pid;
600
			ticks_t gtc = current_ticks();
601
			if (bounty_map.timeout[index] < gtc)
602
			{
603
				if (pdata->show_exp)
604
				{
605
					int minBonusPlayers = cfg->GetInt(p->arena->cfg, "Hyperspace", "MinBonusPlayers",  4);
606
					int bonus = p->arena->playing >= minBonusPlayers;
607
					int exp = calculateKillExpReward(p->arena, t, p, pos->bounty, bonus);
608
					bounty_map.bounty[index] = exp;
609
				}
610
				else
611
				{
612
					int minBonusPlayers = cfg->GetInt(p->arena->cfg, "Hyperspace", "MinBonusPlayers",  4);
613
					int bonus = p->arena->playing >= minBonusPlayers;
614
					int money = calculateKillMoneyReward(p->arena, t, p, pos->bounty, bonus);
615
					bounty_map.bounty[index] = 	money;
616
				}
617
				bounty_map.timeout[index] = gtc + 100;
618
			}
619
			pos->bounty = bounty_map.bounty[index];
620
			return 1;
566
621
		}
567
		pos->bounty = bounty_map.bounty[index];
568
		return 1;
569
622
	}
570
623
	return 0;
571
624
}
@@ -1135,6 +1188,7 @@ EXPORT int MM_hscore_rewards(int action,
1135
1188
		mm->RegCallback(CB_PLAYERACTION, paction, arena);
1136
1189
1137
1190
		cmd->AddCommand("killmessages", Ckillmessages, arena, killmessages_help);
1191
		cmd->AddCommand("bountytype", Cbountytype, arena, bountytype_help);
1138
1192
1139
1193
		adata->reset = 1;
1140
1194
		ml->SetTimer(periodic_tick, 0, 100, arena, arena);
@@ -1149,6 +1203,7 @@ EXPORT int MM_hscore_rewards(int action,
1149
1203
		mm->UnregAdviser(&myadv, arena);
1150
1204
1151
1205
		cmd->RemoveCommand("killmessages", Ckillmessages, arena);
1206
		cmd->RemoveCommand("bountytype", Cbountytype, arena);
1152
1207
1153
1208
		mm->UnregCallback(CB_WARZONEWIN, flagWinCallback, arena);
1154
1209
		mm->UnregCallback(CB_KILL, killCallback, arena);