* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 30, 2017, 01:21:56 AM

Login with username, password and session length

Summoning NPC's from a menu

  • 38 Replies
  • 1227 Views
*

Offline DJGameFreakTheIguana

  • Hero Member
  • *****
  • 530
  • Baddest Sonic Fan Alive
Re: Summoning NPC's from a menu
« Reply #30 on: April 20, 2017, 03:11:22 AM »
Yeah, I kept them there before I changed the idle animation and it's script.

Code: [Select]

anim follow1
delay 5
offset 34 39
frame data/chars/Menu/Sel0.gif
sound data/sounds/beep2.wav
frame data/chars/Menu/Sel1.gif
@cmd spawnN "RASH_N" -60 0 0 1 "RASH"
frame data/chars/Menu/Sel0.gif
frame data/chars/Menu/Sel1.gif
@cmd beidle
frame data/chars/Menu/Sel0.gif

The other 4 follow animatins are the same, aside from what's being spawned. Dunno what else needs to be done, unless there needs to be a change in lescript or something.

x)

*

Online Bloodbane

  • Hero Member
  • *****
  • 3022
  • Dark Dragon
Re: Summoning NPC's from a menu
« Reply #31 on: April 21, 2017, 10:14:00 AM »
 Hmmm... you have keyall.c script in you data/scripts folder right? and if you do, does it have same contents as the one in map demo?

*

Offline DJGameFreakTheIguana

  • Hero Member
  • *****
  • 530
  • Baddest Sonic Fan Alive
Re: Summoning NPC's from a menu
« Reply #32 on: April 22, 2017, 05:13:28 AM »
Yeah, I copied the file. Here it is if you think it needs to be looked over.
Code: [Select]
void main()
{
    int iPlIndex = getlocalvar("player"); //Get Player's index
    void vSelf = getlocalvar("self"); //Get player
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame

    void iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    void iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    void iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    void iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    void iAttack = playerkeys(iPlIndex, 1, "attack");// New key status of "Attack"
    void iAttack2 = playerkeys(iPlIndex, 1, "attack2");// New key status of "Attack2"
    void iAttack3 = playerkeys(iPlIndex, 1, "attack3");// New key status of "Attack3"
    void iAttack4 = playerkeys(iPlIndex, 1, "attack4");// New key status of "Attack4"
    void iSpecial = playerkeys(iPlIndex, 1, "special");// New key status of "Special"
    void iJump = playerkeys(iPlIndex, 1, "jump");// New key status of "Jump"
    void iStart = playerkeys(iPlIndex, 1, "start");// New key status of "Start"

    void iUpR = playerkeys(iPlIndex, 2, "moveup"); // Release status of "Up"
    void iDownR = playerkeys(iPlIndex, 2, "movedown"); // Release status of "Down"
    void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    void iAttackR = playerkeys(iPlIndex, 2, "attack");// Release status of "Attack"
    void iAttack2R = playerkeys(iPlIndex, 2, "attack2");// Release status of "Attack2"
    void iAttack3R = playerkeys(iPlIndex, 2, "attack3");// Release status of "Attack3"
    void iAttack4R = playerkeys(iPlIndex, 2, "attack4");// Release status of "Attack4"
    void iJumpR = playerkeys(iPlIndex, 2, "jump");// Release status of "Jump"
    void iStartR = playerkeys(iPlIndex, 2, "start");// Release status of "Start"

    void iUpH = playerkeys(iPlIndex, 0, "moveup"); // Held key status of "Up"
    void iDownH = playerkeys(iPlIndex, 0, "movedown"); // Held key status of "Down"
    void iLeftH = playerkeys(iPlIndex, 0, "moveleft"); // Held key status of "Left"
    void iRightH = playerkeys(iPlIndex, 0, "moveright"); // Held key status of "Right"

// Movement event capture
    if(iLeft){ //Left is pressed?
      setglobalvar(iPlIndex+"X", -1);
    } else if(iRight){ //Right is pressed?
      setglobalvar(iPlIndex+"X", 1);
    }
    if(iUp){ //Up is pressed?
      setglobalvar(iPlIndex+"Y", 1);
    } else if(iDown){ //Down is pressed?
      setglobalvar(iPlIndex+"Y", -1);
    }

    if(iLeftR || iRightR){ //Left or Right is released?
      setglobalvar(iPlIndex+"X", 0);
    }
    if(iUpR || iDownR){ //Up or Down is released?
      setglobalvar(iPlIndex+"Y", 0);
    }

// Action event capture
    if(iAttack){ //Attack is pressed?
      setglobalvar(iPlIndex+"A", 1);
    }
    if(iAttackR){ //Attack is released?
      setglobalvar(iPlIndex+"A", NULL());
    }

    if(iAttack2){ //Attack2 is pressed?
      setglobalvar(iPlIndex+"A2", 1);
    }
    if(iAttack2R){ //Attack2 is released?
      setglobalvar(iPlIndex+"A2", NULL());
    }

    if(iAttack3){ //Attack3 is pressed?
      setglobalvar(iPlIndex+"A3", 1);
    }
    if(iAttack3R){ //Attack3 is released?
      setglobalvar(iPlIndex+"A3", NULL());
    }

    if(iAttack4){ //Attack4 is pressed?
      setglobalvar(iPlIndex+"A4", 1);
    }
    if(iAttack4R){ //Attack4 is released?
      setglobalvar(iPlIndex+"A4", NULL());
    }

    if(iJump){ //Jump is pressed?
      setglobalvar(iPlIndex+"J", 1);
    }
    if(iJumpR){ //Jump is released?
      setglobalvar(iPlIndex+"J", NULL());
    }

    if(iStart){ //Start is pressed?
      setglobalvar(iPlIndex+"St", 1);
    }
    if(iStartR){ //Start is released?
      setglobalvar(iPlIndex+"St", NULL());
    }
}

x)

*

Online Bloodbane

  • Hero Member
  • *****
  • 3022
  • Dark Dragon
Re: Summoning NPC's from a menu
« Reply #33 on: April 25, 2017, 12:42:56 AM »
 DJ, I figured out the cause of the problem and I have to tell this bad news. Your method of using frames with long delay is incompatible with the script :(

 The reason Curs entity has a very short delay i.e 2 centiseconds is because it needs to be responsive to player's key press. In your method, the delay is 90000 centiseconds or 900 seconds or 15 minutes which means for the menu to respond to player's key press, it has to wait for 15 minutes

 You'll have to change the method OR use updatescript to acquire key press instead

*

Offline DJGameFreakTheIguana

  • Hero Member
  • *****
  • 530
  • Baddest Sonic Fan Alive
Re: Summoning NPC's from a menu
« Reply #34 on: April 25, 2017, 04:28:52 AM »
Damn, ok then, what about Beastie's idea of switching between looping follow animations? The script for each one could be something like this:
Code: [Select]
  if(frame == 1){ // Sonic
      if(C1==1){
        setglobalvar(PIndex+"A", NULL());
        performattack(self, openborconstant("ANI_FOLLOW101")); // selected Sonic
      } else if(X1>0){ // right is pressed?
        playsample(SFX, 0, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW2")); // selects Tails
      }
I don't think I'll have over 100 selectable chars but this may be easier to keep up with, especially when I have to change what order they are in to fit the menu.

EDIT:
Tried making a script this way but it crashes the engine and doesn't tell me why in the log. Here's what I did(Idle and Follow1 have the same script so another Follow animation go back to 1 if needed)
Code: [Select]

anim idle
@script
  if(frame>=0){
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"y");
    void Par = getentityvar(self, 2);
    int Px = getentityproperty(Par,"x");
    int PIndex = getentityproperty(Par,"playerindex");
    int C1 = getglobalvar(PIndex+"A"); // gets attack pressed status
    int X1 = getglobalvar(PIndex+"X"); // gets left or right pressed status
    int Y1 = getglobalvar(PIndex+"Y"); // gets up or down pressed status
    int SFX = loadsample("data/sounds/ganti.wav");

  if(frame == 2){ // Sonic
      if(C1==1){
        setglobalvar(PIndex+"A", NULL());
        performattack(self, openborconstant("ANI_FOLLOW101")); // selected Sonic
      } else if(X1>0){ // right is pressed?
        playsample(SFX, 0, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW2")); // selects Tails
      }
    }
  }
@end_script
loop 1
delay 1
offset 117 66
frame data/chars/Menu/NSel0.gif
frame data/chars/Menu/NSel0.gif
delay 15
frame data/chars/Menu/NSel0.gif

anim follow1
@script
  if(frame>=0){
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"y");
    void Par = getentityvar(self, 2);
    int Px = getentityproperty(Par,"x");
    int PIndex = getentityproperty(Par,"playerindex");
    int C1 = getglobalvar(PIndex+"A"); // gets attack pressed status
    int X1 = getglobalvar(PIndex+"X"); // gets left or right pressed status
    int Y1 = getglobalvar(PIndex+"Y"); // gets up or down pressed status
    int SFX = loadsample("data/sounds/ganti.wav");

  if(frame == 2){ // Sonic
      if(C1==1){
        setglobalvar(PIndex+"A", NULL());
        performattack(self, openborconstant("ANI_FOLLOW101")); // selected Sonic
      } else if(X1>0){ // right is pressed?
        playsample(SFX, 0, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW2")); // selects Tails
      }
    }
  }
@end_script
loop 1
delay 1
offset 117 66
frame data/chars/Menu/NSel0.gif
frame data/chars/Menu/NSel0.gif
delay 15
frame data/chars/Menu/NSel0.gif

anim follow101
delay 5
offset 34 39
frame data/chars/Menu/Sel0.gif
sound data/sounds/beep2.wav
frame data/chars/Menu/Sel1.gif
@cmd spawnN "RASH_N" -60 0 0 1 "RASH"
frame data/chars/Menu/Sel0.gif
frame data/chars/Menu/Sel1.gif
@cmd beidle
frame data/chars/Menu/Sel0.gif

anim follow2
@script
  if(frame>=0){
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"y");
    void Par = getentityvar(self, 2);
    int Px = getentityproperty(Par,"x");
    int PIndex = getentityproperty(Par,"playerindex");
    int C1 = getglobalvar(PIndex+"A"); // gets attack pressed status
    int X1 = getglobalvar(PIndex+"X"); // gets left or right pressed status
    int Y1 = getglobalvar(PIndex+"Y"); // gets up or down pressed status
    int SFX = loadsample("data/sounds/ganti.wav");

  if(frame == 2){ // Tails
      if(C1==1){
        setglobalvar(PIndex+"A", NULL());
        performattack(self, openborconstant("ANI_FOLLOW102")); // selected Tails
      } else if(X1>0){ // right is pressed?
        playsample(SFX, 0, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW3")); // selects Knuckles
      } else if(X1<0){ // left is pressed?
        playsample(SFX, 1, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW1")); // selects Sonic
      }
    }
  }
loop 1
delay 1
offset 117 66
frame data/chars/Menu/NSel1.gif
frame data/chars/Menu/NSel1.gif
delay 15
frame data/chars/Menu/NSel1.gif

anim follow102
delay 5
offset 34 39
frame data/chars/Menu/Sel0.gif
sound data/sounds/beep2.wav
frame data/chars/Menu/Sel1.gif
@cmd spawnN "ZITZ_N" -60 0 0 1 "FZITZ"
frame data/chars/Menu/Sel0.gif
frame data/chars/Menu/Sel1.gif
@cmd beidle
frame data/chars/Menu/Sel0.gif

anim follow3
@script
  if(frame>=0){
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x");
    int y = getentityproperty(self,"y");
    void Par = getentityvar(self, 2);
    int Px = getentityproperty(Par,"x");
    int PIndex = getentityproperty(Par,"playerindex");
    int C1 = getglobalvar(PIndex+"A"); // gets attack pressed status
    int X1 = getglobalvar(PIndex+"X"); // gets left or right pressed status
    int Y1 = getglobalvar(PIndex+"Y"); // gets up or down pressed status
    int SFX = loadsample("data/sounds/ganti.wav");

  if(frame == 2){ // Knuckles
      if(C1==1){
        setglobalvar(PIndex+"A", NULL());
        performattack(self, openborconstant("ANI_FOLLOW103")); // selected Knuckles
      } else if(X1<0){ // left is pressed?
        playsample(SFX, 1, 120, 120, 100, 0);
        performattack(self, openborconstant("ANI_FOLLOW2")); // selects Tails
      }
    }
  }
loop 1
delay 1
offset 117 66
frame data/chars/Menu/NSel2.gif
frame data/chars/Menu/NSel2.gif
delay 15
frame data/chars/Menu/NSel2.gif

anim follow103
delay 5
offset 34 39
frame data/chars/Menu/Sel0.gif
sound data/sounds/beep2.wav
frame data/chars/Menu/Sel1.gif
@cmd spawnN "PIMPLE_N" -60 0 0 1 "PIMPLE"
frame data/chars/Menu/Sel0.gif
frame data/chars/Menu/Sel1.gif
@cmd beidle
frame data/chars/Menu/Sel0.gif
x)
« Last Edit: April 25, 2017, 05:53:05 AM by DJGameFreakTheIguana »

*

Online Bloodbane

  • Hero Member
  • *****
  • 3022
  • Dark Dragon
Re: Summoning NPC's from a menu
« Reply #35 on: April 26, 2017, 12:25:16 AM »
 You really want to use 100 FOLLOWS?

 Anyways, I asked that cause if you do, you need to expand follows limit with maxfollows in models.txt first. Otherwise, you got that crash

*

Offline DJGameFreakTheIguana

  • Hero Member
  • *****
  • 530
  • Baddest Sonic Fan Alive
Re: Summoning NPC's from a menu
« Reply #36 on: April 26, 2017, 03:45:38 AM »
I forgot about setting max follows, but I just opened up my models txt and saw that it's already set to 200. I don't remember why but it's there. Yeah though, I figured that linking them this way would make it easier to keep track rather then every character having 2 or 3 numbers higher then the next. Honestly though, I've given this some thought and wonder if this is really about the delay, because the menu still reacted to going left and right, just not performing the attacks.

Let's say I go back to my previous setup(which I made a copy of) and do what you suggested, "use updatescript to acquire key press instead", what all would I need for that, and wasn't this what Keyall was for and have the coding for?
Code: [Select]
void main()
{
    int iPlIndex = getlocalvar("player"); //Get Player's index
    void vSelf = getlocalvar("self"); //Get player
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame

    void iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    void iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    void iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    void iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    void iAttack = playerkeys(iPlIndex, 1, "attack");// New key status of "Attack"
    void iAttack2 = playerkeys(iPlIndex, 1, "attack2");// New key status of "Attack2"
    void iAttack3 = playerkeys(iPlIndex, 1, "attack3");// New key status of "Attack3"
    void iAttack4 = playerkeys(iPlIndex, 1, "attack4");// New key status of "Attack4"
    void iSpecial = playerkeys(iPlIndex, 1, "special");// New key status of "Special"
    void iJump = playerkeys(iPlIndex, 1, "jump");// New key status of "Jump"
    void iStart = playerkeys(iPlIndex, 1, "start");// New key status of "Start"

    void iUpR = playerkeys(iPlIndex, 2, "moveup"); // Release status of "Up"
    void iDownR = playerkeys(iPlIndex, 2, "movedown"); // Release status of "Down"
    void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    void iAttackR = playerkeys(iPlIndex, 2, "attack");// Release status of "Attack"
    void iAttack2R = playerkeys(iPlIndex, 2, "attack2");// Release status of "Attack2"
    void iAttack3R = playerkeys(iPlIndex, 2, "attack3");// Release status of "Attack3"
    void iAttack4R = playerkeys(iPlIndex, 2, "attack4");// Release status of "Attack4"
    void iJumpR = playerkeys(iPlIndex, 2, "jump");// Release status of "Jump"
    void iStartR = playerkeys(iPlIndex, 2, "start");// Release status of "Start"

    void iUpH = playerkeys(iPlIndex, 0, "moveup"); // Held key status of "Up"
    void iDownH = playerkeys(iPlIndex, 0, "movedown"); // Held key status of "Down"
    void iLeftH = playerkeys(iPlIndex, 0, "moveleft"); // Held key status of "Left"
    void iRightH = playerkeys(iPlIndex, 0, "moveright"); // Held key status of "Right"

// Movement event capture
    if(iLeft){ //Left is pressed?
      setglobalvar(iPlIndex+"X", -1);
    } else if(iRight){ //Right is pressed?
      setglobalvar(iPlIndex+"X", 1);
    }
    if(iUp){ //Up is pressed?
      setglobalvar(iPlIndex+"Y", 1);
    } else if(iDown){ //Down is pressed?
      setglobalvar(iPlIndex+"Y", -1);
    }

    if(iLeftR || iRightR){ //Left or Right is released?
      setglobalvar(iPlIndex+"X", 0);
    }
    if(iUpR || iDownR){ //Up or Down is released?
      setglobalvar(iPlIndex+"Y", 0);
    }

// Action event capture
    if(iAttack){ //Attack is pressed?
      setglobalvar(iPlIndex+"A", 1);
    }
    if(iAttackR){ //Attack is released?
      setglobalvar(iPlIndex+"A", NULL());
    }

    if(iAttack2){ //Attack2 is pressed?
      setglobalvar(iPlIndex+"A2", 1);
    }
    if(iAttack2R){ //Attack2 is released?
      setglobalvar(iPlIndex+"A2", NULL());
    }

    if(iAttack3){ //Attack3 is pressed?
      setglobalvar(iPlIndex+"A3", 1);
    }
    if(iAttack3R){ //Attack3 is released?
      setglobalvar(iPlIndex+"A3", NULL());
    }

    if(iAttack4){ //Attack4 is pressed?
      setglobalvar(iPlIndex+"A4", 1);
    }
    if(iAttack4R){ //Attack4 is released?
      setglobalvar(iPlIndex+"A4", NULL());
    }

    if(iJump){ //Jump is pressed?
      setglobalvar(iPlIndex+"J", 1);
    }
    if(iJumpR){ //Jump is released?
      setglobalvar(iPlIndex+"J", NULL());
    }

    if(iStart){ //Start is pressed?
      setglobalvar(iPlIndex+"St", 1);
    }
    if(iStartR){ //Start is released?
      setglobalvar(iPlIndex+"St", NULL());
    }
}

x)

*

Online Bloodbane

  • Hero Member
  • *****
  • 3022
  • Dark Dragon
Re: Summoning NPC's from a menu
« Reply #37 on: April 28, 2017, 02:38:09 AM »
Quote
because the menu still reacted to going left and right, just not performing the attacks.

 That's strange cause it should take really long to respond to those key press
 Are you using updatescript for this menu?

Quote
do what you suggested, "use updatescript to acquire key press instead", what all would I need for that, and wasn't this what Keyall was for and have the coding for?

 keyall.c is for acquiring key press / release status to be used by non player entities. Just leave it be
 I just realized that I said it wrong. It should be use updatescript to respond to key press.
 Anyways, to make updatescript, create a blank .c file then move the animation script you have made there. Don't forget to add animation check to ensure key press/release is only taken when menu is in IDLE

*

Offline DJGameFreakTheIguana

  • Hero Member
  • *****
  • 530
  • Baddest Sonic Fan Alive
Re: Summoning NPC's from a menu
« Reply #38 on: May 06, 2017, 06:24:31 PM »
Had some internet issues over the past few days so I was able to get back on.

That's strange cause it should take really long to respond to those key press
 Are you using updatescript for this menu?
No, update script is being used for unlocking characters when certain bosses are killed.

Quote
do what you suggested, "use updatescript to acquire key press instead", what all would I need for that, and wasn't this what Keyall was for and have the coding for?

Quote
keyall.c is for acquiring key press / release status to be used by non player entities. Just leave it be
 I just realized that I said it wrong. It should be use updatescript to respond to key press.
 Anyways, to make updatescript, create a blank .c file then move the animation script you have made there. Don't forget to add animation check to ensure key press/release is only taken when menu is in IDLE
Ok, I'll leave Keyall alone, but the animation script, if you mean for the menu, that would be lescript, which I just did. I'll try experimenting now.

EDIT:
Don't know what animation check is but I'll try to look.

x)
« Last Edit: May 06, 2017, 07:59:26 PM by DJGameFreakTheIguana »

 

Recent

Members
  • Total Members: 6034
  • Latest: jampol
Stats
  • Total Posts: 44636
  • Total Topics: 3045
  • Online Today: 33
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 4
Guests: 18
Total: 22