Detonate projectiles while in air(SOLVED)

Discuss all aspects related to modding Zandronum here.
Post Reply
Faad3e_
New User
Posts: 18
Joined: Wed Sep 12, 2012 9:32 pm

Detonate projectiles while in air(SOLVED)

#1

Post by Faad3e_ » Sat Jan 04, 2014 3:20 am

Is there anyway that a player can detonate a projectile while its in the air with a weapon?
(Example: A projectile is flying, I use the ALTFIRE and the projectile is sent to death state)
Last edited by Faad3e_ on Sat Jan 04, 2014 6:27 pm, edited 1 time in total.

Catastrophe
Retired Staff / Community Team Member
Posts: 2571
Joined: Sat Jun 02, 2012 2:44 am

RE: Detonate projectiles while in air

#2

Post by Catastrophe » Sat Jan 04, 2014 3:39 am

Yeah, look at the ghostbuster traps in GvH

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Detonate projectiles while in air

#3

Post by Ivan » Sat Jan 04, 2014 3:41 am

Catastrophe wrote: Yeah, look at the ghostbuster traps in GvH
Or Ragnarok DM, which has an example that works exactly the way OP describes.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

Faad3e_
New User
Posts: 18
Joined: Wed Sep 12, 2012 9:32 pm

RE: Detonate projectiles while in air

#4

Post by Faad3e_ » Sat Jan 04, 2014 4:00 am

Ivan wrote:

Or Ragnarok DM, which has an example that works exactly the way OP describes.
Alright, i downloaded it, which gun haves the behavior i described?

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Detonate projectiles while in air

#5

Post by Ivan » Sat Jan 04, 2014 4:15 am

The plasma cannon, found in 3rd or 4th map. Although you might need to define a new key to detonate it, still, it's the same for altfire really. (With enabling A_Weaponready and necessary flags to allow alt fire to pass)
Last edited by Ivan on Sat Jan 04, 2014 4:16 am, edited 1 time in total.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

Faad3e_
New User
Posts: 18
Joined: Wed Sep 12, 2012 9:32 pm

RE: Detonate projectiles while in air

#6

Post by Faad3e_ » Sat Jan 04, 2014 4:23 am

Ivan wrote: The plasma cannon, found in 3rd or 4th map. Although you might need to define a new key to detonate it, still, it's the same for altfire really. (With enabling A_Weaponready and necessary flags to allow alt fire to pass)
Alright, thanks a lot sir

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: Detonate projectiles while in air

#7

Post by Ijon Tichy » Sat Jan 04, 2014 4:49 am

It's simple, really. Have the projectile constantly check for an item in the player's inventory. If it's there, jump to a state where it does an A_Stop (to stop in midair), then do some explosion shit and disappear. Alternately, have it call A_Die, which would drop its health to 0 and put it in the Death state, and have the A_Stop there.

This grenade lays on the ground and does not detonate until the player gets the DakkaDetonateGrenades item.

Code: Select all

// This is the inventory item that will be placed in the player's inventory
// to detonate it; give it through whatever method, take it immediately after
actor DakkaDetonateGrenades: Inventory { Inventory.MaxAmount 1 +UNDROPPABLE }

// The grenade itself
actor DakkaRemoteGrenade
{
    // irrelevant

    States
    {
      Spawn:
        SGRN A 1 bright
        SGRN A 0 A_JumpIfInTargetInventory("DakkaDetonateGrenades", 1, "Detonate")
        loop
      
      Detonate:
        SGRN A 0 A_Die
        goto Death2  // should never be reached

      Death:
        SGRN A 0 A_Stop
        SGRN A 0 A_ChangeFlag("NOGRAVITY", 1)
        SGRN A 0 A_JumpIfInTargetInventory("DakkaDetonateGrenades", 1, "Death2")
        goto OnGround

      OnGround:
        SGRN A 1 bright
        loop

      Death2:
        SGRN A 0 A_Stop
        SGRN A 0 A_ChangeFlag("NOGRAVITY", 1)
        MISL B 0 A_SetTranslucent(1, 1)
        MISL B 0 bright A_PlaySound("dakka/explode")
        MISL B 0 bright A_Explode(96, 144, 0)
        MISL B 0 bright A_Explode(64, 144)
        MISL B 8 bright
        MISL C 6 bright
        MISL D 4 bright
        stop
    }
}
Last edited by Ijon Tichy on Sat Jan 04, 2014 4:50 am, edited 1 time in total.

Faad3e_
New User
Posts: 18
Joined: Wed Sep 12, 2012 9:32 pm

RE: Detonate projectiles while in air

#8

Post by Faad3e_ » Sat Jan 04, 2014 5:26 am

Ijon Tichy wrote: It's simple, really. Have the projectile constantly check for an item in the player's inventory. If it's there, jump to a state where it does an A_Stop (to stop in midair), then do some explosion shit and disappear. Alternately, have it call A_Die, which would drop its health to 0 and put it in the Death state, and have the A_Stop there.

This grenade lays on the ground and does not detonate until the player gets the DakkaDetonateGrenades item.

Code: Select all

// This is the inventory item that will be placed in the player's inventory
// to detonate it; give it through whatever method, take it immediately after
actor DakkaDetonateGrenades: Inventory { Inventory.MaxAmount 1 +UNDROPPABLE }

// The grenade itself
actor DakkaRemoteGrenade
{
    // irrelevant

    States
    {
      Spawn:
        SGRN A 1 bright
        SGRN A 0 A_JumpIfInTargetInventory("DakkaDetonateGrenades", 1, "Detonate")
        loop
      
      Detonate:
        SGRN A 0 A_Die
        goto Death2  // should never be reached

      Death:
        SGRN A 0 A_Stop
        SGRN A 0 A_ChangeFlag("NOGRAVITY", 1)
        SGRN A 0 A_JumpIfInTargetInventory("DakkaDetonateGrenades", 1, "Death2")
        goto OnGround

      OnGround:
        SGRN A 1 bright
        loop

      Death2:
        SGRN A 0 A_Stop
        SGRN A 0 A_ChangeFlag("NOGRAVITY", 1)
        MISL B 0 A_SetTranslucent(1, 1)
        MISL B 0 bright A_PlaySound("dakka/explode")
        MISL B 0 bright A_Explode(96, 144, 0)
        MISL B 0 bright A_Explode(64, 144)
        MISL B 8 bright
        MISL C 6 bright
        MISL D 4 bright
        stop
    }
}
whoa, you made it so simple, thanks even more sir!

guess im just too dumb at this :(

EDIT: one question, projectiles always take as target the thing that shot them?
Last edited by Faad3e_ on Sat Jan 04, 2014 5:28 am, edited 1 time in total.

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: Detonate projectiles while in air

#9

Post by Ijon Tichy » Sat Jan 04, 2014 5:58 am

Yeah, a projectile's target is its firer. Change the target of the projectile, that target is now considered the firer. Kinda backwards, but welcome to hacks.

Post Reply