Thrown weapons have no attack box

pbbopenbor

New member
I'm trying to understand how thrown weapons work. I have a weapon definition:
Code:
name			knifeT #THROWNED
type			none
subtype			weapon
nolife			1
lifespan		4
remove			1
gfxshadow		1 1
noatflash 		1
flash			noflash

anim idle
	attackone 1
	fastattack 1
	jugglecost 5
	forcedirection -1
	hitflash bloodhit
	loop	0
	delay	1
	offset	25 27
	bbox 	16 25 19 3
	hitfx	data/sounds/Cutter.wav
	attack 16 25 19 3 8 1 0 0 10 12
	frame	data/chars/weapons/knife07.gif
	sound	data/sounds/Whoosh.wav
	attack 16 25 50 50 8 1 0 0 10 12
	frame	data/chars/weapons/knife07.gif
	
anim fall
	landframe 9
	loop	1 1 9
	delay	2
	offset	25 27
	sound	data/sounds/Clash.wav
	frame	data/chars/weapons/knife00.gif
	sound	data/sounds/Whoosh.wav
	frame	data/chars/weapons/knife00.gif
	frame	data/chars/weapons/knife01.gif
	frame	data/chars/weapons/knife02.gif
	frame	data/chars/weapons/knife03.gif
	frame	data/chars/weapons/knife04.gif
	frame	data/chars/weapons/knife05.gif
	frame	data/chars/weapons/knife06.gif
	frame	data/chars/weapons/knife07.gif
	frame	data/chars/weapons/knife08.gif

I can throw the weapon easily enough using throwframe. However the weapon never hits anything. I can see it has a bounding box but it doesn't appear to have any attack box when using the debug tools.
 
It seems I'd forgotten to put
Code:
load	Knife				data/chars/weapons/knife.txt
load	KnifeT				data/chars/weapons/knifeT.txt
in models.txt which seemed to cause it to use the knife entity instead of knifet entity when thrown and knife didn't have a hit box. Roughly working version of a knife you can pick up and throw for future reference

mary.txt
Code:
name	Mary
health	100
speed	9
type	player
shadow	3
running 25 3 2 1 1
diesound data/sounds/eek.wav
projectilehit enemy player
candamage enemy npc obstacle
icon	data/chars/mary/icon.gif
grabturn 0
holdblock 2
blockback 1
weapons mary_knife none none none none mary

mary_knife.txt
Code:
name				Mary_Knife
type				none
atchain				1
candamage enemy
projectilehit enemy
knife knifeT
animationscript	 	data/scripts/animation.c

anim attack1 #THROW KNIFE
	throwframe 1 9999
	loop	0
    offset	33 98
	bbox	34 24 19 93
	delay	8
	#attack	41 10 28 25 5
    frame data/chars/mary/knee1.gif
	@cmd throWeapon 76 43 -1 3 0 0
    frame data/chars/mary/knee2.gif

animation.c
Code:
void throWeapon(float dx, float dy, float dz, float Vx, float Vy, float Vz)
{//Shoot entity with defined conditions (DEFAULT SHOOT SCRIPT FOR PROJECTILES, USING HOLDING WEAPON INSTEAD OF WEAPON NAME)
	void self 		= getlocalvar("self");
	void type		= getentityproperty(self, "type");
	void candamage	= getentityproperty(self, "candamage");
	void weapon 	= getentityproperty(self, "weapnum");
	void vShot;
	int direction 	= getentityproperty(self, "direction");
	int x 			= getentityproperty(self, "x");
	int y 			= getentityproperty(self, "y");
	int z 			= getentityproperty(self, "z");
	float offense	= getentityproperty(self, "offense", 0);
	
	if(direction == 0){dx = -dx;}

	vShot = projectile(weapon, x+dx, z+dz, y+dy, direction, 0, 0, 0); //GENERATE ENTITY USING "PROJECTILE", NOT "SPAWN"
	changeentityproperty(vShot, "speed", Vx); //"X" SPEED CONTROL
	changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
	changeentityproperty(vShot, "parent", self); //SET TO PARENT
	changeentityproperty(vShot, "candamage", candamage); //COPY "SELF" CANDAMAGE PROPERTY
	changeentityproperty(vShot, "subject_to_platform", 0); //SET SUBJECT_TO_PLATFORM TO 0
	changeentityproperty(vShot, "offense", openborconstant("ATK_NORMAL"), offense);
	changeentityproperty(vShot, "offense", openborconstant("ATK_NORMAL2"), offense);
	changeentityproperty(vShot, "offense", openborconstant("ATK_NORMAL6"), offense);
	changeentityproperty(vShot, "offense", openborconstant("ATK_BURN"), offense);
	changeentityproperty(vShot, "offense", openborconstant("ATK_SHOCK"), offense);
	
	//IS ENTITY A ENEMY TYPE?
	if(type == openborconstant("TYPE_ENEMY")){changeentityproperty(vShot, "type", openborconstant("TYPE_SHOT"));}
	
	return vShot;
}

knife.txt
Code:
name			knife #GROUND
type			item
subtype			weapon
candamage		enemy npc
nolife			1
typeshot 		0
weapnum			1
shootnum 		1
counter			3
gfxshadow		1 1
offscreenkill	50
#animationscript	data/scripts/animation/default.c

anim idle
	loop	1
	delay	200
	offset	25 27
	bbox 	16 24 19 3
	#nodrawmethod
	frame	data/chars/weapons/knife08.gif
		delay	6
	#drawmethod tintmode 1
	#drawmethod tintcolor 150_150_150
	frame	data/chars/weapons/knife08.gif

anim fall
	loop	1
	delay	200
	offset	25 27
	bbox 	16 24 50 50 30
	attack	41 10 28 25 10 1
	#nodrawmethod
	frame	data/chars/weapons/knife08.gif
		delay	6
	#drawmethod tintmode 1
	#drawmethod tintcolor 150_150_150
	frame	data/chars/weapons/knife08.gif
	
anim follow1
	landframe 8
	loop	1 0 8
	delay	2
	offset	25 27
	itembox 10023 10023 5 5
	#sound	data/sounds/Whoosh.wav
	#@cmd wall 0
	frame	data/chars/weapons/knife00.gif
	frame	data/chars/weapons/knife01.gif
	frame	data/chars/weapons/knife02.gif
	frame	data/chars/weapons/knife03.gif
	frame	data/chars/weapons/knife04.gif
	frame	data/chars/weapons/knife05.gif
	frame	data/chars/weapons/knife06.gif
	frame	data/chars/weapons/knife07.gif
	#@cmd wall 1
	#@cmd antiWall 40 -40 -1
	#@cmd aniChange 1 "ANI_IDLE"
	frame	data/chars/weapons/knife08.gif

knifet.txt
Code:
name			knifeT #THROWNED
type			item
subtype			weapon
nolife			1
lifespan		4
remove			1
gfxshadow		1 1
noatflash 		1
flash			noflash
#didhitscript	data/scripts/didhit/default.c
#ondrawscript	data/scripts/ondraw/weapons.c
#onfallscript	data/scripts/onfall/weapons.c
#animationscript	data/scripts/animation.c

anim idle
	attackone 1
	fastattack 1
	jugglecost 5
	forcedirection -1
	hitflash bloodhit
	loop	0
	delay	1
	offset	25 27
	bbox 	16 25 19 3
	hitfx	data/sounds/Cutter.wav
	attack 16 25 19 3 8 1 1 0 10 12
	frame	data/chars/weapons/knife07.gif
	sound	data/sounds/Whoosh.wav
	frame	data/chars/weapons/knife07.gif
	
anim fall
	landframe 9
	loop	1 1 9
	delay	2
	offset	25 27
	sound	data/sounds/Clash.wav
	frame	data/chars/weapons/knife00.gif
	sound	data/sounds/Whoosh.wav
	frame	data/chars/weapons/knife00.gif
	frame	data/chars/weapons/knife01.gif
	frame	data/chars/weapons/knife02.gif
	frame	data/chars/weapons/knife03.gif
	frame	data/chars/weapons/knife04.gif
	frame	data/chars/weapons/knife05.gif
	frame	data/chars/weapons/knife06.gif
	frame	data/chars/weapons/knife07.gif
	frame	data/chars/weapons/knife08.gif
 
The knife weapons delay is less than a second , so the hit box disappears immediately,  no? Also it's loop is set to 0?
Wouldn't you want that to be set to 1?
 
PS VITA said:
The knife weapons delay is less than a second , so the hit box disappears immediately,  no? Also it's loop is set to 0?
Wouldn't you want that to be set to 1?

If I understand the stuff I've copied correctly it throws the built in "knife" engine projectile off screen because it's properties aren't very configurable. It then uses throWeapon to generate a new projectile of "knifet" type. Because the animation sets an attack box but never clears it then the attack box persists for the life time of the projectile. Basically loop 0 means that whatever state the entity is in at the end of the animation it stays in that state till a new animation is played.
 
Back
Top Bottom