Healing Orb [SOLVED]

Hello again, fellow developers!

I'm making a new move for one of my characters: a healing orb spell.
Upon casting, the character spawns a healing orb that restores 20 HP upon contact.

Instead of dealing with complicated attack types for such effect, i decided to simply make the char to spawn an item with subtype touch... But it isn't working at all. The orb doesn't detect any touching, and just floats there ad infinitum


Here's the object spawning script that I'm using (even with changes related to items)
Code:
void spawnentity(void cName, void cAni, float fX, float fY, float fZ, float vX, float vY, float vZ)
{
  void self = getlocalvar("self");											//get calling entity.
  void Child;																//Spawned child entity.
  void ChildType;
	int pDirection = getentityproperty(self, "direction");					//parent's facing direction.
	int pPal = getentityproperty(self, "map");								//parent's pallette.

  clearspawnentry();														//Clear current spawn entity.
  setspawnentry("name", cName);												//Set spawn entity by it's name.

  if (pDirection ==0)														//is parent facing left?
  {
    fX = -fX;
    vX = -vX;																//Reverse x Direction to match facing.
  }

	fX = fX + getentityproperty(self, "x");
	fY = fY + getentityproperty(self, "a");
	fZ = fZ + getentityproperty(self, "Z");

	Child = spawn();														//Spawn child entity.
	ChildType = getentityproperty(Child, "type");
	if (ChildType != "TYPE_ITEM")
	{
		changeentityproperty(Child, "parent", self);						//Set child's parent.
		changeentityproperty(Child, "owner", self);							//Set child's owner.
	}
	
	changeentityproperty(Child, "position", fX,fZ,fY);						//Set spawn location.
	changeentityproperty(Child, "direction", pDirection);					//Inherit Parent's facing direction.
	changeentityproperty(Child, "velocity", vX, vZ, vY);					//Set child velocity.
	changeentityproperty(Child, "map", pPal);								//Set child pallette.
	performattack(Child, openborconstant(cAni), 1);							//Perform set animation.
	return Child;
}

Here's the healing orb file:
(the SFX_HEAL are just particles, ignore them)
Code:
name		HealOrb
health		20

type		item
subtype		touch
antigravity	100
gfxshadow	1
nolife		1

alpha		5

animationscript	data/scripts/items_animationscript.c

anim idle
	loop	1 5
	offset	7 7

	delay	3
	drawmethod	scale 0.2 0.2
	frame	data/items/healorb/healorb_00.png
	drawmethod	scale 0.4 0.4
	frame	data/items/healorb/healorb_00.png
	drawmethod	scale 0.6 0.6
	frame	data/items/healorb/healorb_00.png
	drawmethod	scale 0.8 0.8
	frame	data/items/healorb/healorb_00.png
	nodrawmethod
	frame	data/items/healorb/healorb_00.png

	itembox 0 0 16 16
	bbox	0 0 16 16

	@cmd	spawnentity "SFX_Heal" "ANI_FOLLOW11" 0 0 0 0 0 0 
	frame	data/items/healorb/healorb_00.png
	frame	data/items/healorb/healorb_00.png
	@cmd	spawnentity "SFX_Heal" "ANI_FOLLOW11" 0 0 0 0 0 0 
	frame	data/items/healorb/healorb_00.png
	frame	data/items/healorb/healorb_00.png
	@cmd	spawnentity "SFX_Heal" "ANI_FOLLOW11" 0 0 0 0 0 0 
	frame	data/items/healorb/healorb_00.png
	frame	data/items/healorb/healorb_00.png
	@cmd	spawnentity "SFX_Heal" "ANI_FOLLOW11" 0 0 0 0 0 0 
	frame	data/items/healorb/healorb_00.png
	frame	data/items/healorb/healorb_00.png

	@cmd	spawnentity "SFX_Heal" "ANI_FOLLOW11" 0 0 0 0 0 0 
	frame	data/items/healorb/healorb_01.png
 
From a quick look i can say that you should remove the bbox command and use only the itembox command instead. Itembox is meant for use for "subtype touch" items and bbox is for anything else. But you cannot use both in same time.
 
bbox removed, no results so far.

EDIT: Now enemies are able to get the orb, and, if the player dies, the orb becomes gettable.
EDIT: Just made a test; if i removed the parenting/owning issue from my spawnentity script, the orb works as intended. But now i face another issue:

The IF below seems to be ignored by my code, which was the whole issue:
Code:
	ChildType = getentityproperty(Child, "type");
	if (ChildType != "TYPE_ITEM")
	{
		changeentityproperty(Child, "parent", self);						//Set child's parent.
		changeentityproperty(Child, "owner", self);							//Set child's owner.
	}
What's wrong in this if?
 
have it on my mod, just spawn an enemy tipe entity with -10 or so attack damage, set empty sprite long delay at end of the attack anim and adjust lifespan, no script needed
 
Paulo HP Bender said:
The IF below seems to be ignored by my code, which was the whole issue:

Code:
    ChildType = getentityproperty(Child, "type");
    if (ChildType != "TYPE_ITEM")
    {
        changeentityproperty(Child, "parent", self);                        //Set child's parent.
        changeentityproperty(Child, "owner", self);                            //Set child's owner.
    }
What's wrong in this if?

Just typing text like "TYPE_ITEM" is well, just text. Obviously the model type will never, ever match that. You need to get the constant like this: openborconstant("TYPE_ITEM")

C:
ChildType = getentityproperty(Child, "type");
    if (ChildType != openborconstant("TYPE_ITEM"))
    {
        changeentityproperty(Child, "parent", self);                        //Set child's parent.
        changeentityproperty(Child, "owner", self);                            //Set child's owner.
    }
 
Back
Top Bottom