Page 1 of 1

WLaD system still in progress. ACS help needed.

PostPosted: Sat May 08, 2004 7:21 am
by ellmo
I've decide to call my Weapon system WLaD (Weapon Limit and Drop). Yeah, I know it's silly, and it's not exactly mine if it comes to dropping weapons. But what the hell.

Dropping works fine as for now, thanks to LilWhiteMouse. But I've encountered minor porblems with it. Mouse, have you been testing it when Our Hero is very near to the wall? In my map the weapon is removed, but the MapSpot does not appear? Something I've done wrong?

And also, take a look at this code:
Code: Select allExpand view
Script 702 OPEN
{
int weaponsaw, weaponshot, weaponsawn, weaponchain, weaponrl, weaponplasma, weaponbfg;

If (CheckInventory("Chainsaw") != 0) {weaponsaw=1;}
        else  {weaponsaw=0;}
If (CheckInventory("Shotgun") != 0) {weaponshot=1;}
        else  {weaponshot=0;}
If (CheckInventory("SuperShotgun") != 0) {weaponsawn=1;}
        else  {weaponsawn=0;}
If (CheckInventory("Chaingun") != 0) {weaponchain=1;}
        else  {weaponchain=0;}
If (CheckInventory("RocketLauncher") != 0) {weaponrl=1;}
        else  {weaponsaw=0;}
If (CheckInventory("PlasmaRifle") != 0) {weaponplasma=1;}
        else  {weaponplasma=0;}
If (CheckInventory("BFG9000") != 0) {weaponbfg=1;}
        else  {weaponbfg=0;}

CurrentLoad =
weaponsaw+
weaponshot+
weaponchain+
weaponrl+
weaponplasma+
weaponbfg;
             
If (CurrentLoad > WeaponLimit)
        {
        Thing_Deactivate (240);  //Dormant Chainsaws
        Thing_Deactivate (241);  //Dormant Shotguns
        Thing_Deactivate (242);  //Dormant SuperShotguns
        Thing_Deactivate (243);  //Dormant Chainguns
        Thing_Deactivate (244);  //Dormant RocketLaunchers
        Thing_Deactivate (245);  //Dormant PlasmaGuns
        Thing_Deactivate (246);  //Dormant BFGs
        }
If (CurrentLoad <= WeaponLimit)
        {
        Thing_Activate (240);  //Activate Chainsaws
        Thing_Activate (241);  //Activate Shotguns
        Thing_Activate (242);  //Activate SuperShotguns
        Thing_Activate (243);  //Activate Chainguns
        Thing_Activate (244);  //Activate RocketLaunchers
        Thing_Activate (245);  //Activate PlasmaGuns
        Thing_Activate (246);  //Activate BFGs
        }
Hudmessage (s:"Current Weapon Load", s:CurrentLoad;
        HUDMSG_PLAIN, 103, CR_WHITE, 1.0, 0.09, 1);
Delay(3);
Restart;
}


It's supposed to set a Weapon Carrying Limit, and check if it's met every 3 tics. I know that CurrentLoad variable is a bit complicated, but I tried many other solutions, and it still does not work.
Moreover - The hudmessage visible in one of the last lines is supposed to print CurrentLoad on the screen. Insted of that I get:
"Current Weapon LoadFist"
Where the hell did he get that from?

And don't worry. All the variables are defined.
Any ides?

PostPosted: Sat May 08, 2004 7:34 am
by Chilvence
For the hudmessage, replace the s:CurrentLoad with d:CurrentLoad. All its doing at the moment is using the value of currentload as the index of the string to print after "Current Weapon Load"

This is because when you compile the script, the strings are stored in an index, and are only referred to in the scripts themselves by number.

Also, some simplification. This should work, but I cant say I've tried it.

CurrentLoad=CheckInventory("Chainsaw")+(CheckInventory("Shotgun")+(CheckInventory("SuperShotgun")+(CheckInventory("Chaingun")+(CheckInventory("RocketLauncher")+(CheckInventory("PlasmaRifle")+(CheckInventory("BFG9000")

PostPosted: Sat May 08, 2004 8:13 am
by ellmo
Yes, I've tried your solution also.
It seems that everything works fine (except the HudMessage, which I'm going to change in no-time), but weapons, even in dormant state can be picked up.

That screws everything I've ried to achive. Gotta have to thing a way around.

Any ideas, ZDoomers?

PostPosted: Sat May 08, 2004 8:32 am
by LilWhiteMouse
As to the thing not appearing, modify the drop script a little.

Code: Select allExpand view
script 1 (void) {
int PX, PY, PZ;
int MX, MY, MZ;
int Dist;

Thing_ChangeTID (0, 256);
SpawnSpot ("MapSpot", 256, 255, 0);
//Get things location
MX = GetActorX(255)/65536;
MY = GetActorY(255)/65536;
MZ = GetActorZ(255)/65536;

while (Dist < 32*32)//Wait until player is far enough away
   {
delay (const:4);
//Check player location
PX = GetActorX(256)/65536;
PY = GetActorY(256)/65536;
PZ = GetActorZ(256)/65536;
Dist = (PX - MX)*(PX - MX) + (PY - MY)*(PY - MY) + (PZ - MZ)*(PZ - MZ);
   }

SpawnSpot ("Shotgun", 255, 257, 0);
Thing_Remove(255);
if (ThingCount (0, 257) != 0)
   {
   TakeInventory ("Shotgun", 1);
   Thing_ChangeTID (257, 0);
   }
}


As to being able to pick up dormant weapons, create dummy pickups with decorate. Have a script check the players inventory for the weapon, remove the pickup specials if they already have it. When they drop a weapon, set the pickup specials at the same time.

[EDIT]
[EDIT2] I mis-interpreted the intent.

Something like this if what I mean:
Code: Select allExpand view
int WeaponTID[7] = {240, 241, 242, 243 244, 245, 246};
str WeaponName[7] = {"Chainsaw", "Shotgun", "SuperShotgun", "Chaingun", "RocketLauncher", "PlasmaRifle", "BFG9000"};
int WeaponLoad, WeaponLimit;

script 1 ENTER {
int f;
WeaponLimit = 4;
while (1)
   {
   WeaponLoad = 0;
   for (f = 0;f < 7;f++)
      {
      if (CheckInventory(WeaponName[f]) == 1)
         {
         WeaponLoad++;
         }
      }
   if (WeaponLoad >= WeaponLimit)
      {
      for (f = 0;f < 7;f++)
         {
         SetThingSpecial (WeaponTID[f], 0, 0, 0, 0, 0, 0);
         }
      }
      else
      {
      for (f = 0;f < 7;f++)
         {
         SetThingSpecial (WeaponTID[f], 226, 0, 2, f, 0, 0);
         }
      }
   Hudmessage (s:"Current Weapon Load ", d:WeaponLoad;HUDMSG_PLAIN, 103, CR_WHITE, 1.0, 0.09, 1);
   delay (const:3);
   }
}

script 2 (int Weapon) {
GiveInventory(WeaponName[Weapon], 1);
}

PostPosted: Sat May 08, 2004 9:18 am
by ellmo
Mhm.

I see your point, but I'm really having problems with this WeaponLoad (CurrentLoad or GearLoad, as the var name was changed few times).

After restarting the script this var does not change. I have a hud message that should indicate current value of GearLoad wit delay(4); refresh, but after picking up weapons, or typing IDFA it stays on zero.

BTW, using DECORATE dummy weapons works well now, but I cannot test them with WeaponLimit hit, yet I suppose they cannot be picked up, so this question is solved.
{
Thing_SetSpecial (240, 0, 0, 0, 0);
}

GODDAMN!

Looks lie this, now:
Code: Select allExpand view
Script 702 OPEN
{
GearLoad=
CheckInventory("Chainsaw")+
CheckInventory("Shotgun")+
CheckInventory("Chaingun")+
CheckInventory("SuperShotgun")+
CheckInventory("RocketLauncher")+
CheckInventory("PlasmaRifle")+
CheckInventory("BFG9000");
       
If (GearLoad <= WeaponLimit)
        {
        Thing_SetSpecial (240, 80, 230, 0, 0); 
        Thing_SetSpecial (241, 80, 231, 0, 0); 
        Thing_SetSpecial (242, 80, 232, 0, 0); 
        Thing_SetSpecial (243, 80, 233, 0, 0); 
        Thing_SetSpecial (244, 80, 234, 0, 0); 
        Thing_SetSpecial (245, 80, 235, 0, 0); 
        Thing_SetSpecial (246, 80, 236, 0, 0);
        Hudmessage (s:"Limit hit";
        HUDMSG_PLAIN, 103, CR_WHITE, 1.0, 0.01, 1);
        }
Else    {
        Thing_SetSpecial (240, 0, 0, 0, 0); 
        Thing_SetSpecial (241, 0, 0, 0, 0); 
        Thing_SetSpecial (242, 0, 0, 0, 0); 
        Thing_SetSpecial (243, 0, 0, 0, 0); 
        Thing_SetSpecial (244, 0, 0, 0, 0); 
        Thing_SetSpecial (245, 0, 0, 0, 0); 
        Thing_SetSpecial (246, 0, 0, 0, 0);
        Hudmessage (s:"Limit free";
        HUDMSG_PLAIN, 103, CR_WHITE, 1.0, 0.01, 1);
        }
Hudmessage (s:"Current Payload - ", d:CheckInventory("Shotgun");
HUDMSG_PLAIN, 103, CR_WHITE, 1.0, 0.1, 1);
Delay(const: 4);
Restart;
}

PostPosted: Sat May 08, 2004 10:06 am
by LilWhiteMouse
OPEN scripts are run by the map, and have no inventory. ENTER scripts are run by the player(s).

PostPosted: Sat May 08, 2004 10:42 am
by ellmo
YEAH!
I did it! And I did it before you gave me the last tip, Mouse!

It was in fact a problem of OPEN vs ENTER script.

Now the script that checks player's inventory is separated in ENTER script.
Phew. That was pretty simple... come to think of it.

Works perfectly fine now, but how the hell can a player drop a weapon that has no ammo?