Conditional Entity

It's possible to do that but the question is what for? what is it that you're trying to achieve?
Hi Bloodbane thank you for responding to my question. I am trying to have Spawn a different Boss depending on the Player selected. I am thinking this can be achived by script where I included both bosses on the my level.txt and then using the Killentity(entity) line to have that Boss disappear depending on the Player entering that level. I am having trouble writing that script. Any advice you could provide would be much appreciated.
 
I think I get what you want but let me confirm this:
If player 1 plays as A, the boss who would appear would be BA but if player 1 plays as B, the boss would be BB, right?

My question is if there were 2 players and each play as A and B, which boss would appear? or which player defines the boss? or would there be special boss if there were 2 players?
 
The Level will check to see if either P1 or P2 is that specific character and then Spawn that new Boss or Just Spawn the regular Boss. I tried using the Spawn a Special Intro Code that is out there but am having limited success. Here is the code I tried using below.

spawn Wildchild
@script
void main()
{
int P1 = getplayerproperty(0, "name");
int P2 = getplayerproperty(1, "name");
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iName; //Entity name.
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.
iName = getentityproperty(vEntity, "defaultname"); //Get target name
if(iName == "Wildchild" && P1 == "Guardian"){
//changeentityproperty(vEntity, "direction", 1); //Face right
changeentityproperty(vEntity, "animation", openborconstant("ANI_FOLLOW60"));

}
}}
@end_script
#map 1
health 120
coords 0 150
at 0
 
  • Like
Reactions: ABK
I think it would be better with this:
Code:
spawn    Boss1
@script
void main()
{
  int P1 = getplayerproperty(0, "name");
  int P2 = getplayerproperty(1, "name");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName=="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

spawn    Boss2
@script
void main()
{
  int P1 = getplayerproperty(0, "name");
  int P2 = getplayerproperty(1, "name");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName!="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

This script will remove Boss1 if player 1 is Guardian but will remove Boss2 instead if player 1 isn't Guardian.
The script could check player 2 if player 1 isn't available but if both are in, then player 1 will define the boss.
I haven't tested this but try this and see if it works :)
 
Hi Bloodbane,
Thank you again for the dode assist. I only made one slight modification after getting an error message. I am highlighting bellow. Thank you again for the help!


I think it would be better with this:
Code:
spawn    Boss1
@script
void main()
{
  int P1 = getplayerproperty(0, "entity");
  int P2 = getplayerproperty(1, "entity");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName=="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

spawn    Boss2
@script
void main()
{
  int P1 = getplayerproperty(0, "entity");
  int P2 = getplayerproperty(1, "entity");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName!="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

This script will remove Boss1 if player 1 is Guardian but will remove Boss2 instead if player 1 isn't Guardian.
The script could check player 2 if player 1 isn't available but if both are in, then player 1 will define the boss.
I haven't tested this but try this and see if it works :)
 
@Bloodbane,

is there a way to feature @cmd OR function-like type deal on level .txt files
example:
Code:
spawn    Boss1
@cmd    conditionalboss
#map    1
health    120
coords    0 150
at    0
instead of the current inline-ish script stuff?

i noticed that NS has some levels that feature this entity-like script calling using this:
levelscript data/bgs/lv1/lv1.c
or
updatescript data/scripts/dropdead.c
 
Well, you can use spawnscript to replace inline script like the above.
Code:
spawn    Boss1
spawnscript data/scripts/bossplay.c
#map    1
health    120
coords    0 150
at    0

I rarely use this cause it's only useful for generic purpose scripts.
 
Well, you can use spawnscript to replace inline script like the above.
Code:
spawn    Boss1
spawnscript data/scripts/bossplay.c
#map    1
health    120
coords    0 150
at    0

I rarely use this cause it's only useful for generic purpose scripts.

I think it would be better with this:
Code:
spawn    Boss1
@script
void main()
{
  int P1 = getplayerproperty(0, "name");
  int P2 = getplayerproperty(1, "name");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName=="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

spawn    Boss2
@script
void main()
{
  int P1 = getplayerproperty(0, "name");
  int P2 = getplayerproperty(1, "name");
  void self = getlocalvar("self");
  char PName; void Play;

  if(P1){
    Play = P1;
  } else if(P2){
    Play = P2;
  }

  if(Play){
    PName = getentityproperty(Play, "defaultname");

    if(PName!="Guardian"){
      killentity(self);
    }
  }
}
@end_script
#map    1
health    120
coords    0 150
at    0

This script will remove Boss1 if player 1 is Guardian but will remove Boss2 instead if player 1 isn't Guardian.
The script could check player 2 if player 1 isn't available but if both are in, then player 1 will define the boss.
I haven't tested this but try this and see if it works :)
Hi Bloodbane, I was wondering if you had an edit suggestion that would also include NPC's as well as Player?
 
NPCs require extra lines cause unlike players, there's no direct way to acquire their handles.
The simplest way is have them register themselves in certain global variables so the above script will check those variables instead.
 
Back
Top Bottom