• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved Problem with onkillscript

Question that is answered or resolved.

dantedevil

Well-known member
I have a boss (Balrog) and set the onkillscript in the header txt.

Code:
onspawnscript data/chars/balrog/balrog.c
onkillscript data/chars/balrog/balrog2.c
animationscript data/scripts/escript.c

As you see, he have onspawnscript too.

The onspawnscript works ok, I used several times without problems.
Now I want use the onkillscript, but not work.

I kill Balrog and the script never shows and the sytem seems works ok, with any errors.
I try setting the blarog2.c (onkillscript), in the onspawnscript and the script dialog it's ok.
Try to set the onkillscript in other character, and not work again.
Testing more, I see something is wrong. Because if I set the line:

onkillscript data/chars/balrog/balrog2.c

Ths script not work, but if quit the game and select the new game again, the menu works bad.
The statues not explode when select a character, then when the game start you can se the frames of the stone explosion over the stage background.

If remove the "onkillscript data/chars/balrog/balrog2.c", all works ok again.

What happend here?
 
Last edited:
Solution
Alhamdullilah, I got it working :)

First you need this entity:

Code:
name    	Bosser
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   =...
Just to make sure :

onkillscript => triggered when entity kills another entity
ondeathscript => triggered when entity is killed (by another entity)
 
Piccolo said:
Just to make sure :

onkillscript => triggered when entity kills another entity
ondeathscript => triggered when entity is killed (by another entity)

ondeathscript => triggered exact moment when enemy is killed, during the first frame of the fall.
This works ok for me.

onkillscript => triggered after the death animation.
This not working  for me.
 
Piccolo said:
Just to make sure :

onkillscript => triggered when entity kills another entity
ondeathscript => triggered when entity is killed (by another entity)

You are right about ondeathscript, but not onkillscript.

onkillscript fires when the entity is actually removed from the play. For example, if you are using the default death behavior, onkillscript is run when the entity finishes flashing and disappears.

DC
 
Well, finally find the error.
Seems the onkillscript can't work if the enemy has set NODIEBLINK 3 in one of his deaths animations.
I change all NODIEBLINK 3 for 2 and now works ok.
Here the new problem,  the onkillscript work only with nornal enemies.
I mean, If the enemy it's a boss not work.

spawn balrog
boss 1
coords 490 240
at 1500

So ca be possibble spawn the dialogs in the last frame of the death animation?
 
Damon Caskey said:
Piccolo said:
Just to make sure :

onkillscript => triggered when entity kills another entity
ondeathscript => triggered when entity is killed (by another entity)

You are right about ondeathscript, but not onkillscript.

onkillscript fires when the entity is actually removed from the play. For example, if you are using the default death behavior, onkillscript is run when the entity finishes flashing and disappears.

DC

Indeed, my bad  :-[
 
dantedevil, let me confirm this: you want Balrog to spawn dialogues after his death right?

If that's true, then it's best not to use boss 1, spawn the dialogues normally and use script to replicate slow motion effect
 
Yes,  I want spawn the dialogs after his death.
I think in that solution, but the only problem to make Balrog work like a boss without use boss 1,  is when Balrog dies the others enemies dont.
It's a way to solve that?
I mean all the enemies in the screen must dies at the same time of Balrog,  and reinforcements enemies ready to enter too. Thats the only way to simulate the boss behaviour.
 
Alhamdullilah, I got it working :)

First you need this entity:

Code:
name    	Bosser
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_NORMAL"));
        }
      } 
      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.gif
	delay	300 # slowmotion effect will be active for 3 seconds
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

anim spawn
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif

This entity will activate and deactive slowmotion effect, kill remaining enemies and set sign (with indexed variable) to remove other enemies before removing itself

Here's an example on how to set it in level :

Code:
spawn	Amazon2
alias Boss
health	400
flip	1
map	1
item	bosser # <--- have the boss drop it on her death
coords	160 200 300
at	120

group	3 3
at	0

spawn	Soldier2
coords	360 170
at	0

spawn	Soldier2
coords	370 260
at	0
# I didn't declare script to the former 2 soldier2s as they are guaranteed to appear
spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-40 170
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-50 260
at	0
#
spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
coords	360 170
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
coords	370 260
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-40 170
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-50 260
at	0
#
spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
coords	360 170
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
coords	370 260
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-40 170
at	0

spawn	Soldier2
@script
void main()
{
    void self = getlocalvar("self");
    int Kill = getindexedvar("Dead");
    
    if(Kill == 1){
      killentity(self);
    }
}
@end_script
flip	1
coords	-50 260
at	0
#

group	1 1
at	0

spawn	Delay
health	20
coords	160 200
at	0

That sign will be read by the unspawned-yet enemies and be used to remove themselves. After all of them are removed, the delay entity at the end will be spawned. You can spawn dialogue or anything prior to delay if needed :)

I forget if you already use endlevel.c or not but you need it to stabilize the effect. Here's the script:
Code:
void main()
{
  changeopenborvariant("slowmotion", 0);
  setindexedvar("Dead", NULL());
}

If you have one, then just add those two lines there

HTH
 
Solution
You're welcome :D

I forget to tell you that boss 1 command does more than just slowing down and killing remaining enemies such as stopping the screen from scrolling and set invincibility to players. However, I dislike the former and the latter is kinda redundant to set

Last but not least, unlike that command, you can use this method for subboss in middle of level without ending the level ;)
 
Bloodbane
Thank you for the link, this is likely the solution I need
before I start to use it I need to know where should I put "killentity soldier2 code"?
since in my case Boss spawn backup from follow animation, so I don't have spawn enemy in level.txt

Code:
name	damnd
health 144
speed	12
type	enemy


anim	    follow2
	loop	0
	delay	1
	offset	85 173
	frame	data/chars/damnd/ju0.gif
	delay	10
	frame	data/chars/damnd/ju1.gif
	frame	data/chars/damnd/ju2.gif
	frame	data/chars/damnd/ju3.gif
	frame	data/chars/damnd/ju4.gif
	frame	data/chars/damnd/ju1.gif
	frame	data/chars/damnd/ju2.gif
	frame	data/chars/damnd/ju3.gif
	delay	20
	frame	data/chars/damnd/ju4.gif
	delay	1
	offset	85 173
	frame	data/chars/damnd/whistle_wall00a.gif
	delay	300
	offset	85 173
	frame	data/chars/damnd/whistle_wall00a.gif
	delay	30
	frame	data/chars/damnd/whistle_wall01a.gif
	delay	50
	sound	data/sounds/whistle.wav
	@cmd	spawn01 "holly_wood_60" -200 183 -1553
	frame	data/chars/damnd/whistle_wall02a.gif
	@cmd	spawn01 "bred_28" -200 183 -1553
	@cmd	spawn01 "j_28_B1" -650 0 197
	@cmd	spawn01 "dug_41_B1" -650 0 216
	delay	300
	frame	data/chars/damnd/whistle_wall00a.gif
	@cmd	changeState "FOLLOW3"
 
  You're welcome :)

The kill remaining enemies are only used if you have enemies waiting to be spawned as boss' backups. If you don't have any and you can ensure that all enemies are around just before boss is killed, you don't need to script to kill the soldier2 or backups.
 
Back
Top Bottom