Solved change 2pspawn/3pspawn via script

Question that is answered or resolved.

Toranks

Active member
Is there a way to change/ignore/erase 2pspawn/3pspawn lines in level files via script using global variables or similar?
My intention is to create 3 different difficulties for one player using 2pspawn / 3pspawn
 
Rather than doing that, why not use script to remove spawned entity if certain condition is met?
That's how I remove markers in world map in Map demo when the level linked by the marker is completed.

Here's an example from map.txt:
Code:
spawn    marker
@script
  void main()
  {
    void self = getlocalvar("self"); //Get calling entity
    void Status2 = getglobalvar("For1");

    if(Status2 == 1){
      killentity(self);
    }
  }
@end_script
alias    F1
map    1
coords    560 410
at    0

For1 variable is filled with 1 after forest1 level is completed.

Same idea could be implemented to remove spawned entities in different difficulty setting. It comes to how exactly you define difficulty.
If you're using level set (ex: set 1 = easy, set 2 = medium and set 3 = hard) to define difficulty, you could use script like this:
Code:
spawn    Enemy
@script
  void main()
  {
    void self = getlocalvar("self"); //Get calling entity
    void set = openborvariant("current_set");

    if(set == 0){
      killentity(self);
    }
  }
@end_script
map    1
coords    400 200
at    0

set = 0 is first level set.
This script means this enemy won't appear in easy mode.
 
Good, I can replace al 2pspawns with the script with set=2 and 3pspawns with set=3. It can be done quickly and easily, without involving a great deal of change. Thanks! Now I only have to create a menu within the game to change that value, but that part is easy, since I have quite a few models already in the game itself. I will tell you if everything works when I try it
 
One question. How is defined openborvariant("current_set")? The order of the level set in levels.txt file? (first level set is 0)

“current_set”, – Current difficulty set index, start from 0.
 
Back
Top Bottom