Scripts / Keep Weapons Over Levels

Author
Message
turtle123484
8
Years of Service
User Offline
Joined: 12th Aug 2015
Location:
Posted: 12th Aug 2015 03:50
I need a script to keep weapons from one level to another. I don't want the ammo to stay the same though so if you take the weapon id's at the very end of the level is there a way to give them to you on the next level when you spawn?
PM
turtle123484
8
Years of Service
User Offline
Joined: 12th Aug 2015
Location:
Posted: 12th Aug 2015 03:54
I don't see my message so I'm going to rewrite it, this forum is confusing me. I need a script to keep the weapons you had from one level onto the other, I don't need the ammo the same though so if you enter the win zone and get the weapon id's can you spawn them in on the next level.
PM
Errant AI
Forum Support
17
Years of Service
User Offline
Joined: 24th Aug 2006
Location: [REDACTED]
Posted: 12th Aug 2015 04:00
New accounts require topics and posts to be manually approved by a moderator. Please be patient and your post will show up once approved.

I don't believe there is yet an accessible value stored for ammo count. While it should be possible to be able to keep track of what weapons the player has found and then re-issue them in a new level, accurate ammo quantities wouldn't be able to be carried over. Hopefully we will see level to level persistence eventually.
Gigabyte P67A-UD4-B3, Intel Core i7 2600K (passmark 8555), 16GB Corsair DDR3, EVGA GTX 970 SC (passmark 8637), Win7 Pro 64-bit SP1, Primary monitor @ 1920x1080, secondary monitor @ 1024x1280
Moshroom
8
Years of Service
User Offline
Joined: 18th Jul 2015
Location: Finland
Posted: 18th Aug 2015 21:42 Edited at: 18th Aug 2015 21:43
Quote: "While it should be possible to be able to keep track of what weapons the player has found and then re-issue them in a new level..."


If LUA commands for this do exist, what are they?

If I've understood correctly, there are only g_PlayerGunCount and g_PlayerGunID. The former tells how many guns have been collected and the latter tells which slot is currently active? So these are pretty much useless if you want to store weapon data from map to map.

In the other hand, is there a LUA command to put certain weapon to certain slot? If so, what is it? As far as I know, there is only AddPlayerWeapon(e), which can only add weapon data from the single entity where it is called from (as the only parameter that can be used to call this command is e).
Corno_1
GameGuru Tool Maker
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 18th Aug 2015 22:00
take the weapon.lua and delete everything from it which restrict the take process.
Then place in the next level all weapons you have and give them this script.

You maybe must save in a small txt file wich weapon you collected in the last level and restore this.

That is what Errant AI mean, I think
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Aug 2015 01:04
you can simply store the names and work from there rather than id's etc
but yh, no ammo count.
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Moshroom
8
Years of Service
User Offline
Joined: 18th Jul 2015
Location: Finland
Posted: 19th Aug 2015 16:27 Edited at: 19th Aug 2015 16:32
Quote: "you can simply store the names and work from there rather than id's etc"


Sorry for repeating, but is there really a LUA-command for this?

I know it's possible to edit weapon.lua and add some global variables to store the data manually, but my question is, is there a way to read the name (or id) of weapon that's already collected? For example is there a command to call weapon name from slot 3. If so, what is this LUA command?
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Aug 2015 18:43
no you would do it by editing the script so it's stored at the time of pick up - the name is already stored for weapons but as you say, it's not for storing that it's collected or anything but merely used to show the name when the player is looking at it.
it would only require 2 lines to do (plus 2 declarations) ;
1 to store a counter (so we can adjust the array)
and 1 to store the actual name
so it'll end up looking something like this



then store the values into a text file when the level finished (dont remember the code off the top of my head but it's in the lua manual)

then when the new level is loaded you would loop through a predetermined number of weapons (based on however many were in the previous level but any number that's greater will be fine too) and check the gun_name and give the corresponding weapon



the only slot we have access to is the players current weapon (which means if a gun is collected but never held then it wont be stored)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Login to post a reply

Server time is: 2024-05-06 14:03:16
Your offset time is: 2024-05-06 14:03:16