Jump to content
  • 0

[Resolved] How can I remove a turret in Zandronum and/or ZDoom?


Empyre

Question

I want to create a reusable inventory item that spawns a turret. I can do that easily in DECORATE. However, I want the item to remove any existing turret the player has (but not other players' turrets) before spawning the new one, thus limiting the player to one at a time. Furthermore, I want a player's turret to be removed when the player disconnects or spectates.

I assume this will require ACS, but I don't know ACS, so I am asking for help. I know enough about coding to be able to understand what you tell me to do. I probably could also modify the code to fit my needs, but I wouldn't be able to create the code in the first place, yet. Solving this problem, with help, might be all I need to then begin exploring the possibilities of ACS.

You will, of course, be thanked in the WADINFO (and here, too).

Edited by Empyre
marking it resolved

Share this post


Link to post

6 answers to this question

Recommended Posts

  • 0

I plan to make two items with different kinds of turrets, and limit the player to one of each. Also, the player can spawn "ghosts". I wouldn't want to remove everything the player has spawned, but I like the idea to remove all children when the player disconnects or spectates.

Share this post


Link to post
  • 0

Here is the code for the plasma turret:

 

ACTOR OPPlasmaTurretMaker : CustomInventory

{

  Tag "Plasma Turret Maker"

  +INVENTORY.INVBAR

  +INVENTORY.UNDROPPABLE

  Inventory.Icon "COL4A0"

  Inventory.MaxAmount 1

  States

  {

  Use:

    TNT1 A 1

    TNT1 A 0 A_PlaySound("cyber/hoof")

    TNT1 A 0 A_SPawnItemEx("OPPlasmaTurret",0,0,0,0,0,0,0,SXF_SETMASTER)

    Fail

  }

}

 

ACTOR OPPlasmaTurret

{

  RenderStyle "Add"

  Alpha 0.75

  Mass 1000000

  Health 1000

  Damage 1024

  DamageType "PlayerDamage"

  PainChance 0

  Species "OPPlayer"

  +FRIENDLY

  +NOBLOCKMONST

  +THRUSPECIES

  +DONTHARMSPECIES

  +NOBLOOD

  +LOOKALLAROUND

  +NOTAUTOAIMED

  +MISSILEMORE

  +MISSILEEVENMORE

  +NOFEAR

  +QUICKTORETALIATE

  Radius 16

  Height 40

  Speed 0

  Monster

  +FLOORCLIP

  ActiveSound "baby/active"

  PainSound "pain/pain"

  Obituary "%o was gibbed by a plasma turret!"

  States

  {

  Spawn:

    COL4 A 10 A_Look

    Loop

  See:

    COL4 A 3 A_Chase

    Loop

  Melee:

  Missile:

    COL4 A 1 Bright A_FaceTarget

    COL4 A 2 A_CustomMissile("OPTurretBall",28,0,0,CMF_CHECKTARGETDEAD)

    Goto See

  Pain:

    COL4 A 3

    COL4 AI 3 A_Pain

    Goto See

  Death:

    COL4 A 12 A_SpawnItemEx("OPTurretDeath",0,0,24,0,0,0,0,SXF_SETMASTER)

    Stop

  }

}

 

ACTOR OPTurretDeath

{

  RenderStyle "Add"

  Alpha 0.75

  Damage 1024

  DamageType "PlayerDamage"

  Species "OPPlayer"

  +DONTHARMSPECIES

  +NOGRAVITY

  Obituary "%o was caught in a plasma turret explosion!"

  States

  {

  Spawn:

    TNT1 A 1     TNT1 A 0 A_PlaySound("world/barrelx")

    MISL B 8 Bright A_Explode(1024,256,FALSE)

    MISL C 6 Bright     MISL D 4 Bright

    Stop

  }

}

 

ACTOR OPTurretBall : PlasmaBall

{

  Damage 1024

  DamageType "PlayerDamage"

  Scale 0.75

  Speed 25

  Obituary "%o couldn't get away from from %k's plasma turret."

  BounceCount 5

  BounceType "Grenade"

  BounceFactor 1.0

  WallBounceFactor 1.0

  +MTHRUSPECIES

  +SEEKERMISSILE

  States

  {

  Spawn:

    PLS2 AB 6 Bright A_SeekerMissile(60,90,SMF_LOOK|SMF_PRECISE,256)

    Loop

  Death:

    PLS2 CDE 6 Bright

    Stop

  }

}

 

Here is the code for the rail turret:

 

ACTOR OPRailTurretMaker : CustomInventory

{

  Tag "Rail Turret Maker"

  +INVENTORY.INVBAR

  +INVENTORY.UNDROPPABLE

  Inventory.Icon "COL2A0"

  Inventory.MaxAmount 1

  States

  {

  Use:

    TNT1 A 1

    TNT1 A 0 A_PlaySound("cyber/hoof")

    TNT1 A 0 A_SPawnItemEx("OPRailTurret",0,0,0,0,0,0,0,SXF_SETMASTER)

    Fail

  }

}

 

ACTOR OPRailTurret

{

  RenderStyle "Add"

  Alpha 0.75

  Mass 1000000

  Health 1000

  DamageType "PlayerDamage"

  PainChance 0

  Species "OPPlayer"

  +FRIENDLY

  +NOBLOCKMONST

  +THRUSPECIES

  +DONTHARMSPECIES

  +NOBLOOD

  +LOOKALLAROUND

  +NOTAUTOAIMED

  +MISSILEMORE

  +MISSILEEVENMORE

  +NOFEAR

  +QUICKTORETALIATE

  Radius 16

  Height 40

  Speed 0

  Monster

  +FLOORCLIP

  ActiveSound "baby/active"

  PainSound "pain/pain"

  Obituary "%o was punctured by a rail turret!"

  States

  {

  Spawn:

    COL2 A 10 A_Look

    Loop

  See:

    COL2 A 3 A_Chase

    Loop

  Melee:

  Missile:

    COL2 A 1 Bright A_FaceTarget

    TNT1 A 0 A_CustomRailgun(-1,0,NONE,"Green",RGF_SILENT,1,0,"OPTurretPuff")

    TNT1 A 0 A_PlaySound("weapons/railgf")

    COL2 A 9

    Goto See

  Pain:

    COL2 A 3

    COL2 AI 3 A_Pain

    Goto See

  Death:

    COL2 A 12 A_SpawnItemEx("OPTurretDeath",0,0,24,0,0,0,0,SXF_SETMASTER)

    Stop

  }

}

 

ACTOR OPTurretPuff : BulletPuff

{

  +FORCERADIUSDMG

  +NODAMAGETHRUST

  +PUFFGETSOWNER

  -ALLOWPARTICLES

  +ALWAYSPUFF

  +PUFFONACTORS

  VSpeed 0

  DamageType PlayerDamage

  Obituary "%o was punctured by a rail turret."

  States

  {

  Spawn:

  Missile:

    TNT1 A 1

    TNT1 A 1 A_Explode (1024, 16, FALSE, FALSE, 16)

    stop

  }

}

 

I know that these are way overpowered, but so is the rest of opweapons, so they fit right in. As-is, the player can make an unlimited number of the turrets, and I don't want it to be that way, but i do want the player to be able to move the turret an unlimited number of times (replacing the old turret with a new one at a new location). Thus, once we have the removal working, the player would be limited to one of each.

 

If you tell me how to remove one of them, I should be able to apply that technique to the other one.

Edited by Empyre
added spoiler tags, then fixed what broke when I added spoilers around the code tagse

Share this post


Link to post
  • 0

I learned enough ACS to come up with this solution. The players can place unlimited turrets, but at a limited pace.


#library "oplibrary"
#include "zcommon.acs"

script "OPRailTurretGiver" ENTER
{
  TakeInventory("OPRailTurretMaker",4);
  GiveInventory("OPRailTurretMaker",2);
  while (TRUE)
  {
    Delay(35*20); //seconds * 35 tics/second = tics
    GiveInventory("OPRailTurretMaker",1);
  }
}

script "OPPlasmaTurretGiver" ENTER
{
  TakeInventory("OPPlasmaTurretMaker",4);
  GiveInventory("OPPlasmaTurretMaker",2);
  while (TRUE)
  {
    Delay(35*20); //seconds * 35 tics/second = tics
    GiveInventory("OPPlasmaTurretMaker",1);
  }
}

Share this post


Link to post
  • 0

Let's say there existed N types of turrets (where N was a known constant number), and each player was only allowed to have one turret of each type at a time. If you somehow assigned a unique range of N tags to each player in the game, then every turret in the game would have its own unique tag. If the tag could be computed from the player's number (see PlayerNumber) and the turret type, you'd compute it every time a new turret was being spawned, and call Thing_Remove on that tag to remove any previously existing turret with that tag from the map, before giving this tag to the newly spawned turret.

Edited by scifista42

Share this post


Link to post
  • 0

Thank you for answering. That would probably work, but I am happy with the solution I came up with. The player can carry up to 4 at a time, and they start each map with 2, and every 30 seconds (increased from the 20 seconds that was in the code posted above) they are given another one. This way, they can place an unlimited number of them, but slowly enough that they can't really flood the server.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...