Projectile remove issue

msmalik681

OpenBOR Developer
Staff member
I have a issue with a knife entity. I have "Remove 1" flag in the entity header and when the enemy throws the knife it will be removed on hit as expected but when a player throws the same weapon it will fly through all enemies.  I found a work around using followanim & followcond but this seems to be a engine bug has anyone else had this issue ?

weapon entity:
Code:
name		Knife_Throw
type		none
antigravity	100
remove		1
shadow		0
candamage	enemy player
offscreenkill	200
no_adjust_base  0
subject_to_wall	1
subject_to_platform 1
subject_to_hole 1
subject_to_obstacle 1

animationscript data/scripts/0_scripts.openbor
onblockWscript data/scripts/bounceoff.openbor
onblockoscript data/scripts/bounceoff.openbor
onblockpscript data/scripts/bounceoff.openbor

anim	spawn
	loop	0
	offset	15 5
	delay	3
	frame	data/chars/misc/knife.gif
	@cmd	name2ani
	frame	data/chars/misc/knife.gif

anim	idle
	loop	0
	Delay	1
	offset	15 5
	Attack	0 0 24 7 10 1 0 0 10
	followanim 2
	followcond 1
	frame	data/chars/misc/knife.gif
	@cmd	dasher 3.5 0 0
	frame	data/chars/misc/knife.gif
	
anim	follow2
	loop	0
	Delay	1
	frame	data/chars/misc/empty.gif
	@cmd	killentity getlocalvar("self")
	frame	data/chars/misc/empty.gif

anim	follow1
	loop	0
	Delay	5
	offset	17 18
	jumpframe 0 2 0.5 0
	landframe 11
	@cmd	changeentityproperty getlocalvar("self") "antigravity" 0
	frame	data/chars/misc/knife/spin01.gif
	frame	data/chars/misc/knife/spin02.gif
	frame	data/chars/misc/knife/spin03.gif
	frame	data/chars/misc/knife/spin04.gif
	frame	data/chars/misc/knife/spin05.gif
	frame	data/chars/misc/knife/spin06.gif
	frame	data/chars/misc/knife/spin07.gif
	frame	data/chars/misc/knife/spin08.gif
	frame	data/chars/misc/knife/spin01.gif
	frame	data/chars/misc/knife/spin02.gif
	delay	999
	frame	data/chars/misc/knife/spin03.gif
	sound	data/sounds/knife_drop.wav
	@cmd	spawn01 "Knife" 0 0 0
	@cmd	killentity getlocalvar("self")
	frame	data/chars/misc/knife/spin04.gif
 
Normally this has to do with how you do spawn/throw the knife. It normally works if you spawn it with "custknife" and "throwframe" but it does not work if you spawn it with script. Because when you spawn it with script the engine obviously does not recognize it as a "knife" so the remove command can't work. So, it's not a bug in such case.
 
Hi msmalik681!

I have an alternative way to throw weapons and "Remove 1" works fine both for players and enemies. I don't use "throwframe" to throw weapons because in the scripted form I can adjust the x,y,z position/velocity freely and other properties too. The the "throwframe" command is here only for change from weapon models to default models, the scripted way to do this is bad. And the antiwall script is here because if the entity is too close from walls in x or z axis, the throwned weapon will disappear.

I hope this can help you. Here is the code:

Knife entity
Code:
name			knifeT #THROWNED
type			none
subtype			weapon
nolife			1
lifespan		6
remove			1
noquake 		1
gfxshadow		1 1
noatflash 		1
flash			metalflash
didhitscript	data/scripts/didhit/weapons.c
animationscript	data/scripts/animation/animation.c

anim idle
	attackone 1
	fastattack 1
	jugglecost 5
	forcedirection -1
	hitflash blood
	loop	0
	delay	1
	offset	25 27
	bbox 	16 24 19 3
	hitfx	data/sounds/Cutter.wav
	attack 16 24 19 3 8 1 0 0 0 12
	frame	data/chars/weapons/knife09.gif
	sound	data/sounds/Whoosh.wav
	frame	data/chars/weapons/knife09.gif
	
anim fall
	landframe 9
	loop	1 1 9
	delay	2
	offset	25 27
	@cmd leaper -1 2 0
	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

Player animation for throwned knife
Code:
anim attackboth #THROW KNIFE
	throwframe 1 9999
	loop	0
	delay	8
	offset	62 126
	@cmd antiwall 20 -20 -1
	frame	data/chars/axel/knife/a100.gif
	@cmd throWeapon 48 48 -1 3 0 0
	frame	data/chars/axel/knife/a102.gif
	frame	data/chars/axel/knife/a103.gif

Animation script for throwned knife
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 ENTITY NAME)
	void self 	= getlocalvar("self");
	void candamage	= getentityproperty(self, "candamage");
	void weapon 	= getentityproperty(self, "weapnum");
	int Direction 	= getentityproperty(self, "direction");
	int x 		= getentityproperty(self, "x");
	int y 		= getentityproperty(self, "y");
	int z 		= getentityproperty(self, "z");
	void vShot;
	
	if(Direction == 0){ //Is entity facing left?                  
		dx = -dx; //Reverse X direction to match facing
	}

	vShot = projectile(weapon, x+dx, z+dz, y+dy, Direction, 0, 0, 0); //Generate entity using "projectile", not "spawn"
	changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
	changeentityproperty(vShot, "speed", Vx); //"X" Speed control
	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
	
	return vShot;
}

Player header config
Code:
##LOADS
knife knifeT
 
Back
Top Bottom