Possible to give a monster more than one collision box?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- MetroidJunkie
- Posts: 709
- Joined: Fri Aug 19, 2011 7:27 am
Possible to give a monster more than one collision box?
Like if you wanted to give a monster a weak spot where hitting a small spot damages the monster but hitting the other collision box that spans across the rest of its body does nothing.
Re: Possible to give a monster more than one collision box?
So far as I know the only reliable way to do this is really hacky and involves having the monster spawn special collision boxes after every visible frame... if you take a look at the monster definitions in Brutal Doom you should get an idea of how to do this
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Possible to give a monster more than one collision box?
An alternate method is to spawn the extra hitbox once, set it to master/child, then use [wiki]A_Warp[/wiki] to bring the hitbox into place every tic.
The disadvantage to this method is that you can't temporarily remove the hitbox to get it out of the way of the monster's own attack. (Of course, the disadvantage to avoiding that problem by getting rid of the hitbox is that an attack may become completely uninterruptible and you lose that super satisfying fastest-draw-in-the-West headshot kill)
The disadvantage to this method is that you can't temporarily remove the hitbox to get it out of the way of the monster's own attack. (Of course, the disadvantage to avoiding that problem by getting rid of the hitbox is that an attack may become completely uninterruptible and you lose that super satisfying fastest-draw-in-the-West headshot kill)
- MetroidJunkie
- Posts: 709
- Joined: Fri Aug 19, 2011 7:27 am
Re: Possible to give a monster more than one collision box?
Probably an obvious question, how do you spawn a hitbox, specifically?
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Possible to give a monster more than one collision box?
Here's a simplified version of the abandoned headshot actor from Hideous Destructor:
EDIT: right, spawning. At some point (probably Spawn frame) the monster will be given the following item:
Code: Select all
actor ShotHead
{
// renderstyle none
+ismonster
-countkill
+shootable
+nogravity
+noradiusdmg //any radius damage inflicted on the head would already be inflicted on the body too
health 10000
height 12
radius 8
var int user_health;
var int user_damage;
var int user_height;
var int user_forward;
painchance 256
+quicktoretaliate
+forcepain
+seeinvisible
+notarget
+noextremedeath
+nodamagethrust
meleerange 32
states
{
spawn:
TNT1 A 0 nodelay
TNT1 A 0 A_SetUserVar("user_height",40) //height of base of neck
TNT1 A 0 A_SetUserVar("user_forward",3) //slight forward pitch of head
spawn2:
BON1 A 1 A_Warp(AAPTR_MASTER,user_forward,0,user_height)
TNT1 A 0 A_RearrangePointers(AAPTR_MASTER,AAPTR_MASTER,AAPTR_DEFAULT)
TNT1 A 0 A_MonsterRefire(0,"nope") //checks if target/master is dead
loop
pain:
TNT1 A 0 A_SetUserVar("user_damage",random((10000-health),(10000-health)*2)) //this means a shot to the head inflicts a random amount of damage between full and double
pain2:
TNT1 A 0 A_PrintBold("\cgHEAD SHOT",0.4,"BIGFONT")
TNT1 A 0 A_GiveInventory("HeadCheeze",random(2,12))
TNT1 A 0 A_CustomMeleeAttack((user_damage)) //could use A_Explode for this instead
TNT1 A 0 HealThing(10000)
TNT1 A 0 A_RearrangePointers(AAPTR_MASTER,AAPTR_MASTER,AAPTR_DEFAULT)
TNT1 A 0 A_MonsterRefire(0,"boom")
goto spawn2
boom:
TNT1 A 3 A_NoBlocking
TNT1 A 0 A_RearrangePointers(AAPTR_MASTER,AAPTR_MASTER,AAPTR_TARGET)
TNT1 AAAAAAAAAAAAAAAA 0 A_CustomMeleeAttack((1))//A_SpawnItemEx ("MegaBloodSplatter",0,0,0,velx,vely,velz+1,0,SXF_NOCHECKPOSITION)
TNT1 A 0 A_RearrangePointers(AAPTR_TRACER,AAPTR_MASTER,AAPTR_DEFAULT)
nope:
death:
TNT1 A 1 A_TakeInventory("HasHead",999,0,AAPTR_MASTER)
stop
}
}Code: Select all
actor GiveHead : ActionItem
{
states
{
pickup:
TNT1 A 0 A_JumpIfInventory("HasHead",1,2)
TNT1 A 0 A_Jump(256,"ReallyGiveHead")
TNT1 A 0
fail
reallygivehead:
TNT1 A 0 A_SpawnItemEx("ShotHead",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION,0)
goto nowyouhavegotahead
nowyouhavegotahead:
TNT1 A 0 A_GiveInventory("HasHead",1)
fail
}
}