How do I make weapons summon enemies?

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
The Struggler
Posts: 15
Joined: Sat Sep 22, 2018 12:46 pm

How do I make weapons summon enemies?

Post by The Struggler »

Now, let me clarify that I know about A_SpawnItemEx but how do you actually use it for a weapon? Cause i wanna make a badass weapon that summons pinkies. I made this simple DECORATE script to show you how it should look:

actor JazzHands : Weapon 19872
{
Inventory.PickupMessage "That's some nice jazzhands"
Weapon.AmmoType "Cell"
Weapon.AmmoGive 500
Weapon.SlotNumber 8
AttackSound "vile/death"
States
{
Spawn:
IFOG A -1
Stop
Ready:
PUNG C 1 A_WeaponReady
Loop
Select:
PUNG C 1 A_Raise
Deselect:
PUNG C 1 A_Lower
Loop
Fire:
PUNG A 5 A_SpawnItemEx ("Demon", 0, 0)
Goto Ready
}
}
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: How do I make weapons summon enemies?

Post by ramon.dexter »

You should learn how to use the 'code' tag ;)

Also, what exactly is your question? The posted code should work, so use, try it.
Also, are you aware of the fact that the spawned pinkies will be hostile to you? If you want a badass weapon that will spawn pinkies, who will attack enemies, you need to make a new class inheriting from pinkie and add +FRIENDLY flag to it.

So, you should definitely specify your question.
User avatar
The Struggler
Posts: 15
Joined: Sat Sep 22, 2018 12:46 pm

Re: How do I make weapons summon enemies?

Post by The Struggler »

Hmm... I'll try that.

Basically what I'm saying is that the pinkies wont spawn and just becomes a weapon that is useless. Now this is my first time working with A_SpawnItemEx but I know the basics of guns.
User avatar
Boondorl
Posts: 137
Joined: Wed Jul 11, 2018 10:57 pm

Re: How do I make weapons summon enemies?

Post by Boondorl »

Keep in mind that monsters, by default, will not telefrag unless spawned from an Icon of Sin cube or specified to via the TELESTOMP flag. It's entirely possible the spawn is failing because it's spawning from your origin, and thus you yourself are blocking it. You'll want to make sure it's spawning a bit in front of the player to prevent that from happening (the edge of the Pinkie's hitbox should be outside the edge of yours, so you'll want to spawn it about 64 units away). Also, as the other person pointed out, make sure it's a custom Pinkie that inherits from the Demon class but has the +FRIENDLY flag, otherwise it'll just try to start chomping your face off.
User avatar
The Struggler
Posts: 15
Joined: Sat Sep 22, 2018 12:46 pm

Re: How do I make weapons summon enemies?

Post by The Struggler »

I really just cant seem to summon it, whatever i try to do.

ACTOR PlayerDemon 18604
{
Health 150
PainChance 100
Speed 20
Radius 30
Height 56
Mass 400
Monster
+FRIENDLY
+FLOORCLIP
SeeSound "demon/sight"
AttackSound "demon/melee"
PainSound "demon/pain"
DeathSound "demon/death"
ActiveSound "demon/active"
Obituary "$OB_DEMONHIT" // "%o was bit by a demon."
States
{
Spawn:
SARG AB 10 A_Look
Loop
See:
SARG AABBCCDD 2 Fast A_Chase
Loop
Melee:
SARG EF 8 Fast A_FaceTarget
SARG G 8 Fast A_SargAttack
Goto See
Pain:
SARG H 2 Fast
SARG H 2 Fast A_Pain
Goto See
Death:
SARG I 4
SARG J 4 A_Scream
SARG K 4
SARG L 4 A_NoBlocking
SARG M 4
SARG N -1
Stop
Raise:
SARG N 5
SARG MLKJI 2
Goto See
}
}



Actor JazzHands : Weapon replaces Chainsaw
{
Inventory.PickUpMessage "Nice jazzhands."
Weapon.SlotNumber 7
States
{
Spawn:
GORB B -1
Stop
Select:
TNT1 A 1 A_Raise
goto SelectAnim
DeselectAnim:
JAZH A 1 Offset(131, 98)
JAZH A 1 Offset(136, 99)
JAZH A 1 Offset(141, 101)
JAZH A 1 Offset(157, 115)
JAZH A 1 Offset(176, 129)
JAZH A 1 Offset(189, 139)
JAZH A 1 Offset(195, 148)
JAZH A 1 Offset(197, 152)
JAZH A 1 Offset(205, 164)
JAZH A 1 Offset(211, 177)
JAZH A 1 Offset(219, 189)
JAZH A 1 Offset(222, 195)
TNT1 AAAAAAAAAAAAAAA 1 A_lower
Wait
SelectAnim:
JAZH A 1 Offset(251, 170)
JAZH A 1 Offset(245, 161)
JAZH A 1 Offset(233, 149)
JAZH A 1 Offset(223, 136)
JAZH A 1 Offset(196, 105)
JAZH A 1 Offset(151, 96)
JAZH A 1 Offset(141, 99)
JAZH A 1 Offset(136, 98)
JAZH A 1 Offset(131, 98)
Goto Ready
READY:
JAZH B 1 A_WeaponReady
Wait
Deselect:
JAZH A 1 Offset(131, 98)
goto DeselectAnim
Fire:
JAZF A 3 A_SpawnItemEx ("PlayerDemon", 0, 0, 28, 0, 0, 0, 0, SXF_TRANSFERPOINTERS)
JAZF B 2
JAZH A 10 Offset(131, 98)
Goto Ready

}
}

Sorry for the REALLY, REALLY REALLY late reply.
User avatar
The Struggler
Posts: 15
Joined: Sat Sep 22, 2018 12:46 pm

Re: How do I make weapons summon enemies?

Post by The Struggler »

bump
User avatar
Ravick
Posts: 2002
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: How do I make weapons summon enemies?

Post by Ravick »

I'd try to make a 'demon projectile' that drops a pinky demon instead of trying to summon it directly from the weapon. :)
Post Reply

Return to “Scripting”