Page 1 of 3

Custom Inventory & Respawn

Posted: Sun Feb 02, 2014 11:07 pm
by The_Spartan
Hi guys, i have this problem:

I have these weapons, that are generated on the map and shown depending on the player class (it is supposed to be a multiplayer map) by an object that spawns them all (depending also on their own strenght) and makes each one shown only to a specific playerclass.

Now, I want the weapons to not disappear after they are picked up and be pickable suddenly by another player, and I can't use the sv_weaponstay command, because the object that is supposed to give you the weapon is just a custominventory item.

Just for example, i'll show you the definition of the object that is to give you the Fighter Axe from Hexen:
ACTOR AxeGiver : CustomInventory
{
SpawnID 27
Game Doom
Inventory.RespawnTics 35
Tag "Timon's Axe"
Inventory.PickupMessage "$TXT_WEAPON_F2"
//$Category Weapons
VisibleToPlayerClass "Fighter"
States
{
Spawn:
WFAX A -1
Stop
Pickup:
TNT1 A 0 A_JumpIfInventory("FWeapAxe", 1, "Failing")
TNT1 A 0 A_JumpIfInventory("ImaFighter", 1, "PickupWeapon")
Fail
Failing:
TNT1 A 0
Fail
PickupWeapon:
TNT1 A 0 A_GiveInventory("FWeapAxe", 1)
goto Spawn
}
}
Unfortunately, this item just disappears after a player picks it up. I've tried also to make the "axegiver" respawn with the command A_SpawnItem after pickup, but unfortunately, being the player the activator, the item just moves a bit on the floor following the player's movements, causing the object to move a bit on each pickup.

Any ideas? :(

RE: Custom Inventory & Respawn

Posted: Thu Feb 20, 2014 10:16 am
by Vincent(PDP)
Try adding

Code: Select all

TNT1 A 0 A_SpawnItem("AxeGiver", 0)
to the PickupWeapon line.

But why do you have to make it an inventory item?
Just take the weapon itself and add:

Code: Select all

Spawn:
  WFAX A -1
  Stop
And then give the weapon a number

Code: Select all

ACTOR <Name> : Weapon <Random number here>

RE: Custom Inventory & Respawn

Posted: Thu Feb 20, 2014 6:36 pm
by Untitled
He wants to make it so only a certain playerclass can pick it up. I'm assuming he's just using Axe as frame of reference.

RE: Custom Inventory & Respawn

Posted: Thu Feb 20, 2014 6:48 pm
by Ijon Tichy
You have to use ACS to get a CustomInventory to respect sv_weaponstay. Things get more complicated then.
If you just want it to stay when you pick it up, use 'fail' (as you already are for the no-pickup cases), and the inventory item won't leave the floor, you won't get a pickup flash, no sound will play, and you won't get a pickup message. The flash and sound can be done with DECORATE, and the message can either be horribly faked with A_Print, or more convincingly faked with clientside ACS and Log (read msg0color to find out what color to make the message).

Also, why are you jumping to Spawn in a pickup state? Just use a 'stop'.

RE: Custom Inventory & Respawn

Posted: Sat Feb 22, 2014 9:43 am
by Vincent(PDP)
Untitled wrote: He wants to make it so only a certain playerclass can pick it up.
I get that, but who says you cannot try putting VisibleToPlayerClass on a weapon?

RE: Custom Inventory & Respawn

Posted: Sat Feb 22, 2014 7:54 pm
by The_Spartan
Ijon Tichy wrote: You have to use ACS to get a CustomInventory to respect sv_weaponstay. Things get more complicated then.
If you just want it to stay when you pick it up, use 'fail' (as you already are for the no-pickup cases), and the inventory item won't leave the floor, you won't get a pickup flash, no sound will play, and you won't get a pickup message. The flash and sound can be done with DECORATE, and the message can either be horribly faked with A_Print, or more convincingly faked with clientside ACS and Log (read msg0color to find out what color to make the message).
So, your idea is just to simulate a normal pickup even if it doesn't really happen?

RE: Custom Inventory & Respawn

Posted: Sat Feb 22, 2014 10:47 pm
by Popsoap
Vincent(PDP) wrote: I get that, but who says you cannot try putting VisibleToPlayerClass on a weapon?
I'm certain that doesn't prevent it from being picked up, it just makes it invisible to every class except the one specified.

RE: Custom Inventory & Respawn

Posted: Sun Feb 23, 2014 12:59 pm
by Vincent(PDP)
The_Spartan, change 'CustomInventory' into Weapon, add a DoomEdNum and see what happens.

RE: Custom Inventory & Respawn

Posted: Sun Feb 23, 2014 1:16 pm
by CloudFlash
Maybe make it so when unauthorized player class picks it up, it immediately throws another one behind itself and erases itself from this player's inventory?
That's how would I do it, anyway

RE: Custom Inventory & Respawn

Posted: Sun Feb 23, 2014 2:33 pm
by The_Spartan
CloudFlash wrote: Maybe make it so when unauthorized player class picks it up, it immediately throws another one behind itself and erases itself from this player's inventory?
That's how would I do it, anyway
Tried, it makes the pickup weapon spawn a bit far away from the original position, making it move on each pickup. I'll tell you, it's quite funny too. :lol:

RE: Custom Inventory & Respawn

Posted: Mon Feb 24, 2014 12:27 am
by Vincent(PDP)
The_Spartan wrote: Tried, it makes the pickup weapon spawn a bit far away from the original position, making it move on each pickup. I'll tell you, it's quite funny too. :lol:
Either "cheat":

Code: Select all

ACTOR FWeapAxe : Weapon <DoomEdNum>
{
<Some of your code here>
States
{
Ready:
  TNT1 A 0 A_JumpIfInventory("ImaFighter", 0, NoWay)
  <More of your code>
  Stop
Select:
  TNT1 A 0 A_JumpIfInventory("ImaFighter", 0, "NoWay")
   ??? ? ? 1 A_Raise
  Loop
NoWay:
  TNT1 A 0 A_TakeInventory("FWeapAxe", 1)
  TNT1 A 0 A_Print("You're not allowed to pick up this weapon.")
  Stop
}
}
Or you can use ACS (Best way):

Code: Select all

Script 123 (void)
{
Spawn("AxeGiver", GetActorX(ActivatorTID()), GetActorY(ActivatorTID()), GetActorZ(ActivatorTID()), 0, 0)
}
If you want, send me the mod and i can fix the ACS part for you.

RE: Custom Inventory & Respawn

Posted: Thu Mar 13, 2014 6:55 am
by Vincent(PDP)
Have you solved the problem yet? :3

RE: Custom Inventory & Respawn

Posted: Wed Mar 19, 2014 7:23 pm
by The_Spartan
Vincent(PDP) wrote: Have you solved the problem yet? :3
It just doesn't work: when you use the ActivatorTID command on the script, it considers the PLAYER as the activator, so it spawns the weapon where the player is, not where the weapon was before.
Considering also that using this method doesn't help much, because i would have to use a different script on each weapon, which is impossible.

RE: Custom Inventory & Respawn

Posted: Wed Mar 19, 2014 9:08 pm
by Vincent(PDP)
The_Spartan wrote:
Vincent(PDP) wrote: Have you solved the problem yet? :3
It just doesn't work: when you use the ActivatorTID command on the script, it considers the PLAYER as the activator, so it spawns the weapon where the player is, not where the weapon was before.
Considering also that using this method doesn't help much, because i would have to use a different script on each weapon, which is impossible.
How about this?

Code: Select all

 PickupWeapon:
 TNT1 A 0 A_GiveInventory("FWeapAxe", 1)
 Fail

--------------------------------------------------------------------------------------------


(Please try the above one first) A little change on the ACS:

Code: Select all

Script 123 (void)
{
Spawn("AxeGiver", GetActorX(0), GetActorY(0), GetActorZ(0), 0, 0)
}
And then on the weapon:

Code: Select all

PickupWeapon:
 TNT1 A 0 A_GiveInventory("FWeapAxe", 1)
 TNT1 A 0 ACS_ExecuteAlways(123, 0, 0, 0, 0)
 Stop

RE: Custom Inventory & Respawn

Posted: Thu Mar 20, 2014 7:39 pm
by The_Spartan
Same thing again...

RE: Custom Inventory & Respawn

Posted: Fri Mar 21, 2014 9:50 am
by Vincent(PDP)
The_Spartan wrote: Same thing again...
I've got it! I actually think this should work:

Code: Select all

PickupWeapon:
TNT1 A 0 A_GiveInventory("FWeapAxe", 1)
TNT1 A 0 ACS_ExecuteAlways(123, 0, x, y, z)
Stop
And:

Code: Select all

Script 123 (int x, int y, int z)
{
Spawn("AxeGiver", x, y, z, 0, 0);
}

RE: Custom Inventory & Respawn

Posted: Fri Mar 21, 2014 7:56 pm
by The_Spartan
Vincent(PDP) wrote:
The_Spartan wrote: Same thing again...
I've got it! I actually think this should work:

Code: Select all

PickupWeapon:
TNT1 A 0 A_GiveInventory("FWeapAxe", 1)
TNT1 A 0 ACS_ExecuteAlways(123, 0, x, y, z)
Stop
And:

Code: Select all

Script 123 (int x, int y, int z)
{
Spawn("AxeGiver", x, y, z, 0, 0);
}
Still nothing. I don't think that declaring new integers x y and z would mean checking the weapon position :surprised: I just think that we need to set the activator to be the OBJECT (the weapon) and not the player, so it doesn't respawn where the player is but where the weapon was on its original position.

RE: Custom Inventory & Respawn

Posted: Fri Mar 21, 2014 8:16 pm
by Vincent(PDP)
But it should work, try putting it on the regular pickup instead...
Because these x, y, z variables

Code: Select all

TNT1 A 0 ACS_ExecuteAlways(123, 0, x, y, z)
are used in decorate to get the objects position... See more: http://zdoom.org/wiki/DECORATE_expressions#Variables

Can you send me the wad, or atleast a PWAD with the weapon in? I'll see what i can do.

RE: Custom Inventory & Respawn

Posted: Sat Mar 22, 2014 6:06 pm
by The_Spartan
They just don't work. I think they do ONLY in Decorate Expressions.

Yes, i can send you the wad. I would be very grateful to you if you could fix this annoying problem for me. Private Message?

RE: Custom Inventory & Respawn

Posted: Sat Mar 22, 2014 6:16 pm
by Klofkac
It might not be good thing, but try replacing the Stop in PickupWeapon with Fail.