Battle music?

NickyP

Active member
I swear I've seen someone post a script (either on here or Lavalit) that basically was an if-else statement... ie, if enemies are present, then play battlemusic; else, if no enemies, play normal stage music.

Does anyone have that script? I don't want to use normal music switching techniques because the levels I'm planning to make are entirely different from normal levels. Like, no conventional groups or waits--just an enormous level with enemies that respawn after a certain time.
 
Sounds like a very RPG type of element to add and I expect nothing less from you.  I have not scripted anything in a while would like to help you out but first I will wait to see if anyone knows of this lost code feel free to PM me if your not having any luck.
 
I don't remember seeing such script before but anyways, I could make such script if you like Nick :)

The question: is this script run once or multiple times?
The former means at certain point of game, script checks for enemies and plays battle music if enemies are present etc. IT WON'T change music if those enemies are gone
The latter means it keeps checking for enemies and play appropriate music.
 
I'd appreciate it if either of you helped, but I don't want to be a burden; that's why I was hoping to find the old script. I swear I saw it before!  :o

Bloodbane said:
The question: is this script run once or multiple times?
The former means at certain point of game, script checks for enemies and plays battle music if enemies are present etc. IT WON'T change music if those enemies are gone
The latter means it keeps checking for enemies and play appropriate music.

It would run multiple times, constantly checking for when enemies are on screen. And presumably, each level would have its own variation of this script to match with its' level music, etc.
 
ok I found a real messy way around this but that's how I code. Bloodbane if you can see any way to clean it up please feel free.

so you need to make a new npc entity I called mine "music" here is the code behind the entity.

name Music
health  999
type npc

anim idle
loop 1
offset 38 128
delay 1
@script
void self = getlocalvar("self");
void name = getentityproperty(self,"name");
void fmusic = getglobalvar("fmusic");
if(fmusic==NULL()){
setglobalvar("fmusic", 0);
}
if(openborvariant("count_enemies")>0 && fmusic==0){
  setglobalvar("fmusic", 1);
playmusic("data/music/fight.ogg",1);
}
if(openborvariant("count_enemies")<1 && fmusic==1){
  setglobalvar("fmusic", 0);
  playmusic("data/music/" + name + "",1);
}
@end_script
frame data/chars/misc/empty.gif


now when you spawn him make sure its the first thing you do in the stage and add a alias with the exact file name of your current stage music. the file must be in data/music/ and include the extension.  here is a example.

spawn music
alias normal.ogg
coords 100 200
at 0


with this code you can not change the fight music only the normal stage music when all enemies are defeated.

finally to have a boss music take over when you boss is spawned add this line to his spawn animation. and make sure there is a bit of a delay before the script line at least one frame.

anim spawn
loop 0
offset 46 81
delay 10
frame data/chars/lobster/stand1.gif
@cmd playmusic "data/music/boss.ogg" 1
frame data/chars/lobster/stand1.gif


just in case you cant get this to work here is a demo http://www.mediafire.com/download/109a73j2twt36ej/changemusic_demo.rar

hope that helped.
 
The script is good malik
My recommendation is to use type none since it is simple and doesn't need other animations

This script uses global variable as mean to prevent this script to change same music with same one. If you want this variable to be carried to next levels, global variable is best solution. But if you don't want that, entity variable can do it too :)
 
Thank you, malik! I'll be sure to try it promptly!  ;D

I noticed you're using .ogg's in this script. I still use .bor music files. Will that matter?
 
Change https to http and it will work

https://www.youtube.com/watch?v=xCyNOIbyjM4


Trying to find random enemy link for you on the boards,  I think Bloodbane has a new solution for this.

He has an old script from crime busters mod thou named thug.c

thug.c
Code:
void Rspawn(float fX, float fY, float fZ)
{//Spawns random enemy next to caller.
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%5 + 5;

	if (iR >= 0 && iR < 2){ 
        vName = "Garcia";
      } else if (iR >= 2 && iR < 4){ 
        vName = "Carol";
      } else if (iR >= 4 && iR < 6){ 
        vName = "Lesus";
      } else if (iR >= 6 && iR < 8){ 
        vName = "Rini";
      } else { 
        vName = "Ray";
      }

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = vName;
      }

	if (vAlias == "Garcia"){ // If Garcia is spawned, his alias will be adjusted to his remap
	  if (iMap == 1){
          vAlias = "Joseph";
        } else if (iMap == 2){
          vAlias = "Brash";
        } else if (iMap == 3){
          vAlias = "B.T";
        } else if (iMap == 4){
          vAlias = "Surger";
        } else if (iMap == 5){
          vAlias = "Jonathan";
        } else if (iMap == 6){
          vAlias = "Julio";
        }
      } else if (vAlias == "Ray"){ // If Ray is spawned, his alias will be adjusted to his remap
        if (iMap == 1 || iMap == 4){
          vAlias = "J";
        } else if (iMap == 2 || iMap == 5){
          vAlias = "Bred";
        } else if (iMap == 3 || iMap == 6){
          vAlias = "Zack";
        }
      } else if (vAlias == "Lesus"){ // If Lesus is spawned, his alias will be adjusted to his remap
	  if (iMap == 1){
          vAlias = "Frost";
        } else if (iMap == 2){
          vAlias = "Hail";
        } else if (iMap == 3){
          vAlias = "Tempest";
        } else if (iMap == 4){
          vAlias = "Rain";
        } else if (iMap == 5){
          vAlias = "Calm";
        } else if (iMap == 6){
          vAlias = "Hujan";
        }
      }

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

void RspawnU(float fX, float fY, float fZ)
{//Spawns random enemy next to caller.
// Spawned enemy has Upper ability
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%3 + 3;

	if (iR >= 0 && iR < 2){ 
        vName = "Joe";
      } else if (iR >= 2 && iR < 4){ 
        vName = "Angel";
      } else { 
        vName = "Donna";
      }

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = vName;
      }

	if (vAlias == "Joe"){ // If Joe is spawned, his alias will be adjusted to his remap
	  if (iMap == 0){
          vAlias = "Elang";
        } else if (iMap == 1){
          vAlias = "Condor";
        } else if (iMap == 2){
          vAlias = "Hawk";
        } else if (iMap == 3){
          vAlias = "Eagle";
        } else if (iMap == 4){
          vAlias = "Rajawali";
        } else if (iMap == 5){
          vAlias = "Raven";
        }
      } else if (vAlias == "Donna"){ // If Donna is spawned, her alias will be adjusted to her remap
        if (iMap == 1 || iMap == 5){
          vAlias = "Althea";
        } else if (iMap == 2){
          vAlias = "Maria";
        } else if (iMap == 3){
          vAlias = "Reina";
        } else if (iMap == 4){
          vAlias = "Zora";
        }
      } 

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

void Rspawn2(float fX, float fY, float fZ)
{//Spawns random enemy next to caller.
// Spawned enemy is hard enemy
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%4 + 4;

	if (iR >= 0 && iR < 2){ 
        vName = "Mary";
      } else if (iR >= 2 && iR < 4){ 
        vName = "Jhun";
      } else if (iR >= 4 && iR < 6){ 
        vName = "MayLee";
      } else { 
        vName = "Vanessa";
      }

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = vName;
      }

	if (vAlias == "Jhun"){ // If Jhun is spawned, his alias will be adjusted to his remap
	  if (iMap == 1){
          vAlias = "Hakuyo";
        } else if (iMap == 2){
          vAlias = "Suicho";
        } else if (iMap == 3){
          vAlias = "Singa";
        } else if (iMap == 4){
          vAlias = "Tiger";
        } else if (iMap == 5){
          vAlias = "Macan";
        } 
      } else if (vAlias == "MayLee"){ // If MayLee is spawned, her alias will be adjusted to her remap
        if (iMap == 0){
          vAlias = "Maya";
        } else if (iMap == 1){
          vAlias = "Kelly";
        } else if (iMap == 2){
          vAlias = "Nina";
        } else if (iMap == 3){
          vAlias = "Jessy";
        } else if (iMap == 4){
          vAlias = "Lisa";
        } else if (iMap == 5){
          vAlias = "Betsy";
        }
      } 

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

void RspawnD(float fX, float fY, float fZ)
{//Spawns random rolling drum next to caller.
// Spawned drum could be destructible or not
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%3 + 3;

	if (iR >= 0 && iR < 4){ 
        vName = "RollDrum";
      } else { 
        vName = "SDrum";
      }

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = "Drum";
      }

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

void RspawnDM(float fX, float fY, float fZ)
{//Spawns random mirrored rolling drum next to caller.
// Spawned drum could be destructible or not
//
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	void vName; //Spawn object's name.
      void vRName = getentityproperty(self,"defaultname"); // Get caller's real name.
      void vAlias = getentityproperty(self,"name"); // Get caller's alias.
      int  iMHealth = getentityproperty(self,"maxhealth"); // Get caller's maximum health.
      int  iHealth = getentityproperty(self,"health"); // Get caller's health.
	int  iDirection = getentityproperty(self, "direction"); // Get caller's direction.
	int  iMap = getentityproperty(self, "map"); // Get caller's remap.
      int  iR = rand()%3 + 3;

	if (iR >= 0 && iR < 4){ 
        vName = "RDrumM";
      } else { 
        vName = "SDrumM";
      }

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	if (vAlias == vRName){ // If this entity doesn't have alias, it will use spawned entity's name.
        vAlias = "Drum";
      }

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "name", vAlias); //Set alias.
	changeentityproperty(vSpawn, "map", iMap); //Set map.
	changeentityproperty(vSpawn, "maxhealth", iMHealth); //Set maximum health.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.

	return vSpawn; //Return spawn.
}

void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    damageentity(self, self, 10000, 1, openborconstant("ATK_NORMAL"));
}

void move(int dx, int dz,int da)
{ // Moves entity freely or ignores obstacles
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getentityproperty(self,"a"); //Get character's a coordinate
    int dir = getentityproperty(self,"direction"); //Get character's facing direction

     if(dir==0){ // Facing left?
      changeentityproperty(self, "position", x-dx, z+dz, a+da); //Move
     }
     else if(dir==1){ // Facing right?
      changeentityproperty(self, "position", x+dx, z+dz, a+da); //Move
     }
}

void anichange(void Ani)
{ // Animation changer
    void self = getlocalvar("self");

    changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
}

void dasher( float Vx, float Vy, float Vz )
{// Dash with desired speed!
    void self = getlocalvar("self");
    int dir = getentityproperty(self,"direction");

    if(dir==0){ // Facing left?
      Vx = -Vx ;
    }

    if( Vx!=NULL() && Vy!=NULL() && Vz!=NULL() ){
      changeentityproperty(self, "velocity", Vx, Vz, Vy); //Move!!
    }
}

void stop()
{// Stop enemy's movement!
    void self = getlocalvar("self");
    changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
}

 
I used npc as the entity will follow you around and i am too used to using globalvars.  Well nick glad i could help scripting is annoying but gratifying.
 
The recent posts about music scripts made got me trying to update my old 'jukebox' stage from my dott mod.

My old method was using an invisible char with weapons, each weapon played the next track.

I used freespecials to choose tracks

A2 - next track
A1 - previous track


Trying to do it with one entity now using script, just making an entity with idle animation and adding the script there.  It will cycle tracks when you press a key.  Thought you guys might have a good solution for it.

It just needs to play from a list of tracks, and display the current track title.  Also it plays a sound effect when switching tracks, the buttons mapped like I mentioned earlier.

So far I can't get the next track/previous track thing working.

 
Using the thug.c excerpt, I tried to make my own spawner.

Code:
name group1
type none
nomove 1
hostile player npc
offscreenkill 999999

load enem1
load enem2
load enem3
load enem4

anim spawn
	delay 1
	offset 1 1
	frame data/enems/group/blank.png

anim idle
	delay 1
	offset 1 1
	frame data/enems/group/blank.png

anim attack1
@script
if(frame == 0){//Spawns random enemy from list next to caller.
   void self = getlocalvar("self"); //Get calling entity.
   void vSpawn; //Spawn object.
   void vName; //Spawn object's name.
        int  iR = rand()%10 + 10;

        if (iR >= 0 && iR < 5){ 
        vName = "enem1";
      } else if (iR >= 5 && iR < 10){ 
        vName = "enem2";
      } else if (iR >= 10 && iR < 15){ 
        vName = "enem3";
      } else if (iR >= 15 && iR < 20){ 
        vName = "enem4";
      } 

   clearspawnentry(); //Clear current spawn entry.
     setspawnentry("name", vName); //Acquire spawn entity by name.
   
   vSpawn = spawn(); //Spawn in entity.

   changeentityproperty(vSpawn, "position", "a", "x", "z"); //Set spawn location.

   return vSpawn; //Return spawn.
}
@end_script
	range 1 300
	offset 1 1
	delay 10
	frame data/enems/group/blank.png
	delay 30000
	frame data/enems/group/blank.png

The idea is to plant these all over the levels, and when the player walks by, a random enemy is spawned. As long as the player is in range, an enemy should be spawned every X minutes (set by the delay in anim attack1).

This sounds great, but... it doesn't spawn anything. Help?  :o

EDIT:

Apparently, "none" type entities can't be hostile towards players. Not only that, but the script I have isn't spawning anything anyways. So I gave up for now and resorted to more archaic methods... setting the type to npc, and using multiple attacks to spawn.

Code:
name group1
type npc
nomove 1
hostile player
offscreenkill 999999

load enem1
load enem2
load enem3
load enem4

anim spawn
	delay 1
	offset 1 1
	frame data/enems/group/blank.png

anim idle
	delay 1
	offset 1 1
	frame data/enems/group/blank.png

anim attack1
	custentity enem1
	summonframe 0 1 1
	range 1 100
	offset 1 1
	delay 10
	frame data/enems/group/blank.png
	delay 30000
	frame data/enems/group/blank.png

anim attack2
	custentity enem2
	summonframe 0 1 1
	range 1 100
	offset 1 1
	delay 10
	frame data/enems/group/blank.png
	delay 30000
	frame data/enems/group/blank.png

anim attack3
	custentity enem3
	summonframe 0 1 1
	range 1 100
	offset 1 1
	delay 10
	frame data/enems/group/blank.png
	delay 30000
	frame data/enems/group/blank.png

anim attack4
	custentity enem4
	summonframe 0 1 1
	range 1 100
	offset 1 1
	delay 10
	frame data/enems/group/blank.png
	delay 30000
	frame data/enems/group/blank.png

Each enemy is spawned by it's corresponding attack animation. All attack animations have matching ranges and use summonframe; so it can spawn one enemy at a time in a pseudo-random fashion. Hey, it works so far.

Anyways, thanks a whole lot.  :)
 
Sorry Nick I'd hoped Bloodbane would of returned by now, I think the thug script needs updating.

You can still add randomness to this entity you made, check this topic.
http://www.chronocrash.com/forum/index.php?topic=653.msg4931#msg4931


Basically you add something like this to the idle animation.

Code:
      	@script
    void self = getlocalvar("self");
    if( frame == 0){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      } else if( r < -10){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
      } else if( r < 0){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
      } else if( r > 0){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW4"));
      }
    }
	@end_script
(you will need to edit the randomness values, I'm not good at this)

Change your attacks to follows

Also if you need you can use spawn01 animation script to spawn multiple enemies in one frame or animation.

Code:
@cmd spawn01 name x y z

Code:
void spawn01(void vName, float fX, float fY, float fZ)
{
	//spawn01 (Generic spawner)
	//Damon Vaughn Caskey
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Y location adjustment.
      //fZ: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    
	return vSpawn; //Return spawn.
}
 
I used npc as the entity will follow you around

You can just set offscreenkill 3000 if you don't want it to be removed offscreen

This sounds great, but... it doesn't spawn anything. Help?

This is the problem:

Code:
   changeentityproperty(vSpawn, "position", "a", "x", "z");

This line controls where spawned entity would be. I don't know what will this function do if you fill the values with these "a" , "x" and "z" but clearly it's not right.

Try this:

@script
if(frame == 0){//Spawns random enemy from list next to caller.
  void self = getlocalvar("self"); //Get calling entity.
  void vSpawn; //Spawn object.
  void vName; //Spawn object's name.
  int x = getentityproperty(self, "x"); //Get X location and add adjustment.
  int y = getentityproperty(self, "a"); //Get Y location and add adjustment.
  int z = getentityproperty(self, "z"); //Get Z location and add adjustment.

  int  iR = rand()%10 + 10;

  if (iR >= 0 && iR < 5){
    vName = "enem1";
  } else if (iR >= 5 && iR < 10){
    vName = "enem2";
  } else if (iR >= 10 && iR < 15){
    vName = "enem3";
  } else if (iR >= 15 && iR < 20){
    vName = "enem4";
  }

  clearspawnentry(); //Clear current spawn entry.
  setspawnentry("name", vName); //Acquire spawn entity by name.
 
  vSpawn = spawn(); //Spawn in entity.

  changeentityproperty(vSpawn, "position", x, z, y); //Set spawn location.
}
@end_script

Haven't tried this myself though
 
Hmmm. I'll try these scripts tomorrow.

In the meantime, because sharing is caring, here's what I whipped up with you guys' help:

https://www.dropbox.com/s/foynttn9nnmwmd2/somethingtest%28totally_pre_alpha%29.pak

Like the name suggests, it's definitely in rough initial stages. Ignore the title/menu screens, and keep in mind that it plays similar to ClaFan. (one might even say it's more advanced compared to ClaFan; wink wink)

I've yet to make a method to go back to town from the field, but you know. We'll get there when we get there.
 
It's really cool NickyP, the town felt like zelda on snes, I kept trying to chop the bushes. :p

in the combat mode, you could make it go dark when combat starts (like some RPG games do), by changing the stage palette, or spawn darkness effect panel.
 
Back
Top Bottom