by Leon_Portier » Thu Jun 01, 2017 12:20 pm
Very good tutorial, the code can be expanded to create helmets, which fly off when shot.
Looks like this:
https://www.youtube.com/watch?v=CJ4w6GKfqwg
I could not figure out how to pass a var to a child actor, so I used a fake inventory actor.
Code(commented):
Spoiler:Im new to decorate, so please dont kill me
Hitboxes
Code: Select all
//helm headshot actor
Actor Helm_HeadshotHitbox//A hitbox für helmets
{
Radius 9 //Radius of hitbox
Health 1
Height 10 //Height of hitbox
Mass 0x7FFFFFFF //Disables game physics
+DONTTHRUST //Dont be thrusted by explosions
+NORADIUSDMG //No splash damage
+NOGRAVITY //Must not be affected by gravity
+SHOOTABLE //Must be shootable
+NODAMAGETHRUST //Must not be thrusted by damage
States
{
Spawn:
TNT1 A 1 A_Warp(AAPTR_MASTER, 0,0,34, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)//Attaches the hitbox on top of the torso
TNT1 A 0 A_CheckFlag("SOLID","Spawn",AAPTR_MASTER) //Goes to "Spawn:" if master is solid
Hitbox_Remove:
TNT1 A 0 A_Remove(AAPTR_DEFAULT) //Deletes the Hitbox
Stop
Death:
TNT1 A 0 A_GiveInventory("NoHelmethave",1,AAPTR_MASTER) //Indicates losing the helmet of master, needed for animation
TNT1 A 0 A_SpawnItemEx("Helmet", 0,0,0, 2,1,10, 0, SXF_SETMASTER) //Spawns a Helmet falling on the ground
TNT1 A 0 A_playsound(Bing_1)
TNT1 A 0 A_Remove(AAPTR_DEFAULT)
Stop
}
}
//Normal headshot
Actor HeadshotHitbox
{
Radius 7
Health 1
Height 10 //Größe der Hitbox in Z-Achse
Mass 0x7FFFFFFF
Species "GrayArmy"//Hitbox must not be shot by friendlys
+DONTTHRUST
+NORADIUSDMG
+NOGRAVITY
+SHOOTABLE
+NODAMAGETHRUST
+FLOORCLIP
States
{
Spawn:
TNT1 A 1 A_Warp(AAPTR_MASTER, 0,0,34, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
TNT1 A 0 A_CheckFlag("SOLID","Spawn",AAPTR_MASTER)
Hitbox_Remove:
TNT1 A 0 A_Remove(AAPTR_DEFAULT)
Stop
Death:
TNT1 AA 0 A_Killmaster
Stop
}
}
Main Actor
Code: Select all
//Headshot implement
Actor NoHelmethave : Inventory { Inventory.MaxAmount 1 } //Needed to check if actor has a helmet(animation)
ACTOR Grau_Gunny_Goat_Helmet 8050
{
Health 70
Radius 20
Height 34 //45 is about the height of the actor plus head hitbox
Speed 6
PainChance 170
Monster
Species "GrayArmy"
+DONTHARMSPECIES
+FLOORCLIP
+Dontharmclass
// SeeSound "G_Achtung"
PainSound "GG_Pain"
DeathSound "GG_Death"
ActiveSound "GG_Active"
Dropitem "Clip"
States
{
Spawn:
GGWH A 4 A_Look
TNT1 A 0 A_SpawnItemEx("Helm_HeadshotHitbox", 0,0,0, 0,0,0, 0, SXF_SETMASTER) //Spawns hitbox for helmet
TNT1 A 0 A_SpawnItemEx("HeadshotHitbox", 0,0,0,0,0,0, 0, SXF_SETMASTER) //Spawns hitbox for headshots
Spawned:
TNT1 A 0
TNT1 A 0 A_Jumpifinventory("NoHelmethave",1,"Nohelm")//Checks if actor has helmet
GGWH A 5 //Sprite with helmet
goto Spawned
Nohelm:
GGWH C 5 //Sprite without helmet
Goto Spawned
See:
Spawned:
TNT1 A 0
TNT1 A 0 A_Jumpifinventory("NoHelmethave",1,"Nohelm")//Checks if actor has helmet
GGWH A 5 //Sprite with helmet
goto Spawned
Nohelm:
GGWH C 5 //Sprite without helmet
Goto Spawned
Loop
Pain:
GGWH H 3
GGWH H 3 A_Pain
Goto See
Death:
GGWH I 5
GGWH J 5 A_Scream
GGWH K 5 A_NoBlocking
GGWH L 5
GGWH M -1
Stop
}
}
Very good tutorial, the code can be expanded to create helmets, which fly off when shot. Looks like this: https://www.youtube.com/watch?v=CJ4w6GKfqwg I could not figure out how to pass a var to a child actor, so I used a fake inventory actor. Code(commented): [spoiler]Im new to decorate, so please dont kill me :) Hitboxes [code]//helm headshot actor Actor Helm_HeadshotHitbox//A hitbox für helmets { Radius 9 //Radius of hitbox Health 1 Height 10 //Height of hitbox Mass 0x7FFFFFFF //Disables game physics +DONTTHRUST //Dont be thrusted by explosions +NORADIUSDMG //No splash damage +NOGRAVITY //Must not be affected by gravity +SHOOTABLE //Must be shootable +NODAMAGETHRUST //Must not be thrusted by damage States { Spawn: TNT1 A 1 A_Warp(AAPTR_MASTER, 0,0,34, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)//Attaches the hitbox on top of the torso TNT1 A 0 A_CheckFlag("SOLID","Spawn",AAPTR_MASTER) //Goes to "Spawn:" if master is solid Hitbox_Remove: TNT1 A 0 A_Remove(AAPTR_DEFAULT) //Deletes the Hitbox Stop Death: TNT1 A 0 A_GiveInventory("NoHelmethave",1,AAPTR_MASTER) //Indicates losing the helmet of master, needed for animation TNT1 A 0 A_SpawnItemEx("Helmet", 0,0,0, 2,1,10, 0, SXF_SETMASTER) //Spawns a Helmet falling on the ground TNT1 A 0 A_playsound(Bing_1) TNT1 A 0 A_Remove(AAPTR_DEFAULT) Stop } } //Normal headshot Actor HeadshotHitbox { Radius 7 Health 1 Height 10 //Größe der Hitbox in Z-Achse Mass 0x7FFFFFFF Species "GrayArmy"//Hitbox must not be shot by friendlys +DONTTHRUST +NORADIUSDMG +NOGRAVITY +SHOOTABLE +NODAMAGETHRUST +FLOORCLIP States { Spawn: TNT1 A 1 A_Warp(AAPTR_MASTER, 0,0,34, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION) TNT1 A 0 A_CheckFlag("SOLID","Spawn",AAPTR_MASTER) Hitbox_Remove: TNT1 A 0 A_Remove(AAPTR_DEFAULT) Stop Death: TNT1 AA 0 A_Killmaster Stop } }[/code] Main Actor [code] //Headshot implement Actor NoHelmethave : Inventory { Inventory.MaxAmount 1 } //Needed to check if actor has a helmet(animation) ACTOR Grau_Gunny_Goat_Helmet 8050 { Health 70 Radius 20 Height 34 //45 is about the height of the actor plus head hitbox Speed 6 PainChance 170 Monster Species "GrayArmy" +DONTHARMSPECIES +FLOORCLIP +Dontharmclass // SeeSound "G_Achtung" PainSound "GG_Pain" DeathSound "GG_Death" ActiveSound "GG_Active" Dropitem "Clip" States { Spawn: GGWH A 4 A_Look TNT1 A 0 A_SpawnItemEx("Helm_HeadshotHitbox", 0,0,0, 0,0,0, 0, SXF_SETMASTER) //Spawns hitbox for helmet TNT1 A 0 A_SpawnItemEx("HeadshotHitbox", 0,0,0,0,0,0, 0, SXF_SETMASTER) //Spawns hitbox for headshots Spawned: TNT1 A 0 TNT1 A 0 A_Jumpifinventory("NoHelmethave",1,"Nohelm")//Checks if actor has helmet GGWH A 5 //Sprite with helmet goto Spawned Nohelm: GGWH C 5 //Sprite without helmet Goto Spawned See: Spawned: TNT1 A 0 TNT1 A 0 A_Jumpifinventory("NoHelmethave",1,"Nohelm")//Checks if actor has helmet GGWH A 5 //Sprite with helmet goto Spawned Nohelm: GGWH C 5 //Sprite without helmet Goto Spawned Loop Pain: GGWH H 3 GGWH H 3 A_Pain Goto See Death: GGWH I 5 GGWH J 5 A_Scream GGWH K 5 A_NoBlocking GGWH L 5 GGWH M -1 Stop } }[/code][/spoiler]