Changing weapon with level up

kdo

Member
Hello guys... is there some way make the player automatically change his/her  weapon when reach certain level ( using level up script) ?

Something like:    level 1    - wapon 1
                              level 4    - wapon 2
                              level 8    - wapon 3
 
This is my script level up (from dungeon fighter mod)
I know about setweap, but i dont know how to insert  the setweap inthe script lines to works.

It works together another scripts, but  this one looks like the main script.


lvup.c

void lvup(int plIndex)
{
void score=getplayerproperty(plIndex,"score");
void ent=getplayerproperty(plIndex,"entity");
int oldLevel=getglobalvar("level."+plIndex);
int lv=getLevel(score);
if (oldLevel==NULL()){oldLevel=1;}
if (lv>oldLevel){
setAbi(plIndex,ent);
spawnLvup(ent);
}
setglobalvar("score"+plIndex,score);
}
void spawnLvup(void ent)
{
clearspawnentry();
setspawnentry("name", "levelup");
void vSpawn=spawn();
float fX =getentityproperty(ent, "x");
float fY = getentityproperty(ent, "a");
float fZ = getentityproperty(ent, "z");
changeentityproperty(vSpawn, "position", fX, fZ, fY + 1);
}
void setAbi(void plIndex,void ent)
{
void score=getplayerproperty(plIndex,"score");
void lv=getLevel(score);
changeentityproperty(ent,"maxhealth",getentityproperty(ent,"maxhealth")+2*(lv - 1));
changeentityproperty(ent,"maxmp",getentityproperty(ent,"maxmp")+2*(lv - 1));
changeentityproperty(ent,"health",getentityproperty(ent,"maxhealth"));
changeentityproperty(ent,"mp",getentityproperty(ent,"maxmp"));
setglobalvar("level."+plIndex,lv);
}
int getLevel(void score)
{
int lv;
if(score>2200000){
lv=20;
}else if(score>1980000){
lv=19;
}else if(score>1760000){
lv=18;
}else if(score>1540000){
lv=17;
}else if(score>1320000){
lv=16;
}else if(score>1100000){
lv=15;
}else if(score>880000){
lv=14;
}else if(score>660000){
lv=13;
}else if(score>440000){
lv=12;
}else if(score>220000){
lv=11;
}else if(score>160000){
lv=10;
}else if(score>110000){
lv=9;
}else if(score>70000){
lv=8;
}else if(score>40000){
lv=7;
}else if(score>20000){
lv=6;
}else if(score>10000){
lv=5;
}else if(score>5000){
lv=4;
}else if(score>2500){
lv=3;
}else if(score>1250){
lv=2;
}else{
lv=1;
}
return lv;
}
void getPlLevel(int plIndex)
{
void ent=getplayerproperty(plIndex,"entity");
if (!ent){return;}else{}
void score=getplayerproperty(plIndex,"score");
 
Thanks, kdo. A function was cut in your post but I know the system you're using :)

Try this script:
anim idle
@script
    void self = getlocalvar("self");
    int PIndex = getentityproperty(self,"playerindex");
    int lv = getglobalvar("level."+PIndex);

    if(frame>1 && lv>=2){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
...

This script will change player's animation to FOLLOW1 if player's level is 2 or higher. There's no weapon change in the script cause in FOLLOW1 that's where weaponframe will do the weapon change

You may need to declare another script like this in weapon 1, weapon 2 and so on for next level up with different level requirement

HTH
 
Iam using all this scripts:

data/scripts/score1.c
data/scripts/score2.c
data/scripts/score3.c
data/scripts/score4.c
data/scripts/reset.c
data/scripts/score1.c
data/scripts/spawn/player.c
data/scripts/spawn/player1.c
data/scripts/spawn/lvup.c
data/scripts/spawn/lvupsc.c

 
I tried your script Bloodbane, but doesnt work... probably i made something wrong.

#i copied the lines of your script end out it in my character idle animation like this:

anim idle
       
                @script
    void self = getlocalvar("self");
    int PIndex = getentityproperty(self,"playerindex");
    int lv = getglobalvar("level."+PIndex);

    if(frame>1 && lv>=2){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script

bbox 11 16 15 17
offset 19 32
loop 1
delay 22
attack 28 25 8 6 10 0 0 1 0 0
frame data/chars/kina/k1.png
attack 0 0 0 0 0 0 0 0 0 0
frame data/chars/kina/k2.png


#And i created a follow animation with the waponsframe command in the same character flag:

anim follow1

       

delay 10
        weaponframe 2 1
        offset 19 32
frame data/chars/kina/k1.png
frame data/chars/kina/k2.png
        frame data/chars/kina/k1.png
frame data/chars/kina/k2.png


#And this settings are including in my flag header ( this info are all from  swordsman txt):

modelflag 1

weapons swordsmana swordsman
weaploss 2

... :-\
 
When you say doesn't work, what happened? did it crashed or did nothing happened?
You need to level up to test the script of course

One more thing, all weapon models have been loaded right?
 
Ok, i put the script lines in player  txt  and nothing happened.
The level up script is runing normaly, player is reaching he level (up)2,3,4... but reach level 2 or higer level doesnt change nothing.
Looks like  all weapon models have been loaded right, i dont know whats is wrong.... :-[
 
Hmmm... I've tried the script myself and it works. However you need to modify your IDLE a bit into this:
Code:
anim	idle       
@script
    void self = getlocalvar("self");
    int PIndex = getentityproperty(self,"playerindex");
    int lv = getglobalvar("level."+PIndex);

    if(lv>=2){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
	loop	1
	delay	11
	offset	19 32
	bbox	11 16 15 17
	attack	28 25 8 6 10 0 0 1 0 0
	frame	data/chars/kina/k1.png
	frame	data/chars/kina/k1.png
	frame	data/chars/kina/k2.png
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/kina/k2.png

This is to make the script more responsive
Since you might be moving alot after getting a level up, you might want to declare above script in WALK animation like this:
Code:
anim	walk       
@script
    void self = getlocalvar("self");
    int PIndex = getentityproperty(self,"playerindex");
    int lv = getglobalvar("level."+PIndex);

    if(lv>=2){
      changeentityproperty(self, "velocity", 0, 0);
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
...

It's the same script + stopping script BTW

HTH
 
WOWWW!!! Now it works perfectly ... thanks a lot Bloodbane...
Now i'll try to put the same effect ( script) in each level up reached by the palyer lv2,lv3,lv4 and lv5.
Thank you friend...
 
One more thing, i notice that levelup  entity is spawned aleatorily, how can i change it to always spawn in the same position?
I didnt understand where/what i have to change in the script to  have not diferent spawn positions....
 
i notice that levelup  entity is spawned aleatorily, how can i change it to always spawn in the same position?

I'm not sure what you mean by aleatorily. I'm guessing what you mean by spawn in same position is spawn in same spot relative to screen e.g player 1's level up message will appear at left side, right?

BTW this is the function which does the message spawn:
Code:
void spawnLvup(void ent)
{
	clearspawnentry();
	setspawnentry("name", "levelup");
	void vSpawn=spawn();
	float fX = getentityproperty(ent, "x");
	float fY = getentityproperty(ent, "a");
	float fZ = getentityproperty(ent, "z");
	changeentityproperty(vSpawn, "position", fX, fZ, fY + 1);
	changeentityproperty(vSpawn, "direction", 1);
}

It's from lvup.c inside data/scripts/levelup folder
 
Yeah, i need to make level up message  appear at center of ecreen , sorry to say " aleatorily " , i mean " variation " that looks calculated  because it repeats.
I notice using  the levelup script a variation in the position of the menssage when its spawned, some times its shows at  left side , some times at right side....looks like its apppear in about 4 diferent positions.....each level earned changes the message position in X  axis, Y has no change.
I dont know how to make the message appear always in the same position....
I tried to change the number in the function 1 to 0, but aparentely has no effect..
Take a llok at this images, this is from the same game play, each one show the player reachin diferent lvs 2,3 and 4.

Btw this is a Drancia mod...

The image shows the diferent positions of leveup message when its spawned.
The second image  shows the message almost in the position that i whishi tha its always spawn...

[attachment deleted by admin]
 
Thanks guys...

The problem is solved... i removed this script line  from lvup.c :

changeentityproperty(vSpawn, "position", fX, fZ, fY + 1);
changeentityproperty(vSpawn, "direction", 1);

After move this lines, i justed the offset position of my levelup entity....so it works.. não its spawn always in the same position without any variation.

Thanks  guys ...you always help me a lot!!! ;)
 
Back
Top Bottom