Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Level Repeats? #395901
02/29/12 00:41
02/29/12 00:41
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70

I have few levels that player will go back and fort, but when every time I go back to previous level that level starts from beginning. All my tasks that have been done you can do them again.

Can someone give me code example on how to stop level repeats?


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Level Repeats? [Re: Siwler] #395904
02/29/12 00:56
02/29/12 00:56
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Looks like you're using level_load for changing levels. That means every time you load a level it will be exactly in its initial state. If you want to avoid that you have to save the game when leaving the level and later on load that game back when your player reenters that level.

The following commands might help you:
http://www.conitec.net/beta/asave.htm
http://www.conitec.net/beta/aload.htm


Always learn from history, to be sure you make the same mistakes again...
Re: Level Repeats? [Re: Uhrwerk] #395905
02/29/12 01:13
02/29/12 01:13
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
or just write a function that resets all your variables, example:

level_load("MAP.wmb");

taskComplete=OFF;
aiKilled=OFF;
weedSmoked=OFF;

laugh

Re: Level Repeats? [Re: Uhrwerk] #395906
02/29/12 01:56
02/29/12 01:56
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Thanks Uhrwerk asave.htm is samething that I was looking for.

But I still dont't get it, how do I call game_save and game_load from the same function and plus I have to do that for every lvl.

All game_saves I have to save them under the same STRING* name and number or do I have to save them under different STRING* name and number, same for game_load?

Do I have to call it throughout example:

Code:
while(level_load)
{
game_save("main", 1, SV-ALL);
else
game_load("main", 1);
}



I tried calling it as just
game_save("main", 1, SV-ALL); // before exiting level 1
and
game_load("main", 1);// after exiting level 2

that only works for one of the levels but the rest of levels still get reset.


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Level Repeats? [Re: darkinferno] #395907
02/29/12 02:07
02/29/12 02:07
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Thanks darkinferno

I'll look into your example, all thou it looks more complexed then just trying to save and load before and after level_loads.

Last edited by Siwler; 02/29/12 02:11.

Honesty will get you far, were dishonesty will get you only so far in life.

Re: Level Repeats? [Re: Siwler] #395911
02/29/12 04:55
02/29/12 04:55
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Save_game is for when you need to exit the game and come back in a new game. If you use global vars they will not be reset when a new level is loaded.

from the manual "The current level is closed, the cache holding level entity files is purged. All current entities in the old level are removed, thus all entity pointers referring to them can't be used anymore."

Darkinferno knows what he's talking about, go his route.

Further, look at how your levels are set up, do you have the player model already in the level at the starting position but the reload level is at a different position? If so it is better to create the player with script along with his position, along with anything else for that level that is not always the same.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: Level Repeats? [Re: FoxHound] #395985
02/29/12 23:32
02/29/12 23:32
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Yea I tried working with var and failed.

How do I check if entity is been removed and keep it removed on coming back from other levels.

Can someone give me a code example on this, Please?


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Level Repeats? [Re: Siwler] #395988
03/01/12 02:24
03/01/12 02:24
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
I dont think you need to check if the player was removed, level_load already removes all entities, so all you can run the same function every time you load a level;

You could have a function like:

Code:
function init_newLevel()
{

// create player
player= ent_create("player.mdl", spawnENT.x, playerFunc);
//reset vars
playerGotPistol =OFF;
playerGotShield =OFF;
}



now when you load a level, do:

Code:
level_load(newMap);
wait(3);
init_newLevel();



Re: Level Repeats? [Re: darkinferno] #395990
03/01/12 03:14
03/01/12 03:14
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Is this like of you have 5 monsters and if they are not killed you have to face them again when you return to the level. If so make a global avr for each monster and set it to 1. Now use that global var either in their while bracket or at the start of their function that they check to see if it is one and if not have them removed via script.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: Level Repeats? [Re: FoxHound] #396039
03/01/12 21:42
03/01/12 21:42
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Yes FoxHound, its like you said if I have 5 monsters in level one and I kill them, then I can proceed to the next level.
But I want player to be able to go back to the first level and complete some other tasks without having to kill those 5 monsters again.

So I have to ent_create("monster1.mdl", vector(10, 20, 30), monstersFunction);//(Ican't bring those 5 monsters throughout WED?) and define 5 different monster names and turn them into global var and set global vars to 1, then check them to see if they have been accomplished/removed and set their vars to 0?

I felt like this could be done by game_save and game_load each level, I guess not.

Last edited by Siwler; 03/01/12 22:29.

Honesty will get you far, were dishonesty will get you only so far in life.

Page 1 of 3 1 2 3

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1