2023-08-27 14:32:18 -07:00
|
|
|
version "4.10"
|
|
|
|
|
|
|
|
|
|
|
|
const HDLD_KIRI_GRETCHENCOUNTER = "kgc";
|
|
|
|
|
|
|
|
class GretchenCounter : HDWeapon
|
|
|
|
{
|
|
|
|
default
|
|
|
|
{
|
|
|
|
+weapon.wimpy_weapon;
|
|
|
|
+inventory.invbar;
|
|
|
|
+hdweapon.droptranslation;
|
|
|
|
+hdweapon.fitsinbackpack;
|
|
|
|
hdweapon.barrelsize 0,0,0;
|
|
|
|
weapon.selectionorder 1014;
|
|
|
|
|
|
|
|
scale 0.6;
|
|
|
|
inventory.icon "SARGF1";
|
|
|
|
inventory.pickupmessage "Picked up a Gretchen Counter.";
|
|
|
|
inventory.pickupsound "derp/crawl";
|
|
|
|
translation 0;
|
|
|
|
tag "Gretchen Counter";
|
|
|
|
|
|
|
|
hdweapon.refid HDLD_KIRI_GRETCHENCOUNTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
float lastReading;
|
2023-08-27 16:55:47 -07:00
|
|
|
float angularVelocity;
|
|
|
|
float needlePosition;
|
|
|
|
int framesSinceLastBeep;
|
2023-08-27 14:32:18 -07:00
|
|
|
|
|
|
|
override double WeaponBulk()
|
|
|
|
{
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
override bool AddSpareWeapon(actor newowner)
|
|
|
|
{
|
|
|
|
return AddSpareWeaponRegular(newowner);
|
|
|
|
}
|
|
|
|
|
|
|
|
override hdweapon GetSpareWeapon(actor newowner,bool reverse,bool doselect)
|
|
|
|
{
|
|
|
|
return GetSpareWeaponRegular(newowner,reverse,doselect);
|
|
|
|
}
|
|
|
|
|
|
|
|
states
|
|
|
|
{
|
|
|
|
spawn:
|
|
|
|
SARG F -1;
|
|
|
|
stop;
|
|
|
|
|
2023-08-27 16:55:47 -07:00
|
|
|
// Needle overlay states.
|
|
|
|
needle_indicator:
|
|
|
|
KGCN A 1; wait;
|
|
|
|
|
2023-08-27 14:32:18 -07:00
|
|
|
select0:
|
2023-08-27 16:55:47 -07:00
|
|
|
KGCM A 1;
|
2023-08-27 14:32:18 -07:00
|
|
|
goto select0big;
|
|
|
|
|
|
|
|
deselect0:
|
2023-08-27 16:55:47 -07:00
|
|
|
KGCM A 1;
|
2023-08-27 14:32:18 -07:00
|
|
|
goto deselect0big;
|
|
|
|
|
|
|
|
ready:
|
2023-08-27 16:55:47 -07:00
|
|
|
KGCM A 1 {
|
|
|
|
A_Overlay(355, "needle_indicator");
|
|
|
|
A_OverlayPivotAlign(355, PSPA_CENTER, PSPA_BOTTOM);
|
2023-08-27 14:32:18 -07:00
|
|
|
UpdateDisplay();
|
|
|
|
A_WeaponReady(WRF_NOFIRE | WRF_ALLOWUSER3); // USER3 = MagManager.
|
|
|
|
}
|
|
|
|
|
|
|
|
goto readyend;
|
|
|
|
|
|
|
|
readyend:
|
|
|
|
#### # 0 A_ReadyEnd();
|
|
|
|
#### # 0 A_Jump(256,"ready");
|
|
|
|
}
|
|
|
|
|
|
|
|
action float GetReadingForType(String type_name, float distance_scale)
|
|
|
|
{
|
|
|
|
ThinkerIterator iter = ThinkerIterator.Create(type_name);
|
|
|
|
Actor mo;
|
|
|
|
float totalReading = 0.0;
|
|
|
|
while(mo = Actor(iter.Next()))
|
|
|
|
{
|
|
|
|
//shardCount++;
|
|
|
|
float dist = Distance3D(mo);
|
|
|
|
|
|
|
|
// Convert to "meters" (with a minimum).
|
|
|
|
if(dist < 32) {
|
|
|
|
dist = 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scale distance.
|
|
|
|
dist *= distance_scale;
|
|
|
|
|
|
|
|
|
|
|
|
console.printf("%s", type_name);
|
|
|
|
totalReading += 1.0 / (dist * dist);
|
|
|
|
}
|
|
|
|
|
|
|
|
return totalReading;
|
|
|
|
}
|
|
|
|
|
2023-08-27 16:55:47 -07:00
|
|
|
// override void Tick()
|
|
|
|
// {
|
|
|
|
// super.Tick();
|
|
|
|
// UpdateDisplay();
|
|
|
|
// }
|
|
|
|
|
2023-08-27 14:32:18 -07:00
|
|
|
action void UpdateDisplay()
|
|
|
|
{
|
2023-08-27 16:55:47 -07:00
|
|
|
float angle_min = -45.0;
|
|
|
|
float angle_max = 45.0;
|
|
|
|
|
|
|
|
|
2023-08-27 14:32:18 -07:00
|
|
|
// console.printf("kjsdcsjkdcnsdjkcnsdkjcnsdc");
|
|
|
|
|
|
|
|
// ThinkerIterator iter = ThinkerIterator.Create("BFGNecroShard");
|
|
|
|
// Actor mo;
|
|
|
|
// int shardCount = 0;
|
|
|
|
// float totalReading = 0.0;
|
|
|
|
// while(mo = BFGNecroShard(iter.Next()))
|
|
|
|
// {
|
|
|
|
// //shardCount++;
|
|
|
|
// float dist = Distance3D(mo);
|
|
|
|
|
|
|
|
// // Convert to "meters" (with a minimum).
|
|
|
|
// if(dist < 32) {
|
|
|
|
// dist = 32;
|
|
|
|
// }
|
|
|
|
// dist /= 32.0;
|
|
|
|
|
|
|
|
// // // Arbitrary scaling.
|
|
|
|
// // dist /= 16.0;
|
|
|
|
|
|
|
|
// totalReading += 1.0 / (dist * dist);
|
|
|
|
// shardCount += 1;
|
|
|
|
// }
|
|
|
|
|
|
|
|
float totalReading =
|
|
|
|
GetReadingForType("BFGNecroShard", 1.0) +
|
|
|
|
GetReadingForType("HDBarrel", 2.0);
|
|
|
|
|
2023-08-27 16:55:47 -07:00
|
|
|
// invoker.lastReading = totalReading * 0.01 + invoker.lastReading * 0.99;
|
2023-08-27 14:32:18 -07:00
|
|
|
|
|
|
|
float pct_reading = invoker.lastReading * 2000.0;
|
2023-08-27 16:55:47 -07:00
|
|
|
|
|
|
|
invoker.lastReading = totalReading;
|
|
|
|
|
|
|
|
float r = frandom(0.0, 1.0);
|
|
|
|
if(r < pct_reading)
|
|
|
|
{
|
|
|
|
console.printf("test: %f %f", r, pct_reading);
|
|
|
|
A_StartSound("kiri/gretchencounter_click");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-27 14:32:18 -07:00
|
|
|
// if(pct_reading > 1.0) {
|
|
|
|
// pct_reading = 1.0;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
String meter_str = "";
|
|
|
|
float k;
|
|
|
|
for(k = 0.0; k < 1.0; k += 0.02) {
|
|
|
|
if(k < pct_reading) {
|
|
|
|
meter_str = meter_str.."#";
|
|
|
|
} else {
|
|
|
|
meter_str = meter_str.."_";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-27 16:55:47 -07:00
|
|
|
// if(pct_reading > 1.0) {
|
|
|
|
// pct_reading = 1.0;
|
|
|
|
// }
|
|
|
|
// A_OverlayRotate(355,
|
|
|
|
// angle_min + (angle_max - angle_min) * (1.0 - pct_reading));
|
|
|
|
|
|
|
|
|
|
|
|
invoker.angularvelocity += pct_reading - invoker.needlePosition;
|
|
|
|
invoker.angularvelocity *= 0.97;
|
|
|
|
|
|
|
|
bool wasNeedleAtMax = (invoker.needlePosition >= 0.9);
|
|
|
|
|
|
|
|
invoker.needlePosition += invoker.angularvelocity * 0.1;
|
|
|
|
invoker.needlePosition = clamp(invoker.needlePosition, 0.0, 1.0);
|
|
|
|
|
|
|
|
A_OverlayRotate(355,
|
|
|
|
angle_min + (angle_max - angle_min) * (1.0 - invoker.needlePosition));
|
|
|
|
|
|
|
|
console.printf("Ang vel %f", invoker.angularvelocity);
|
2023-08-27 14:32:18 -07:00
|
|
|
console.printf("Shard count: [%s] %f", meter_str, pct_reading);
|
2023-08-27 16:55:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
invoker.framesSinceLastBeep++;
|
|
|
|
if((!wasNeedleAtMax || invoker.framesSinceLastBeep > 15) && invoker.needlePosition >= 0.9) {
|
|
|
|
A_StartSound("kiri/gretchencounter_blip");
|
|
|
|
invoker.framesSinceLastBeep = 0;
|
|
|
|
}
|
2023-08-27 14:32:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|