Retaining Weapon Model for Next Level

maxman

Well-known member
When players use weapons as weapon models at the end of the level, they usually and always revert back to the original without carrying weapons in the beginning of the next level. It's like the Punisher (arcade game or character) when he carries a bat in level 1-2 and starts leaving in the end for the next level. In the beginning of level 1-3, he still carries the same bat without reverting back to his bare hands for fighting. Also, after defeating the boss in a certain stage, the playable character goes back to his/her original bare hands for fighting for the next stage (e.g. Stage 2-1, stage 3-1, etc.). (The character needs to retain it until stage is complete.) How can I retain the weapon model after a previous level (for the next level)?
 
Just store your weapon index on a variable and read from it on the next level, in the character spawn animation
I don't know. I'm lost on the next level part. Does that mean I'm going to use a weapon index on a global variable? Which script event should I declare for the weapon index to stay in the first level before/for the next level? Do you have any example of that? I just attempted in making a weapon change and this script event, but somehow, it's not working with levelscript and endlevelscript.

Code:
background    Data\Bgs\3rave2/z01.gif
panel        Data\Bgs\3rave2/z02.gif
frontpanel    Data\Bgs\3rave2/z03.gif
order           a
direction       right
levelscript @script
void main(){
    int player = getlocalvar("player");
    void self = getplayerproperty(player, "entity");
    int weapnum = getplayerproperty(self, "weapnum");
    void model = getentityproperty(self, "model");
    void name = getentityproperty(self, "name");
    void weapChange = getglobalvar("weaponChange");

    if(name == "Athena"){
        setglobalvar("weaponChange", weapnum);
    }

    if(weapChange == NULL()){
        setglobalvar("weaponChange", 1);
        changeplayerproperty(self, "weapnum", 1);
    }
}
@end_script

endlevelscript @script
void main(){
    int player = getlocalvar("player");
    void self = getplayerproperty(player, "entity");
    int weapnum = getplayerproperty(self, "weapnum");
    void model = getentityproperty(self, "model");
    void name = getentityproperty(self, "name");
    void weapChange = getglobalvar("weaponChange");

    if(name == "Athena"){
        setglobalvar("weaponChange", weapnum);
    }

    if(weapChange == NULL()){
        setglobalvar("weaponChange", 1);
        changeplayerproperty(self, "weapnum", 1);
    }
}
@end_script

spawn  light
flip   1
coords 283 244
at     0

spawn  light
flip   1
coords 1005 244
at     0

spawn  light
coords 144 244
at     0

spawn   1up
coords  20 230
at      0

#-------1

spawn   table
item    money
coords  165 225
at      0

spawn   chair
item    hotdog
coords  215 225
at      0

group   3 3
at      0

spawn   shermie
map     1
alias   Fancy
coords  380 170
at      0

Can I get some pointers on where I have done wrong especially with globalvars and weapon change?

EDIT:
I need to retain this weapon model from the end of the first level to the beginning of the next level.
ROD MAXED OUT! - 0012.pngROD MAXED OUT! - 0013.png

But still, the next level always reverts back to the original model.
 
Last edited:
Does that mean I'm going to use a weapon index on a global variable?

To be precise, you'd need to store current weapon number aka currently held weapon into a global variable. Instead of name, it's best that the variable is player based aka the variables store weapon for each player.

Which script event should I declare for the weapon index to stay in the first level before/for the next level?

I think endlevel.c could be used to store current weapon number.

Do you have any example of that?

Shadows of Death has script system to carry weapon from level to level. I forgot how it exactly works but basically Billy's last weapon is stored into global variable then reapplied when level starts.
 
Shadows of Death has script system to carry weapon from level to level. I forgot how it exactly works but basically Billy's last weapon is stored into global variable then reapplied when level starts.
I forgot about Shadows of Death! It's been over a year since my PC's HD died.

I think it goes like this for the items and the weapon models after I found the reference of it.

Example:

Items:
Code:
name        nunchaku    #GROUND
score        1
type        item
nolife        1
gfxshadow    1
offscreenkill    5
stealth        100
didhitscript    data/scripts/wepo.c


anim    idle
    loop    1
    delay    200
    offset    23 5
    bbox    0 0 48 12
    frame    data/chars/weapons/nunchaku.png
    nodrawmethod
    frame    data/chars/weapons/nunchaku.png
    delay    6
    drawmethod tintmode 1
    drawmethod tintcolor 150_150_150
    frame    data/chars/weapons/nunchaku.png

wepo.c:
C:
#import "data/scripts/library/spawn.h"

void main()
{//Script for scripted weapon item
    void self = getlocalvar("self");
    char Item = getentityproperty(self,"defaultname");
    void target = getlocalvar("damagetaker");
    char PWep = getentityproperty(target, "model");
    char PName = getentityproperty(target, "defaultname");
    int PIndex = getentityproperty(target,"playerindex"); // Get player's index
    int PScore = getplayerproperty(PIndex,"score"); // Get player's score
    void Shur;

    if(PName=="Billy"){
      int HP = getglobalvar("HP");
      int THealth = getentityproperty(target,"health");

      if(PWep=="Billynun"){
        shooter2("nunchaku", 0, 20, 0, 0, 1, 0);
      } else if(PWep=="Billyshu"){
        int BAmmo = getglobalvar("BilShur");
        Shur = shooter2("shuriken", 0, 20, 0, 0, 1, 0);

        changeentityproperty(Shur, "grabforce", BAmmo);
      } else if(PWep=="Billysickle"){
        shooter2("sickle", 0, 20, 0, 0, 1, 0);
      }

      if(Item=="nunchaku"){
        setglobalvar("BilWep", 1);
        changeentityproperty(target, "weapon", 1);
      } else if(Item=="shuriken"){
        int Ammo = getentityproperty(self,"grabforce");

        setglobalvar("BilWep", 2);
        setglobalvar("BilShur", Ammo);
        changeentityproperty(target, "weapon", 2);
      } else if(Item=="sickle"){
        setglobalvar("BilWep", 3);
        changeentityproperty(target, "weapon", 3);
      }

      changeentityproperty(target,"maxhealth", 8 + HP);
      changeentityproperty(target,"health", THealth);
    } else {
      int SFX = loadsample("data/sounds/kelly_weapons.wav");

      if(Item=="nunchaku"){
        shooter2("nunchaku", 0, 20, 0, 0, 1, 0);
      } else if(Item=="shuriken"){
        shooter2("shuriken", 0, 20, 0, 0, 1, 0);
      } else if(Item=="sickle"){
        shooter2("sickle", 0, 20, 0, 0, 1, 0);
      }
      playsample(SFX, 0, 120, 120, 100, 0);
    }

    changeplayerproperty(PIndex, "score", PScore-1);
}

Billy:
Code:
##MAIN
name                Billy
type                player
candamage            enemy obstacle player

##LIFE
health                8

##POWER
offense             1 #SCRIPT

##SPEED
speed                10 #SCRIPT
running             23 3.1 1.2 1 1

##JUMP
#jumpmove     0 0
#jumpheight     3

##ENERGY
mp                    2
mprate              1 #SCRIPT

##GRAB
grabdistance         33 #36/33/30
grabfinish             0 #PLAYER=0/ENEMY=1

##WEIGHT/HEIGHT
antigravity            -6 #-3/-6/-9
height                74

##MISC
jugglepoints        30
guardpoints            20
guardrate            4
risetime            170
riseinv             1 1
makeinv                2 0
atchain                1 1 2 3
gfxshadow            1 1
dust                dust
bflash                block
nodieblink             2
makeinv             3 1
#falldie            2
death                 2

##ICONS
icon                data/chars/billy/icon.png 1
iconpain            data/chars/billy/iconpain.png 1

##DIESOUND
diesound            data/sounds/die1.wav

modelflag            7
weaploss             3
weapons             billynun billyshu billysickle cursor Billyrun Billycar Ryu DuPanah

I'm including scripts for the Nunchaku Billy
Code:
##MAIN
name                Billynun
type                 none
hostile                enemy obstacle
candamage            enemy obstacle

##LIFE
health                8

##POWER
offense             1 #SCRIPT

##SPEED
speed                10 #SCRIPT
running             20 3.1 1.2 1 0

##JUMP
jumpmove     0 0
jumpheight     3

##ENERGY
mp                    2
mprate              1 #SCRIPT

##GRAB
grabdistance         33 #36/33/30
grabfinish             0 #PLAYER=0/ENEMY=1

##WEIGHT/HEIGHT
antigravity            -6 #-3/-6/-9
height                74

##MISC
jugglepoints        30
guardpoints            20
guardrate            4
risetime            170
riseinv             1 1
makeinv                2 0
atchain                1
gfxshadow            1 1
dust                dust
bflash                block
nodieblink             2
#falldie            2
death                 2
modelflag            4
weaploss             3
weapons             billynun billyshu billysickle billy

##ICONS
icon                data/chars/billy/icon.png 1
iconpain            data/chars/billy/iconpain.png 1

##DIESOUND
diesound            data/sounds/die1.wav

animationscript            data/scripts/player.c
takedamagescript        data/scripts/weplo.c

#Specials
com            D U A    freespecial2



##ANIMATIONS#############################################################################
anim    spawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int PIndex = getentityproperty(self,"playerindex") + 1;
      int HP = getglobalvar("HP");
      int HPs = getglobalvar("HP" + PIndex +"s");

      if(HPs==NULL()){
        HPs = getentityproperty(self,"health");
      }

      changeentityproperty(self,"maxhealth", 8 + HP);
      changeentityproperty(self,"health", HPs);
      setglobalvar("HP" + PIndex +"s", NULL());
    }
@end_script
    delay    2
    offset    45 93
    sound    data/sounds/Ready.wav
    frame    data/chars/billy/nunchaku/stand1.png
    frame    data/chars/billy/nunchaku/stand1.png

anim    respawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int HP = getglobalvar("HP");

      changeentityproperty(self,"maxhealth", 8 + HP);
      changeentityproperty(self,"health", 8 + HP);
    }
@end_script
    delay    2
    offset    45 93
    sound    data/sounds/Ready.wav
    frame    data/chars/billy/nunchaku/stand1.png
    frame    data/chars/billy/nunchaku/stand1.png


anim    freespecial2 # Throw Nunchaku
@script
  if(frame==2){
    setglobalvar("BilWep", 0);
  }
  if(frame==3){
    void self = getlocalvar("self"); //Get calling entity
    int THealth = getentityproperty(self,"health");
    int HP = getglobalvar("HP");

    changeentityproperty(self, "weapon", 0);
    changeentityproperty(self,"maxhealth", 8 + HP);
    changeentityproperty(self,"health", THealth);
  }
@end_script
    delay    8
    offset    45 94
#    weaponframe 3 0
    bbox    30 14 28 79
    hitfx    data/sounds/aof2-199.wav
    frame    data/chars/billy/nunchaku/attack1.png
    frame    data/chars/billy/nunchaku/attack2.png
    delay    3
    offset    45 93
    @cmd    shooter "nunchakuT" 40 60 0 3 0 0
    frame    data/chars/billy/attack6.png
    frame    data/chars/billy/attack5.png

reweap:
Code:
name        reweap
type        none


anim    idle
@script
  if(frame==1){
    int BWeap = getglobalvar("BilWep");
    void P1 = getplayerproperty(0, "entity");
    char PName = getentityproperty(P1, "defaultname");

    if(PName=="Billy" && BWeap!=0){
      int HP = getglobalvar("HP");
      int THealth = getentityproperty(P1,"health");

      changeentityproperty(P1, "weapon", BWeap);
      changeentityproperty(P1, "maxhealth", 8 + HP);
      changeentityproperty(P1,"health", THealth);
    }
  }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

In levels, here it is for reweap model.

Code:
# Street
music        data/music/tune_level_1.ogg
#bossmusic    data/music/menu.bor

# Load images
panel    data/bgs/stage1.png
order     a

spawn1 0 200
spawn2 0 210

noslow 1

spawn    Reweap
coords    160 200 
at    0

spawn    BringItin
coords    160 200 0
at    0

spawn        animated_door
flip        1
coords        142 123 
at            0

spawn        animated_catmilk
flip        1
coords        164 160 
at
 
I'm lost on the weapon change part. I made reweap entity for a certain model here.

Code:
name        reweap
type        none


anim    idle
@script
  if(frame==1){
    int AWeap = getglobalvar("AtenWep");
    void P1 = getplayerproperty(0, "entity");
    char PName = getentityproperty(P1, "defaultname");
    char name = getentityproperty(P1, "name");

    if(name=="Athena" && AWeap!=0){
      int HP = getglobalvar("HP");
      int THealth = getentityproperty(P1,"health");

      changeentityproperty(P1, "weapon", AWeap);
      changeentityproperty(P1, "maxhealth", 100 + HP);
      changeentityproperty(P1,"health", THealth);
    }
  }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

I don't know what I'm doing wrong, but I have this issue which I cannot have the weapon model start the game after finishing the first level of the stage. Let me show you the codes for both player model and weapon model(s) with some scripts.

Player model:
Code:
name        AthenaXI
type        player
health        100
speed        12
icon        data/chars/heroes/athena/xi/icon.png
modelflag    4
weaploss    3
weapons        Athena94 Atena95 none none none none none none none none none AthenaXI
palette        data/chars/heroes/athena/xi/idle00.png
alternatepal    data/chars/heroes/athena/xi/paltest.png

running 18 3.6 3 7 1 #running {speed} {height} {length} {move} {land}

com d f a freespecial
com f u a freespecial2

onspawnscript data/scripts/onspawn/athena.c
ondrawscript data/scripts/ondraw/player_ondraw.c

anim spawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int PIndex = getentityproperty(self,"playerindex") + 1;
      int HP = getglobalvar("HP");
      int HPs = getglobalvar("HP" + PIndex +"s");

      if(HPs==NULL()){
        HPs = getentityproperty(self,"health");
      }

      changeentityproperty(self,"maxhealth", 100 + HP);
      changeentityproperty(self,"health", HPs);
      setglobalvar("HP" + PIndex +"s", NULL());
    }
@end_script
    offset 39 108
    delay 2
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle00.png

anim respawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int HP = getglobalvar("HP");

      changeentityproperty(self,"maxhealth", 100 + HP);
      changeentityproperty(self,"health", 100 + HP);
    }
@end_script
    offset 39 108
    delay 2
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle00.png

anim freespecial
#@script
  if(frame==6){
    setglobalvar("AtenWep", 1);
  }
  if(frame==7){
    void self = getlocalvar("self"); //Get calling entity
    int THealth = getentityproperty(self,"health");
    int HP = getglobalvar("HP");

    changeentityproperty(self, "weapon", 1);
    changeentityproperty(self,"maxhealth", 100 + HP);
    changeentityproperty(self,"health", THealth);
  }
@end_script
    offset 39 108
    delay 8
    weaponframe 7 1 #weaponframe {frame} {weapon}
    offset 45 92
    delay 8
    frame data/chars/heroes/athena/xi/run00.png # 0
    frame data/chars/heroes/athena/xi/run01.png # 1
    offset 32 108
    frame data/chars/heroes/athena/xi/walk08.png # 2
    frame data/chars/heroes/athena/xi/walk09.png # 3
    frame data/chars/heroes/athena/xi/walk10.png # 4
    frame data/chars/heroes/athena/xi/walk11.png # 5
    frame data/chars/heroes/athena/xi/walk00.png # 6
    frame data/chars/heroes/athena/xi/walk01.png # 7

Weapon model:
Code:
name Athena94 # WEAPON 1
type none
health 100
speed 13

icon data/chars/heroes/athena/94/athena94.png

weaploss 3
modelflag 4
weapons Athena94 Atena95 none none none none none none none none none AthenaXI
#weapon {weapon1} {weapon2} {weapon3} {weapon4} {weapon5} {weapon6}.... {original}
com d f a freespecial
com f u a freespecial2
palette data/chars/heroes/athena/94/0_1.png
alternatepal data/chars/heroes/athena/94/paltest.png

onmodelcopyscript data/scripts/onspawn/athena.c
ondrawscript data/scripts/ondraw/player_ondraw.c

anim spawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int PIndex = getentityproperty(self,"playerindex") + 1;
      int HP = getglobalvar("HP");
      int HPs = getglobalvar("HP" + PIndex +"s");

      if(HPs==NULL()){
        HPs = getentityproperty(self,"health");
      }

      changeentityproperty(self,"maxhealth", 100 + HP);
      changeentityproperty(self,"health", HPs);
      setglobalvar("HP" + PIndex +"s", NULL());
    }
@end_script
    delay 2
    offset 132 203
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_1.png

anim respawn
@script
    if(frame==1){
      void self = getlocalvar("self"); //Get calling entity
      int HP = getglobalvar("HP");

      changeentityproperty(self,"maxhealth", 100 + HP);
      changeentityproperty(self,"health", 100 + HP);
    }
@end_script
    delay 2
    offset 132 203
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_1.png

anim freespecial
@script
  if(frame==9){
    setglobalvar("AtenWep", 0);
  }
  if(frame==10){
    void self = getlocalvar("self"); //Get calling entity
    int THealth = getentityproperty(self,"health");
    int HP = getglobalvar("HP");

    changeentityproperty(self, "weapon", 0);
    changeentityproperty(self,"maxhealth", 100 + HP);
    changeentityproperty(self,"health", THealth);
  }
@end_script
    delay 9
    #weaponframe 10 0
    offset 132 203
    frame data/chars/heroes/athena/94/101_1.png # 0
    frame data/chars/heroes/athena/94/101_2.png # 1
    frame data/chars/heroes/athena/94/101_5.png # 2
    frame data/chars/heroes/athena/94/123_3.png # 3
    frame data/chars/heroes/athena/94/123_4.png # 4
    frame data/chars/heroes/athena/94/123_5.png # 5
    frame data/chars/heroes/athena/94/107_1.png # 6
    attack 100 100 100 100 100 1
    frame data/chars/heroes/athena/94/107_2.png # 7
    frame data/chars/heroes/athena/94/112_2.png # 8
    frame data/chars/heroes/athena/94/112_3.png # 9
    frame data/chars/heroes/athena/94/112_4.png # 10

I'm totally lost with the onspawn/onmodelcopy script here when it comes to weapon change.
Code:
void main(){
    nameChange();
    weapChange();
}

void nameChange(){
    changeentityproperty(getlocalvar("self"), "name", "Athena");
}

void weapChange(){
    //Scripted weapon change
    void self = getlocalvar("self");
    char Wep = getentityproperty(self, "model");
    char PName = getentityproperty(self, "defaultname");
    char name = getentityproperty(self, "name");
    void ani = getentityproperty(self, "animationid");
    int frame = getentityproperty(self, "animpos");

    /*if(PName == "AthenaXI"){
        int HP = getglobalvar("HP");
        int THealth = getentityproperty(self, "health");

        if(Wep == "Athena94"){
            setglobalvar("AtenWep", 1);
            changeentityproperty(self, "weapon", 1);
        }

        if(ani == openborconstant("ANI_FREESPECIAL") && frame == 7){
            setglobalvar("AtenWep", 1);
            changeentityproperty(self, "weapon", 1);
            //changeentityproperty(self, "model", "Athena94");
        }
        changeentityproperty(self, "maxhealth", 100 + HP);
        changeentityproperty(self, "health", THealth);
    }*/

    if(Wep == "Athena94"){
        int HP = getglobalvar("HP");
        int THealth = getentityproperty(self, "health");

        if(ani == openborconstant("ANI_FREESPECIAL") && frame == 10){
            setglobalvar("AtenWep", 0);
            changeentityproperty(self, "weapon", 0);
            //changeentityproperty(self, "model", "Athena94");
        }
        changeentityproperty(self, "maxhealth", 100 + HP);
        changeentityproperty(self, "health", THealth);
    }

}

In 2nd level of the stage:
Code:
background    Data\Bgs\3rave2/z01.gif
panel        Data\Bgs\3rave2/z02.gif
frontpanel    Data\Bgs\3rave2/z03.gif
order           a
direction       right



spawn    reweap
coords    160 210
at    0

spawn  light
flip   1
coords 283 244
at     0

spawn  light
flip   1
coords 1005 244
at     0

spawn  light
coords 144 244
at     0

spawn   1up
coords  20 230
at      0

#-------1

spawn   table
item    money
coords  165 225
at      0

spawn   chair
item    hotdog
coords  215 225
at      0

group   3 3
at      0

spawn   shermie
map     1
alias   Fancy
coords  380 170
at      0

Transforming from a weapon model to the original works fine with script, but when the level ends playing as a weapon model, it reverts back to the original model instead of retaining the weapon model for the next stage.

EDIT: There are no actual weapons like knives, bats, nunchakus, etc., to grab at all. But what I want is to switch from player model to a weapon model like weaponframe without grabbing weapons.

Do I have to use a didhitscript or a takedamagescript for playing a fake pain animation or something for changing model? Or do I have to change with a model property (changeentityproperty(actor, "model", "name_of_model"))?
 
Last edited:
Have you copied the weapon storing system yet?
I don't understand the question, but I believe I copied the animation names except one weapon model without anim run since it doesn't have running sprites. Both player and weapon models don't share the same color table with each other at all. How can I tell if the weapon storing system is copied? Maybe I don't have it defined. What does modelflag 4 do anyway? As well as 7? I see this here and I don't understand it.

modelflag {int}

  • Determines how weapon model copies animation and weaponlist from original model.
    • 0 = Animation and weaponlist are copied
    • 1 = Animation aren't copied but weaponlist are still copied
    • 3 = Animation and weaponlost aren't copied
  • Use this with weapon models of course.

I can send you my mod by PM if you like.
 
I take it that you haven't made/copied the weapon storing yet.
Since you copied Reweap from Shadows of Death, I'm going to use scripts from there as reference. All weapon items run wepo.c when picked up.
It's pretty long but I'll quote the important line related to weapon storing:
C:
      if(Item=="nunchaku"){
        setglobalvar("BilWep", 1);         // <--------------
        changeentityproperty(target, "weapon", 1);
      } else if(Item=="shuriken"){
        int Ammo = getentityproperty(self,"grabforce");

        setglobalvar("BilWep", 2);        // <--------------
        setglobalvar("BilShur", Ammo);
        changeentityproperty(target, "weapon", 2);
      } else if(Item=="sickle"){
        setglobalvar("BilWep", 3);        // <--------------
        changeentityproperty(target, "weapon", 3);
      }

The lines with <---------- are the ones storing weapon in global variable which is BilWep. This variable will later be read by Reweap to rearm Billy with stored weapon, if a weapon is stored in the former of course.
wepo.c has more scripts such as tossing previous weapon but we'll discuss that some other time.
Related to this, Billy has damage script called weplo.c which resets that variable to 0 if he's damaged when wielding a weapon.

Another thing, I've read my notes and apparently, there's no way to acquire current weapon with script. Therefore using weapon system from Shadows of Death is the best way for now.
Try copying this system I've discussed here.
 
Thanks Bloodbane. I copied everything and it works. Now, I want to try something new.

wepo.c has more scripts such as tossing previous weapon but we'll discuss that some other time.
Tell me about the weapon storing system. I understand the stored weapons, but I was lost on which script event to put for storing weapons. I'm trying not to rely on picking items for weapon change.

Related to this, Billy has damage script called weplo.c which resets that variable to 0 if he's damaged when wielding a weapon.
Nice. I would like to switch from weapon model to the original without picking or tossing weapons if it resets to 0.

Another thing, I've read my notes and apparently, there's no way to acquire current weapon with script.
Does that mean I cannot switch weapons without picking items with script?

I would like to do it like this one, but not locking weapon models for unlocking modes. You can take a look at it from 18:49-19:00, or you watch it from the beginning till the end, or somewhere around there where the weapon model leaves in the end of the level to the beginning without changing.
 
Does that mean I cannot switch weapons without picking items with script?
No. You can switch weapon anytime with or without script.
I was lost on which script event to put for storing weapons.
In my weapon system it's weapon's didhitscript which is item.c (stores gained weapon) and player's damagescript which is weplo.c (resets stored weapon to 0).
I'm trying not to rely on picking items for weapon change.
Why? when else you could change weapon if not by picking weapon item. Unless, your weapon is not regular weapon.
I would like to switch from weapon model to the original without picking or tossing weapons
Have you tried changing entity weapon property to 0?
where the weapon model leaves in the end of the level to the beginning without changing.
Ah that one, I used Reweap entity for that before. However, I realized that you could also use levelscript for this purpose.
 
Have you tried changing entity weapon property to 0?
Oh, yes. I forgot that I have tried it. I had the weapon system stored for a weapon model to reset the variable (with entity weapon property) to 0. My apologies, Bloodbane.

when else you could change weapon if not by picking weapon item. Unless, your weapon is not regular weapon.
Anytime, but only after you select a certain character, since she'll be the only one to change outfits in levels like her Psychic 9 or 10 finisher (which she transforms). Yeah, I feel like the weapon model is not meant to be a regular weapon, I guess. I'm kind of confused on what a regular weapon is between item/weapon picking or not, by leaving transformation.

Ah that one, I used Reweap entity for that before. However, I realized that you could also use levelscript for this purpose.
Cool! I could try that, but I want it to be for a specific character only. Even if I don't use levelscript, then reweap would be an option, which it works well for keeping it unchanged.

EDIT:

Because I want to make transformation commands like Shang Tsung does morph into any MK fighter in MK games especially 2 and 3. I'd like to make it like that.
 
Last edited:
To be precise, you'd need to store current weapon number aka currently held weapon into a global variable. Instead of name, it's best that the variable is player based aka the variables store weapon for each player.
So there is no way to save the stuff that are in the current level (stage) to use for all other stages until they are removed without using global variables?
I am trying to save some stuff to use in other stages in my experimental game, but I prefer not use global variables unless there is no other way because my game would be 4 players. Meaning I have to save 4 different global variables for each items. then retrieve them with for loop in the level.c .
Code:
for(i=0; i<4; i++){

}

Wouldn't this be too much for the system?

Thank you
 
Friend, that's not even a drop in the bucket. You'd have to store hundreds of values before the engine would even notice.

DC
That's great to hear!
This is what I have in the level.c
Code:
    for(i=0; i<4;i++){
        p = getplayerproperty(i, "entity");
        if(p != NULL()){
            setentityvar(p, "ExModeBindNum", 0);
            setentityvar(p, "EntityBindNum", 0);
            if(i == 0){
                void P1Orb = getglobalvar("P1SummonOrb");
                void P1_SecondSummon = getglobalvar("P1_SecondSummon");
                setentityvar(p, "SummonOrb", P1Orb);
                setentityvar(p, "SecondSummon", P1_SecondSummon);
            }
            if(i == 1){
                void P2Orb = getglobalvar("P2SummonOrb");
                void P2_SecondSummon = getglobalvar("P2_SecondSummon");
                setentityvar(p, "SummonOrb", P2Orb);
                setentityvar(p, "SecondSummon", P2_SecondSummon);
            }

           so on...
        }           
    }

Endlevel.c
Code:
for(i=0; i<4; i++){
        Player = getplayerproperty(i, "entity");
        if(Player != NULL()){
            log("\nPLAYER " + i + " " + Player);   

            if(i == 0){
                setglobalvar("P1SummonOrb", getentityvar(Player, "SummonOrb"));
                setglobalvar("P1_SecondSummon", getentityvar(Player, "SecondSummon"));
            }
            if(i == 1){
                setglobalvar("P2SummonOrb", getentityvar(Player, "SummonOrb"));
                setglobalvar("P2_SecondSummon", getentityvar(Player, "SecondSummon"));
            }
            so on...     
        }   
    }

Respawn1.c
Code:
    setentityvar(self, "SummonOrb", getentityvar(self, "SummonOrb"));
    setentityvar(self, "SecondSummon", getentityvar(self, "SecondSummon"));

This seems to work, but after player 1 dies and respawns in the stage (1 player mode), the values are all undefined (NULL).
It seems to be a lot of work just to persist the 2 variables across the stages....
I am not sure if I did it correctly, can you please advise?

Thank you so much for your help.
 
Because of this:
Code:
getentityvar(self, "SummonOrb"

If your entity dies, any variable on it get reseted.

You have two options:
- Use a indexed var (a bit harder to track, but easier to handle)
- Use a globalbar (easy to track, harder to handle)

Indexed vars won't have a chance to mess your saves, as they aren't as persistent as globalvars.
Global vars will stay in memory until the engine shut down or you destroy them.

see more information here Avoid Global Vars
 
If your entity dies, any variable on it get reseted.
Ehh, I did not know this. I am learning something new everyday!
Not a problem! This means I will have to code respawn1, 2.. similar to level.c then

Code:
void P1Orb = getglobalvar("P1SummonOrb");
void P1_SecondSummon = getglobalvar("P1_SecondSummon");
setentityvar(self, "SummonOrb", P1Orb);
setentityvar(self, "SecondSummon", P1_SecondSummon);

I am learning how to code the right way, so if you know any better code, please advise and I would be greatly appreciated!
Thank you so much for your help.

Edit:
Ehh, this will be a problem with the new items that being picked up... I will have to think up a better way

Edit 2:
I added the ondeathscript and it is working.
Can someone please take a look at the code below and see if there is ok?

Respawn1.c:
Code:
void P1Orb = getglobalvar("P1SummonOrb");
void P1_SecondSummon = getglobalvar("P1_SecondSummon");
setentityvar(self, "SummonOrb", P1Orb);
setentityvar(self, "SecondSummon", P1_SecondSummon);

character.txt:
Code:
ondeathscript    data/scripts/OnDeathSave.c

OnDeathSave.c:
Code:
    void self = getlocalvar("self");   //caller which is the player
    setglobalvar("P1SummonOrb", getentityvar(self, "SummonOrb"));
    setglobalvar("P1_SecondSummon", getentityvar(self, "SecondSummon"));

Thank you so much
 
Last edited:
Id make it all player number based and not name based thats first , also you pretty much need checks in spawn anims to swap to desired weapon number, yeah you lose wepons on death and it is desireable, you wouldnt want situation where you pick other character and he has a weapon of previous character, strange.
I handled 4 players like this .
Id just name globalvar( cause other get pwned when you die and all) P1weapno or some other name and thats about it, store it and read it back, clean it when needed, pass it when need it.
Code:
    @script
        void self = getlocalvar("self");
        void P1 = getplayerproperty(0,"entity"); 
        void P2 = getplayerproperty(1,"entity"); 
        void P3 = getplayerproperty(2,"entity"); 
        void P4 = getplayerproperty(3,"entity");
        void P1A = ((getentityproperty(P1, "a"))&&(getentityproperty(P1, "base")));
        void P2A = ((getentityproperty(P2, "a"))&&(getentityproperty(P2, "base")));
        void P3A = ((getentityproperty(P3, "a"))&&(getentityproperty(P3, "base")));
        void P4A = ((getentityproperty(P4, "a"))&&(getentityproperty(P4, "base")));
        int z = getentityproperty(self,"z");
        void e;
        if (((P1A == 0 )||(P2A == 0 )||(P3A == 0 )||(P4A == 0 ))&&(frame == 1)){
               changeentityproperty(P1,"noaicontrol",1);
                        changeentityproperty(P2,"noaicontrol",1);
                        changeentityproperty(P3,"noaicontrol",1);
                        changeentityproperty(P4,"noaicontrol",1);




        changeentityproperty(P1, "animation", openborconstant("ANI_FOLLOW1"));
        changeentityproperty(P2, "animation", openborconstant("ANI_FOLLOW1"));
        changeentityproperty(P3, "animation", openborconstant("ANI_FOLLOW1"));
        changeentityproperty(P4, "animation", openborconstant("ANI_FOLLOW1"));
        changeentityproperty(P1, "velocity", 0, 0, 0);
changeentityproperty(P2, "velocity", 0, 0, 0);
changeentityproperty(P3, "velocity", 0, 0, 0);
changeentityproperty(P4, "velocity", 0, 0, 0);
    setspawnentry("name", "ver");
    setspawnentry("coords", 460, z-250, 0);
    e=spawn();
        changeentityproperty(e, "animation", openborconstant("ANI_IDLE"));
     changeentityproperty(e, "direction", 1);
    clearspawnentry();

     }

    @end_script
 
Back
Top Bottom