Need help with a few things

DJGameFreakTheIguana

Active member
I'm working on a new mod for this SAGE expo thing coming up, which I got till July 15 to register for booths. It's a defense AND offense game where you have a machine that spawns NPC's(If you know them) and you have to keep it from getting destroyed by enemies who are being spawned from 7 different spawners, one of them being the master spawner you have to take down in order to fight the boss. There's functions for this wanna add but need help with:

-Getting the spawners to use random freespecial animations for spawning enemies, I currently do it by looping the idle animation. The best way I can think of is by setting some kind of script at the end of it's Idle animation.

-Since there will be so many enemies on the screen, I need to be able to somehow force the boss to spawn regardless of how many enemies on present on the screen, or script an enemy to be a boss even if not listed in the level txt file, like if it had "Boss 1" in it's header if that's somehow possible.

-There will be shops to buy power ups(copied the scripts from Mixmasters, could never figure it out), but I want to set it up so that you instantly gain that power up without needing to grab an item for it's weapon number.

-Ending the game when the NPC spawner is destroyed, or set level skip at the end of it's death animation to restart the level.

EDIT:
I just found this script:
Code:
void attack1(int RxMin, int RxMax, int RyMin, int RyMax, void Ani)
{// Attack interruption with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    int dir = getentityproperty(self, "direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Ty = getentityproperty(target, "a");
      float Disx = Tx - x;
      float Disy = Ty - y;

      if( Disx >= RxMin && Disx <= RxMax && Disy >= RyMin && Disy <= RyMax && dir == 1) // Target within range on right facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disy >= RyMin && Disy <= RyMax && dir == 0) // Target within range on left facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      }
    }
}
Anyway to edit that for random free specials?

x)
 
  Hmmm.... that's alot to request, let's see:

#1: You should use randomness script to randomly choose between freespecials

http://www.chronocrash.com/forum/index.php?topic=719.0

At end of each freespecial, you can either use script to return to IDLE or just set randomness script there

#2: Hmmm.... if your to-be-boss enemy is spawned from level text, you can use a script to make him/her/it boss BUT if he/she/it is spawned by spawners, then you need other solution
So how is your boss spawned on level?

#3: That's tough one, I can't answer it directly cause you need to create money system first

#4: Just set this in that spawner's DEATH animation:

@cmd jumptobranch "End" 1

When this script is run, it will end current level immediately and jumps to branch named End. If that branch is unavailable, no jumping will be done
 
1- Thanks for that, I'll test it later.

2- The boss wont be spawned from the level txt, cause if I don't add a limit, then the player would have to clear the stage of all enemies or the boss would be spawned too early, so I need a way to spawn a boss without the adding him tot he stage txt, unless there's a way to force the boss to spawn when the Master Spawner is destroyed, even if it's set up for it to spawn after clearing all remaining enemies.

3- I'll copy the money system from Mixmasters, but I copied another one of it's scripts for loading entities by attacking one already loaded in the game:
Code:
void loadallentities(int t)
{ //Matman v0.10
  void b = 0;
  settextobj(12, 200, 126, 1, 1, "Entities Loaded." , openborvariant("elapsed_time")+200);
  if ( t == 1 ) {loadmodel("METAL_SONIC_MK1"); b = 1; }
  if ( t == 1 ) {loadmodel("METAL_SONIC_MK1_"); b = 1; }
  if ( t == 1 ) {loadmodel("METAL_SONIC_MK1__"); b = 1; }
  if ( t == 2 ) {loadmodel("GROUNDER"); b = 1; }
  if ( t == 2 ) {loadmodel("GROUNDER_"); b = 1; }
  if ( t == 2 ) {loadmodel("GROUNDER__"); b = 1; }

  if ( b == 1 ) {
    settextobj(12, 100, 60, 1, 1, "Character Unlocked" , openborvariant("elapsed_time")+100);
  }
}
What I wanna do is get this to change the attacker(I .E. the player) into a specified weapon number. I also have the script for buying an NPC, as an example of how the money system works:
Code:
void buynpc(int amount)
{
  //v0.06
  void vSelf  = getlocalvar("self");
  if ( checkent(vSelf) == 1 ) {
  void target = getentityproperty(vSelf, "opponent");
  int cost = 250;

  void P1 = getplayerproperty(0, "entity"); //Get Player 1
  void P2 = getplayerproperty(1, "entity"); //Get Player 2
  void P3 = getplayerproperty(2, "entity"); //Get Player 3
  void P4 = getplayerproperty(3, "entity"); //Get Player 4

  void Health = getentityproperty(target,"speed");

  int maxnpc = 0;
  int moneyamount = 0;
  int canbuy = 0;
    if (target == P1)
    { maxnpc = getvnpc(0);
      moneyamount = getvscore(0); } else
    if (target == P2)
    { maxnpc = getvnpc(1);
      moneyamount = getvscore(1); } else
    if (target == P3)
    { maxnpc = getvnpc(2);
      moneyamount = getvscore(2); } else
    if (target == P4)
    { maxnpc = getvnpc(3);
      moneyamount = getvscore(3); }

  if ( moneyamount - cost > 0){ canbuy = 1; }

  if ( amount > 0 )
  {
    if (canbuy == 1)
    {
    if (target == P1)
    { setvnpc(0,maxnpc+amount);
      setvscore(0,moneyamount-cost); } else
    if (target == P2)
    { setvnpc(1,maxnpc+amount);
      setvscore(1,moneyamount-cost); } else
    if (target == P3)
    { setvnpc(2,maxnpc+amount);
      setvscore(2,moneyamount-cost); } else
    if (target == P4)
    { setvnpc(3,maxnpc+amount);
      setvscore(3,moneyamount-cost);  }
    //increasespeedforentity( target, (maxspeed-1) );
    drawstring(200, 136, 1, "Total Hired NPC: " + (maxnpc-1) );
    } else {
      drawstring(200, 136, 1, "Not Enough Gold!" );
    }
    drawguiforplayer(target);
  } else {
    settextobj(12, 200, 126, 1, 1, "Total Hired NPC: " + (maxnpc-1), openborvariant("elapsed_time")+200);
    settextobj(13, 200, 136, 1, 1, "Cost: " + cost, openborvariant("elapsed_time")+200);
    /*
    drawstring(200, 136, 1, "Total Hired NPC: " + (maxnpc-1) );
    drawstring(200, 146, 1, "Cost: " +  cost );
    drawstring(200, 156, 1, "Gold: " + moneyamount );
    */
  }
  }
}

4 - Ok, cool, but I'd just like it to jump to the current level the player is on. Guess I may have to make an NPC Spawner for each level then.

Thanks for the help BTW.

x)
 
unless there's a way to force the boss to spawn when the Master Spawner is destroyed, even if it's set up for it to spawn after clearing all remaining enemies.

Aah, that might be the solution.
The idea is the boss is spawned together with spawners and anything you want to spawn on the level
The boss however is not active yet aka in wait mode and invisible + stealthed  preventing anything from harming it
The boss will end wait mode when master spawner is destroyed.

Well, actually you can have boss end wait mode when timer hits say 5 minutes if you'd like

What do you say?

but I'd just like it to jump to the current level the player is on. Guess I may have to make an NPC Spawner for each level then.

You need to set branch before each level then

...
branch Level1
file data/levels/level1.txt
branch Level2
file data/levels/level2.txt
branch Level3
file data/levels/level3.txt
...

then set jumptobranch to jump to desired branch
That's the only way to restart level
 
Bloodbane said:
Aah, that might be the solution.
The idea is the boss is spawned together with spawners and anything you want to spawn on the level
The boss however is not active yet aka in wait mode and invisible + stealthed  preventing anything from harming it
The boss will end wait mode when master spawner is destroyed.

Well, actually you can have boss end wait mode when timer hits say 5 minutes if you'd like

What do you say?
I'll go for the former, I don't want the boss coming in until the master Spawn is taken out.  8)

You need to set branch before each level then

...
branch Level1
file data/levels/level1.txt
branch Level2
file data/levels/level2.txt
branch Level3
file data/levels/level3.txt
...

then set jumptobranch to jump to desired branch
That's the only way to restart level
As I thought, thanks.

Also, about this script:
Code:
@script	
    if(frame==0){
      void vSelf = getlocalvar("self");
      int r = rand()%30;

      if(r > 0){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script
I basically want 100% of it changing it's animation when it reaches the last frame of it's idle, but how do I add other animations for it to change to? Like:
Code:
openborconstant("ANI_FOLLOW1")("ANI_FOLLOW2"));
or
Code:
openborconstant("ANI_FOLLOW1""ANI_FOLLOW2"));

x)
 
Well, that randomness script works like this:

Find random number, if it's value is within defined range, change animation

If you want that kind of randomness, this is how the script should be:

@script
    if(frame==10){
      void vSelf = getlocalvar("self");
      int r = rand()%30;

      if(r > 0){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      } else {
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW2"));
      }
    }
@end_script

This script works like this:

At frame 11, find random value, if it's more than 0, change to FOLLOW1 but if it's not change to FOLLOW2

This should work though you need to adjust frame (red colored text above) to your need
 
Thanks for the help guys. After experimenting for a while, I got the random script to work the way I wanted(A certain enemy I set wasn't being spawned at all, so I changed the order of follow animations for each one).

The weapon thing I need can wait till I get the money script on, for now, I need to know how to get a boss to spawn after the Master Spawner gets to the end of it's death animation.

P.S., I can use the spawn script I'm using now to spawn music right? I want the music to fade to silence at one point of the death animation, then the boss music plays when the boss appears, or spawned right before then.

x)
 
I have the script to make boss (or anything actually) to appear after certain entity dies

Here's an example:

anim spawn
@script
    void self = getlocalvar("self");
    int Check1 = getglobalvar("Go");

    if(frame==1 && Check1==1){
      setglobalvar("Go", NULL());
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
loop 1
delay 8
offset  27 48
fshadow 0
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

anim follow1
delay 100
seta 40
offset  27 48
jumpframe 1 3 0 0.5
frame data/chars/knbot/knbot1.png
delay 30
frame data/chars/knbot/knbot1.png
fshadow 1
frame data/chars/knbot/knbot1.png
delay 20
frame data/chars/knbot/knbot1.png

In this example, this enemy, when spawned, will be invisible and waits in its looped animation until global variable by name of Go is set to 1
When it's set to 1, it changes its animation to FOLLOW1. In this example, the enemy simply jumps to front as if it's saying "Now it's my turn!" ;)

In Master Spawn's DEATH animation, set this:
@script
    if(frame==1){
      setglobalvar("Go", 1);
    }
@end_script

this script will set Go variable to 1 when Master Spawner dies and thus 'allow' the former enemy to 'drop in'

I've tested this and it works well

However I just realized something, are you using NPCs? if yes, I might need to add couple scripts to prevent them from attacking this enemy

I want the music to fade to silence at one point of the death animation, then the boss music plays when the boss appears, or spawned right before then.

Hmmm.... I don't know how to fadeout music with script but I know how to change music with script
 
Yup, the "go" script works.  :D

Hmmm.... I don't know how to fadeout music with script but I know how to change music with script
Ok, so I'll go with having the Master Spawner spawn a silent track when it's dead, and have the boss spawn it's own music in the Follow animation.

There's still the weapon issue but that can wait. I have one more then I need help with and I'll be done bothering you guys.  ;D
I'm gonna set up a entity to use as a jukebox, but instead of spawning music, I wanna spawn a menu you can select which tracks to play, and the menu will go off once the track is selected. Also, if there's a way to get a player to spawn this menu themselves, like pressing attack and jump at the same time, I'd like to do this to, but it'll be for Sega Brawlers. OX was helping me with this script back on Lavalit but we only got it to come up when the stage starts, and worse, the script seems to be completely gone now....

x)
 
I've updated the script in SPAWN animation to this:

Code:
@script
    void self = getlocalvar("self");
    int Check1 = getglobalvar("Go");

    if(frame==1 && Check1==1){
      setglobalvar("Go", NULL());
      changeentityproperty(self, "stealth", 0);
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script

The added line is to set stealth to 0 IOW allow NPCs to target this enemy
You can only see the effect of this if you have set something like stealth 350 in enemy's header before

Master Spawner spawn a silent track when it's dead, and have the boss spawn it's own music in the Follow animation.

spawn? you can change music directly with this line of script:

Code:
      playmusic("data/music/remix.bor",1);

Just add this line in animation you want music to change (inside @script and @end_script of course)

I wanna spawn a menu you can select which tracks to play,

Hmmm.... menu, yes I remember Orochi_X once mentioned his menu script. Too bad I couldn't recall the whole script
 
Yup, that's all working now. About music, since spawning a menu may be out of the question, maybe I can make a hub stage like Sega Brawlers, but there will be multiple "jukeboxes", which will change the music when hit, which will keep playing once you start the next stage. If I do that though, I'll have to think of a way to be able to access this hub stage after the next stage has started, in case someone quits this stage and comes back to no music playing at all. I thought about doing what was done with Marvel First Alliance 2, where in some stages, you can walk into this thing that sends you back to the player select screen. The best idea I can come up with is setting a floating item in the corner somewhere so you have to jump into it, so it's not set off by accident, unless you're somehow knocked high enough to touch it.

X)
 
Back
Top Bottom