Duke4.net Forums: Shadow Warrior - "New Episode" - Duke4.net Forums

Jump to content

  • 44 Pages +
  • « First
  • 16
  • 17
  • 18
  • 19
  • 20
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Shadow Warrior - "New Episode"

#511

You could pretty easily write a code generator inside Lua itself if manually converting everything is tedious. For example, using a small bit of data from your post above, I can dump some of it straight into a table and append commas to the end of each line:

local data =
{
	-- simple copy/paste then find+replace in selection "\n" -> ",\n"
	addsoundentry("NULL.VOC",      DIGI_NULL,          0,                    0,      0, 0, DIST_NORMAL, VF_NORMAL),
	addsoundentry("SWRDSTR1.VOC",  DIGI_SWORDSWOOSH,   PRI_HI_PLAYERWEAP,    -200,   200, 0, DIST_NORMAL, VF_NORMAL),
	addsoundentry("THROW.VOC",     DIGI_STAR,          PRI_HI_PLAYERWEAP, -100,    100, 0, DIST_NORMAL, VF_NORMAL),
	addsoundentry("STRCLNK.VOC",   DIGI_STARCLINK,     PRI_PLAYERAMBIENT,    0,      0, 0, DIST_NORMAL, VF_NORMAL),
	addsoundentry("NULL.VOC",      DIGI_NULL_STARWIZ,  PRI_LOW_PLAYERWEAP,   0,      0, 0, DIST_NORMAL, VF_LOOP),
	addsoundentry("UZIFIRE1.VOC",  DIGI_UZIFIRE,       PRI_HI_PLAYERWEAP,    0,      0, 0, DIST_NORMAL, VF_NORMAL),
}


then I write a dummy function to generate the table entries for me, as well as overriding the global table's __index metamethod so that I don't need to manually set DIGI_NULL to "DIGI_NULL" and so forth for every value:

setmetatable(_G,
{
	__index = function(t, k)
		-- return string for nonexistent values
		-- saves needing to manually specify each value
		return k
	end,
})

function addsoundentry(name, id, pri, pitch_lo, pitch_hi, voc_num, voc_dist, voc_flags)
	return
	{
		name = name,
		id = id,
		pri = pri,
		pitch_lo = pitch_lo,
		pitch_hi = pitch_hi,
		voc_num = voc_num,
		voc_dist = voc_dist,
		voc_flags = voc_flags,
	}
end


Then I just use a simple bit of code to output a table:

local file = io.open("out.lua", "wb")
file:write "sounds =\n{\n"
for k, soundentry in ipairs(data) do
	file:write "    {\n"
	for k, v in pairs(soundentry) do
		if type(v) == "string" then
			file:write(string.format("        %s = %q,\n", k, v))
		else
			file:write(string.format("        %s = %s,\n", k, v))
		end
	end
	file:write "    },\n\n"
end
file:write "}"
file:close()


Which yields this in out.lua:

sounds =
{
    {
        voc_flags = "VF_NORMAL",
        pri = 0,
        pitch_hi = 0,
        id = "DIGI_NULL",
        voc_dist = "DIST_NORMAL",
        pitch_lo = 0,
        name = "NULL.VOC",
        voc_num = 0,
    },

    {
        voc_flags = "VF_NORMAL",
        pri = "PRI_HI_PLAYERWEAP",
        pitch_hi = 200,
        id = "DIGI_SWORDSWOOSH",
        voc_dist = "DIST_NORMAL",
        pitch_lo = -200,
        name = "SWRDSTR1.VOC",
        voc_num = 0,
    },

    {
        voc_flags = "VF_NORMAL",
        pri = "PRI_HI_PLAYERWEAP",
        pitch_hi = 100,
        id = "DIGI_STAR",
        voc_dist = "DIST_NORMAL",
        pitch_lo = -100,
        name = "THROW.VOC",
        voc_num = 0,
    },

    {
        voc_flags = "VF_NORMAL",
        pri = "PRI_PLAYERAMBIENT",
        pitch_hi = 0,
        id = "DIGI_STARCLINK",
        voc_dist = "DIST_NORMAL",
        pitch_lo = 0,
        name = "STRCLNK.VOC",
        voc_num = 0,
    },

    {
        voc_flags = "VF_LOOP",
        pri = "PRI_LOW_PLAYERWEAP",
        pitch_hi = 0,
        id = "DIGI_NULL_STARWIZ",
        voc_dist = "DIST_NORMAL",
        pitch_lo = 0,
        name = "NULL.VOC",
        voc_num = 0,
    },

    {
        voc_flags = "VF_NORMAL",
        pri = "PRI_HI_PLAYERWEAP",
        pitch_hi = 0,
        id = "DIGI_UZIFIRE",
        voc_dist = "DIST_NORMAL",
        pitch_lo = 0,
        name = "UZIFIRE1.VOC",
        voc_num = 0,
    },

}


Edit: and with a few small changes you can get it generating the comments, too

This post has been edited by TheZombieKiller: 15 June 2017 - 10:01 AM

6

#512

That is sexy. If you have some time, can you run your script on all of user.lua? If not I can do it when I get home tonight but if you have a second to do it on user.lua I can just modify the code to read the data out of the tables and get this in tonight.

This post has been edited by icecoldduke: 15 June 2017 - 10:17 AM

1

#513

Here's all of the "addsoundentry" stuff converted into tables
Edit: Actually, this version is probably better

This post has been edited by TheZombieKiller: 15 June 2017 - 06:04 PM

3

#514

View PostTheZombieKiller, on 15 June 2017 - 03:34 PM, said:


I like that one best as well. I'm going to try and get it in tonight.

EDIT:
Do you have a example on parsing nested tables?

This post has been edited by icecoldduke: 15 June 2017 - 06:25 PM

1

#515

View Posticecoldduke, on 15 June 2017 - 06:09 PM, said:

Do you have a example on parsing nested tables?

Not currently, but if you can show me an example of the layout of these nested tables I could probably whip something up
1

#516

View PostTheZombieKiller, on 15 June 2017 - 06:31 PM, said:

Not currently, but if you can show me an example of the layout of these nested tables I could probably whip something up

I meant do you have a example on how to parse your table? I figured the terminology for the last example you gave was nested tables; am I wrong?

This post has been edited by icecoldduke: 15 June 2017 - 06:39 PM

1

#517

Oh, that's what you meant.
You'd basically just do something like this (from memory, I haven't done this in a while):

// the "sounds" table has been pushed onto the stack prior
if (lua_istable(L, -1))
{
    lua_pushnil(L); // starting key, will be popped by lua_next
    while (lua_next(L, -2))
    {
        // stack:
        // -1: value
        // -2: key
        // -3: sounds table
        
        // check if value is a table,
        // then grab the values from it

        // key should be a number
        // (the DIGI_* value)
        
        // pop value, key used for next iteration
        lua_pop(L, 1);
    }
}
else
{
    // error
}


This post has been edited by TheZombieKiller: 15 June 2017 - 06:57 PM

1

#518

Here is what I have so far and for some reason either lua_gettable fails or lua_istable fails. Can you see anything obviously wrong?

lua_getglobal(L, "sounds");
lua_gettable(L, -1);
if (lua_istable(L, -1))
{
	lua_pushnil(L); // null iterator
	while (lua_next(L, -2))
	{
		static int fxid = lua_tointeger(L, -1);

		lua_pop(L, 1);
	}
}

1

#519

lua_gettable expects a key on the stack, with the index passed to it being the index of the table to grab the table from.
lua_getglobal is already pushing the table onto the stack, so you can either omit the lua_gettable call, or do this:
lua_pushstring(L, "sounds");
lua_gettable(L, LUA_GLOBALSINDEX);


Edit: for reference, lua_getglobal is an alias for lua_getfield(L, LUA_GLOBALSINDEX, <key>)
Edit 2: Also,
static int fxid = lua_tointeger(L, -1);
should grab the value at index -2, rather than -1

This post has been edited by TheZombieKiller: 15 June 2017 - 07:12 PM

2

#520

I must be doing something stupid because this block of code is failing. Also LUA_GLOBALSINDEX is undefined.
lua_pushstring(L, "sounds");
lua_gettable(L, -1);
if (lua_istable(L, -1))
{
      ...
}


This post has been edited by icecoldduke: 15 June 2017 - 07:18 PM

1

#521

Your lua_gettable call is using index -1, which is the string you just pushed. If you change it to LUA_GLOBALSINDEX it should work (it's defined in one of the Lua headers, I forget which).
Edit: It seems that in recent versions of Lua, LUA_GLOBALSINDEX has been deprecated. Which means you will have to use lua_getglobal, or do this instead:

lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // or lua_pushglobaltable(L);
lua_pushstring(L, "sounds");
lua_gettable(L, -2);


This post has been edited by TheZombieKiller: 15 June 2017 - 07:23 PM

2

#522

View PostTheZombieKiller, on 15 June 2017 - 07:18 PM, said:

Your lua_gettable call is using index -1, which is the string you just pushed. If you change it to LUA_GLOBALSINDEX it should work (it's defined in one of the Lua headers, I forget which).
Edit: It seems that in recent versions of Lua, LUA_GLOBALSINDEX has been deprecated. Which means you will have to use lua_getglobal, or do this instead:

lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); // or lua_pushglobaltable(L);
lua_pushstring(L, "sounds");
lua_gettable(L, -2);


Would you be able to write up a quick function that loads the table? I feel like an idiot, I tried what you just mentioned and it gets passed the istable but I'm not able to pull anything out of it :/.
1

#523

This would probably work (untested):

lua_getglobal(L, "sounds");
if (lua_istable(L, -1))
{
    lua_pushnil(L);
    while (lua_next(L, -2))
    {
        static int fxid = lua_tointeger(L, -2);
        
        if (lua_istable(L, -1))
        {
            char *name;
            int pri, pitch_lo, pitch_hi,
                voc_num, voc_dist, voc_flags;
            
            int len = lua_objlen(L, -1);
            for (int i = 1; i <= len; i++)
            {
                lua_rawgeti(L, -1, i);
                
                switch (i)
                {
                case 1: name      = lua_tostring(L, -1);  break;
                case 2: pri       = lua_tointeger(L, -1); break;
                case 3: pitch_lo  = lua_tointeger(L, -1); break;
                case 4: pitch_hi  = lua_tointeger(L, -1); break;
                case 5: voc_num   = lua_tointeger(L, -1); break;
                case 6: voc_dist  = lua_tointeger(L, -1); break;
                case 7: voc_flags = lua_tointeger(L, -1); break;
                }
                
                lua_pop(L, 1);
            }
            
            // do things with the values
        }
        
        lua_pop(L, 1);
    }
}
else
{
    // error
}


This post has been edited by TheZombieKiller: 15 June 2017 - 08:43 PM

3

#524

I have just committed your work TheZombieKiller. It turns out there was a error in my original user.lua script where I was using DIGI_NULL_HUGEEXP but it wasn't defined(but it had a entry in the table). The issue has been fixed and thank you again TheZombieKiller.

Here is the CL
https://github.com/j...82513d2c1d540f4

This post has been edited by icecoldduke: 15 June 2017 - 09:36 PM

3

#525

Here are the ambient sounds, too
3

#526

I have committed your ambient and level info tables :P.
0

#527

I have also discovered a bug where some player sounds are not playing properly. I will fix this when I get home tonight.

This post has been edited by icecoldduke: 16 June 2017 - 05:00 AM

1

User is offline   Forge 

  • Speaker of the Outhouse

#528

arming the nuke breaks weapons sounds

http://www.mediafire...6-40-45-201.mp4
0

User is offline   Ninjakitty 

#529

View PostForge, on 16 June 2017 - 03:45 PM, said:

arming the nuke breaks weapons sounds

http://www.mediafire...6-40-45-201.mp4

Yeah, he knows :P LOL
0

#530

View PostForge, on 16 June 2017 - 03:45 PM, said:

arming the nuke breaks weapons sounds

http://www.mediafire...6-40-45-201.mp4

Yes I am aware of that bug, that paticular one is top priority for me right now.
1

User is offline   Ninjakitty 

#531

View Posticecoldduke, on 16 June 2017 - 04:18 PM, said:

Yes I am aware of that bug, that paticular one is top priority for me right now.

I'm pretty sure it also happens at random times.
0

#532

View PostNinjakitty, on 16 June 2017 - 04:26 PM, said:

I'm pretty sure it also happens at random times.

I think I fixed the issue. I switched all digi sounds over to the GameVar. This fixed sound issues such as the player not playing the pain sound when hit.

There is still the issue with the rocket launcher and the nuke.

This post has been edited by icecoldduke: 16 June 2017 - 05:43 PM

0

User is offline   Forge 

  • Speaker of the Outhouse

#533

Finished twin dragon - reported pretty much everything that I found - even if it was accidentally redundant.

noticed the end sequence animation was fixed. Nice.

This post has been edited by Forge: 16 June 2017 - 08:35 PM

0

User is offline   Ninjakitty 

#534

View PostForge, on 16 June 2017 - 08:35 PM, said:

Finished twin dragon - reported pretty much everything that I found - even if it was accidentally redundant.

noticed the end sequence animation was fixed. Nice.

Noice!
:P
0

User is offline   Forge 

  • Speaker of the Outhouse

#535

I think I may have had about three random crashes for the whole episode - but considering all the load and save spawning & restarting I was doing, they were too infrequent, and too inconsistent to report. Especially since I couldn't reproduce one intentionally after one happened.

This post has been edited by Forge: 16 June 2017 - 09:13 PM

0

#536

I discovered a bug in the branch where weapons weren't becoming bloody. I have fixed the issue and moved all of that logic over to game.lua. You guys can now add custom bloody weapons to the game or expand the logic for when bloody weapons get displayed. Or later on you guys can have custom weapon override types(example: glowing sword when you pick up a powerup, or quad damage powerups).

-- game.lua
--

require("swdata/scripts/user")

-- UK panzies have to have darts instead of shurikens.
local walmart_dart_table =
{
	[STAR_REST]     = 2510,
	[STAR_REST + 1] = 2511,
	[STAR_REST + 2] = 2512,
	[STAR_REST + 3] = 2513,
	[STAR_REST + 4] = 2514, 
	[STAR_REST + 5] = 2515, 
	[STAR_REST + 6] = 2516, 
	[STAR_REST + 7] = 2517,
}

local weapon_bloody_table = 
{
	[SWORD_REST] 	= BLOODYSWORD_REST,
	[SWORD_SWING0] 	= BLOODYSWORD_SWING0,
	[SWORD_SWING1] 	= BLOODYSWORD_SWING1,
	[SWORD_SWING2] 	= BLOODYSWORD_SWING2,
	
	[FIST_REST] 	= 4077,
	[FIST2_REST] 	= 4051,
	[FIST_SWING0] 	= 4074,
	[FIST_SWING1] 	= 4075,
	[FIST_SWING2] 	= 4076,
}

local weapon_shotgun_table = 
{
	[SHOTGUN_REST]     = 2227,
	[SHOTGUN_RELOAD0]  = 2227,
	[SHOTGUN_RELOAD1]  = 2226,
	[SHOTGUN_RELOAD2]  = 2225,
}

-- PanelGetDisplayWeaponOverride
-- Returns the override picnum for current UI weapon picnum
--

function PanelGetDisplayWeaponOverride(picnum, bloody, parentallock, usedarts, WpnShotgunType)
	local new_picnum = picnum;
	
	if usedarts == 1 then
		if walmart_dart_table[picnum] ~= nil then
			new_picnum = walmart_dart_table[picnum];
		end
	end
	
	if bloody == 1 and parentallock == 0 then
		if weapon_bloody_table[picnum] ~= nil then
			new_picnum = weapon_bloody_table[picnum];
		else
			if picnum == STAR_REST then
				if usedarts == 0 then
					new_picnum = 2138;
				else
					new_picnum = 2518;
				end
			end
		end
	end
	
	if WpnShotgunType == 1 then
		if weapon_shotgun_table[picnum] ~= nil then
			new_picnum = weapon_shotgun_table[picnum];
		end
	end
	
	return new_picnum;
end


View PostForge, on 16 June 2017 - 09:11 PM, said:

I think I may have had about three random crashes for the whole episode - but considering all the load and save spawning & restarting I was doing, they were too infrequent, and too inconsistent to report. Especially since I couldn't reproduce one intentionally after one happened.

The crashes I think your experiencing are still from the audio system. Thats great to know were getting the A bugs(crashes/non progs) cleared out.

This post has been edited by icecoldduke: 17 June 2017 - 05:59 AM

0

User is offline   NY00123 

#537

Well, I can't say I've played Shadow Warrior a lot (although I completed the game and these two old add-ons). Nevertheless, it is great to see someone is doing this work!

Now, there may be different opinions on the progress of this specific project, but I'll say something about the addition of modding capabilities, which isn't even specific to any game.

Once a modding-related feature is added, it's safer to assume you cannot go back. One should take into account the ability to make mods work on *future* revisions of this codebase, not just any current rev.

Obviously, it's not like we want to support a large library of 20+ years old Win32 programs. Still, it can make it more difficult to expend the source port if preserving (some level of) compatibility with existing mods is desired. This is why there should be some thoughts before specific capabilities are added (if there weren't already).

This post has been edited by NY00123: 17 June 2017 - 06:28 AM

1

#538

There are a couple people making makefiles for my depot and I wanted to share the latest CL that went into the depot. A week ago I created the GameVar class to expose variables from Lua to C. It was a wrapper class so I could accomplish this task without having to touch a fuck ton of code and potentially break a whole bunch of code. In some cases sound pointers were not being passed around properly and it was because the order in which the global vars were being constructed happened before the GameVar class constructors. I have fixed the issue by moving all gamevars to _gamevars.cpp in code/swgame/autoload/ folder. Adding "_" to a filename in the Visual Studio IDE makes it so that file gets linked in first. If you are making makefiles, please ensure _gamevars.cpp is compiled before any other code in swgame. I will make proper cmake files at some point, just wanted to make everyone aware of the latest changes.

I have also fixed a memory corruption bug due to huge issue in the original code. In the AI attribute structure there is a sound array with 11 entries and in 90% of cases where that structure was used, it wasn't filled in all the way. I fixed that as well in the latest CL.

View PostNY00123, on 17 June 2017 - 06:26 AM, said:

Once a modding-related feature is added, it's safer to assume you cannot go back. One should take into account the ability to make mods work on *future* revisions of this codebase, not just any current rev.

This is a great question that I don't have time to fully respond to at the moment. But I completely, 100% agree with you.

This post has been edited by icecoldduke: 17 June 2017 - 07:53 AM

0

User is offline   Master O 

#539

View Posticecoldduke, on 17 June 2017 - 07:51 AM, said:

There are a couple people making makefiles for my depot and I wanted to share the latest CL that went into the depot. A week ago I created the GameVar class to expose variables from Lua to C. It was a wrapper class so I could accomplish this task without having to touch a fuck ton of code and potentially break a whole bunch of code. In some cases sound pointers were not being passed around properly and it was because the order in which the global vars were being constructed happened before the GameVar class constructors. I have fixed the issue by moving all gamevars to _gamevars.cpp in code/swgame/autoload/ folder. Adding "_" to a filename in the Visual Studio IDE makes it so that file gets linked in first. If you are making makefiles, please ensure _gamevars.cpp is compiled before any other code in swgame. I will make proper cmake files at some point, just wanted to make everyone aware of the latest changes.

I have also fixed a memory corruption bug due to huge issue in the original code. In the AI attribute structure there is a sound array with 11 entries and in 90% of cases where that structure was used, it wasn't filled in all the way. I fixed that as well in the latest CL.


This is a great question that I don't have time to fully respond to at the moment. But I completely, 100% agree with you.


Outside of all the talk about modding, what else actually remains to be done in terms of Shadow Warrior itself and its 2 addons percentage wise?
0

User is offline   Forge 

  • Speaker of the Outhouse

#540

i'm still using the last snapshot - i don't update and compile my own.

this may, or may not still be an issue

Wanton Destruction crash a second or two after loading this save
polymer
no error messages - just quits straight to the desktop

Attached File  game0_1.zip (188.71K)
Number of downloads: 1
0

Share this topic:


  • 44 Pages +
  • « First
  • 16
  • 17
  • 18
  • 19
  • 20
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options