Aeternitas
Участник форума
- Регистрация
- 1 Июл 2010
- Сообщения
- 125
- Благодарности
- 174
- Баллы
- 185
Hi,
I have a big problem. I would like to create Endurance into my modification. In fact, I already did and it functions good and without problems if you don't save-load the game. Then come problems. First I describe the problem.
I start the game and play and the endurance (let say maximum is 100) falls slowly. I save the game (endurance be for example 75). Then I play on. After a while I stop playing (endurance is now 50) and load the saved position. Looking on the endurance I realized it has weird values. It should have the value from time of saving (75) but it has the still new value (50). Ok, I try again and load it again. The value is then 45. Load again. 43 ... etc. After some time, the loading of the position saved at endurance 75 still gives to endurance value 0. If I restart the game (leave it and then start again) and load the save position at endurance 75, it gives the right value 75.
Now I describe, how I create it. First I create the variables.
Help function:
Definition of the endurance function:
In Init_Global function:
Of course, Ikarus and LeGo is initialized.
I have one more question. I realized the Init_Global function is not called any time by loading the world. I tried this. I started new game (Init_Global is called), then saved it. Then load the saved position (Init_Global is called). Then start new game (Init_Global is NOT called). By the last start is Init_Global not called. It should be but it's not. Why?
Can you help me with it? Thanx in advance.
I have a big problem. I would like to create Endurance into my modification. In fact, I already did and it functions good and without problems if you don't save-load the game. Then come problems. First I describe the problem.
I start the game and play and the endurance (let say maximum is 100) falls slowly. I save the game (endurance be for example 75). Then I play on. After a while I stop playing (endurance is now 50) and load the saved position. Looking on the endurance I realized it has weird values. It should have the value from time of saving (75) but it has the still new value (50). Ok, I try again and load it again. The value is then 45. Load again. 43 ... etc. After some time, the loading of the position saved at endurance 75 still gives to endurance value 0. If I restart the game (leave it and then start again) and load the save position at endurance 75, it gives the right value 75.
Now I describe, how I create it. First I create the variables.
Код:
var int enduranceh_max;
var int enduranceh;
Help function:
Код:
func void EndurancehInc(var int x)
{
enduranceh = enduranceh + x;
if (enduranceh < 0)
{ enduranceh = 0; }
else if (enduranceh > enduranceh_max)
{ enduranceh = enduranceh_max; };
};
Definition of the endurance function:
Код:
func void BeHungryStart()
{
var int tmp;
tmp = hunger_index - (setNiveau*6000);
if (be_hungry_alive==1)
{
tmp = tmp / 2;
};
if (tmp < 1000)
{ tmp = 1000; };
FF_ApplyOnceExt(BeHungryLoop,tmp,-1);
};
func void BeHungryLoop()
{
if (enduranceh > 0)
{
EndurancehInc(-1);
}
else
{
EndurancehInc(-1);
var int tmp;
tmp = hero.attribute[ATR_HITPOINTS_MAX] / 40;
if (tmp<1) { tmp=1; };
tmp=hero.attribute[ATR_HITPOINTS]-tmp;
if (tmp<1)
{
if (be_hungry_alive==1)
{
tmp=1;
}
else
{
tmp=0;
};
};
hero.attribute[ATR_HITPOINTS] = tmp;
};
};
In Init_Global function:
Код:
BeHungryStart();
Of course, Ikarus and LeGo is initialized.
I have one more question. I realized the Init_Global function is not called any time by loading the world. I tried this. I started new game (Init_Global is called), then saved it. Then load the saved position (Init_Global is called). Then start new game (Init_Global is NOT called). By the last start is Init_Global not called. It should be but it's not. Why?
Can you help me with it? Thanx in advance.