Adapt simple script to script.c

dantedevil

Well-known member
I have an entity called "Zangief0", then this enemy spawn "Zangief".

I want "Zangief" spawn the entity "bosser2" when dies.

So I try to convert this in a zangief.c:
Code:
name    	Bosser2
type		none


anim idle
@script
    if(frame==1){
      void vEntity;                                     //Target entity placeholder.
      int  iEntity;                                     //Entity enumeration holder.
      int  iType;                                       //Entity type.
      int  iHP;                                         //Entity HP
      int  iMax      = openborvariant("ent_max");       //Entity count.

       //Enumerate and loop through entity collection.
      for(iEntity=0; iEntity<iMax; iEntity++){    
        vEntity = getentity(iEntity);                 //Get target entity from current loop.
        iType   = getentityproperty(vEntity, "type"); //Get target type.
        iHP   = getentityproperty(vEntity, "health"); //Get target health

        //Enemy type?
        if (iType == openborconstant("TYPE_ENEMY") && iHP > 0){
          damageentity(vEntity, vEntity, 2000, 1, openborconstant("ATK_NORMAL60"));
        }
      } 
      changeopenborvariant("slowmotion", 1);
      setindexedvar("Dead", 1);
    }
    if(frame==2){
      void self = getlocalvar("self");
      changeopenborvariant("slowmotion", 0);
      killentity(self);
    }
@end_script
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.png
	delay	200 # slowmotion effect will be active for 2 seconds
	frame	data/chars/misc/empty.png
	frame	data/chars/misc/empty.png

Here my try but not work:

Code:
void main()
{
      void vEntity;                                     //Target entity placeholder.
      int  iEntity;                                     //Entity enumeration holder.
      int  iType;                                       //Entity type.
      int  iHP;                                         //Entity HP
      int  iMax      = openborvariant("ent_max");       //Entity count.

       //Enumerate and loop through entity collection.
      for(iEntity=0; iEntity<iMax; iEntity++){    
        vEntity = getentity(iEntity);                 //Get target entity from current loop.
        iType   = getentityproperty(vEntity, "type"); //Get target type.
        iHP   = getentityproperty(vEntity, "health"); //Get target health

        //Enemy type?
        if (iType == openborconstant("TYPE_ENEMY") && iHP > 0){
          damageentity(vEntity, vEntity, 2000, 1, openborconstant("ATK_NORMAL60"));
        }
      } 
      changeopenborvariant("slowmotion", 1);
      setindexedvar("Dead", 1);
    }
}

Log error:
Code:
Script error: data/chars/zangief/zangief.c, line 23: Invalid external declaration '}' (in production 'external_decl')

}
^

**************** Done *****************

Failed to parse script file: 'data/chars/zangief/zangief.c'!
 
msmalik681 said:
seems like you over thought this one just use a simple "@cmd spawn" line in the death animation.

I know that, but I want the entity is spawn in the first frame of the fall, because the enemy have falldie 2.

But no problem, finally I can make it work:

Code:
void main()
{
      void vEntity;                                     //Target entity placeholder.
      int  iEntity;                                     //Entity enumeration holder.
      int  iType;                                       //Entity type.
      int  iHP;                                         //Entity HP
      int  iMax      = openborvariant("ent_max");       //Entity count.

       //Enumerate and loop through entity collection.
      for(iEntity=0; iEntity<iMax; iEntity++){    
        vEntity = getentity(iEntity);                 //Get target entity from current loop.
        iType   = getentityproperty(vEntity, "type"); //Get target type.
        iHP   = getentityproperty(vEntity, "health"); //Get target health

        //Enemy type?
        if (iType == openborconstant("TYPE_ENEMY") && iHP > 0){
          damageentity(vEntity, vEntity, 2000, 1, openborconstant("ATK_NORMAL60"));
        }
      } 
      changeopenborvariant("slowmotion", 1);
      setindexedvar("Dead", 1);
    }

Now only need to know how adapt this part.

    if(frame==2){
      void self = getlocalvar("self");
      changeopenborvariant("slowmotion", 0);
      killentity(self);
    }
 
That script part you're trying to adapt requires some time before running it, that's why it's run at 3rd frame
IOW you can't run it at same time unless you're cancelling the slowmotion feature
 
I've analyzed your edited script and I noticed that you enabled slowmotion in a script which runs a hit all enemies
I can't guess what script nor what mechanic you're trying to achieve here
Can you tell me what is exactly you're trying to achieve with this merging?
 
I want adapt the script of this entity,  to a file zangief.c to use in an ondeathscript.
Code:
name    	Bosser2
type		none

anim idle
@script
    if(frame==1){
      void vEntity;                                     //Target entity placeholder.
      int  iEntity;                                     //Entity enumeration holder.
      int  iType;                                       //Entity type.
      int  iHP;                                         //Entity HP
      int  iMax      = openborvariant("ent_max");       //Entity count.

       //Enumerate and loop through entity collection.
      for(iEntity=0; iEntity<iMax; iEntity++){    
        vEntity = getentity(iEntity);                 //Get target entity from current loop.
        iType   = getentityproperty(vEntity, "type"); //Get target type.
        iHP   = getentityproperty(vEntity, "health"); //Get target health

        //Enemy type?
        if (iType == openborconstant("TYPE_ENEMY") && iHP > 0){
          damageentity(vEntity, vEntity, 2000, 1, openborconstant("ATK_NORMAL60"));
        }
      } 
      changeopenborvariant("slowmotion", 1);
      setindexedvar("Dead", 1);
    }
    if(frame==2){
      void self = getlocalvar("self");
      changeopenborvariant("slowmotion", 0);
      killentity(self);
    }
@end_script
	loop	1
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.png
	delay	200 # slowmotion effect will be active for 2 seconds
	frame	data/chars/misc/empty.png
	frame	data/chars/misc/empty.png
 
Ah I see, if that's what you want then the best way is to simply spawn bosser entity on Zangief's death. If he has DEATH animation, you can just spawn it there but if not you need to run spawn function such as spawn01 function
That's how to do it since bosser entity can do the timer part before turning off slowmotion effect
 
Bloodbane said:
Ah I see, if that's what you want then the best way is to simply spawn bosser entity on Zangief's death. If he has DEATH animation, you can just spawn it there but if not you need to run spawn function such as spawn01 function
That's how to do it since bosser entity can do the timer part before turning off slowmotion effect
Oh yes my friend, that was my first option to solve this.
I just want learn other way to make this, and learn how adapt the script of this entity to an scipt.c is a good start.

Thanks anyway!
 
Back
Top Bottom