[solved] for 2 spawners; Spawn other weapon.

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Lagi
Posts: 679
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

[solved] for 2 spawners; Spawn other weapon.

Post by Lagi »

I have randomspawner that make weapon1 or weapon2

If there are 2x randomspawners on map; i would like 1st to spawn weapon1 and 2nd to spawn weapon2.

to avoid situation when you have 2x the same weapons, and no chance to get another.


edit: I was trying to go around it by dispalying different sprite for pickup, but THE SPAWN sprite only change after player pickup the weapon

Code: Select all

Actor  Mace3 : CustomInventory 
{ 
  Inventory.PickupMessage "Mace"
  Inventory.Icon "hmceA0"
  
States
  {
  pickup:
   TNT1 A 0 A_JumpIfInventory("Mace2", 1, "pickup_gauntlets", AAPTR_PLAYER1) 
  TNT1 A 0 A_GiveInventory("MaceAmmo2") //need to not pickup mace more than 1 mace
  TNT1 A 0 A_GiveInventory("Mace2") 
	Stop
	
	
	pickup_gauntlets:
	TNT1 A 0 A_GiveInventory("gauntletspickup") 
	Stop
	
 Spawn:
 TNT1 A 0 
	TNT1 A 0 A_JumpIfInventory("Mace2", 1, "Spawn2", AAPTR_PLAYER1) 
	hmce A -1 
    Stop
	
	Spawn2:
	WGNT A -1
    Stop
	
	}
}

here is summon mace3 two times before picking it up. Second summon its not gauntlets... but if you pick more than one, then next spawn would be looklike gauntlets.
Last edited by Lagi on Sat Aug 19, 2023 5:03 am, edited 1 time in total.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: for 2 spawners; Spawn other weapon.

Post by Jarewill »

Hey Lagi!
Haven't seen you in a while. ;)
Lagi wrote: Wed Aug 16, 2023 8:10 am edit: I was trying to go around it by dispalying different sprite for pickup, but THE SPAWN sprite only change after player pickup the weapon
This might be because you only loop the last frame in your Spawn state, try changing it to a full loop:

Code: Select all

 Spawn:
	TNT1 A 0 A_JumpIfInventory("Mace2", 1, "Spawn2", AAPTR_PLAYER1) 
	hmce A 1
    Loop
User avatar
Lagi
Posts: 679
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

Re: for 2 spawners; Spawn other weapon.

Post by Lagi »

Hi Jarewill,
i am enjoying obsidian maps.

My problem now is:

map spawn 2x mace at generation.

the sprite pickup of the 2nd one is not changing to gauntlets, after player pickup 1st mace.

so when you pickup 2nd mace, you gain gauntlets, but i would like sprite to change as well.

hmm... maybe some acs script that is trigger when player pickup mace.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: for 2 spawners; Spawn other weapon.

Post by Jarewill »

Have you tried including the change I proposed above?
In my testing that worked, unless I am misunderstanding what the problem is.
User avatar
Lagi
Posts: 679
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

Re: for 2 spawners; Spawn other weapon.

Post by Lagi »

my gameplay mod randomly spawn mace or gauntlets in each gauntlets of necromancer place.

let say map have 2x gauntlets spawn point. any my mod change them into 2x maces


I want to have spawn mace AND gauntlets in the case if there are 2x spawn points for gauntlets

so player dont find the same weapon twice - because its useless for him


i want this to happen instead:



Or let me put it this way....

if i pick up 1st mace (on 1st screen) , 2nd didnt become gauntlets - i want player to have access to both weapons

obsidian often generate 2x the same weapons pick up.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: for 2 spawners; Spawn other weapon.

Post by Jarewill »

Ohhh, I think I understand now.
I think for this a BlockThingsIterator will work well, or A_CheckProximity since you are using DECORATE.
You can run that check at the beginning of your weapon's Spawn state (keeping in mind NoDelay) and turn it into the gauntlets if it detects another copy within a radius, for example:
TNT1 A 0 A_CheckProximity("Spawn2","Mace3",10000)
User avatar
Lagi
Posts: 679
Joined: Sat Jun 23, 2018 12:51 pm
Location: Thou shalt alter thy beliefs with new evidence

Re: for 2 spawners; Spawn other weapon.

Post by Lagi »

Yes, that works, thanks
Post Reply

Return to “Scripting”