View unanswered posts | View active topics It is currently 29 Mar 2024, 11:32



Reply to topic  [ 10 posts ] 
Topic about derping around with MDK2's scripts/console. 
Author Message
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Topic about derping around with MDK2's scripts/console.
I found some really intresting stuff in game scripts, like this thing:

Image

I will post cool things that I find.
---

Related Links:
Gob/Object/Item IDs are found *here*

---

First one going to be slow-mo command thing:
If you don't know how to open console - You just press ~ to open console, and ESC to close it.
Also remember, all things are case-sensitive.
Now type one of those:
Code:
chForceDeltaT(0.01) -- for slo-mo.
chForceDeltaT(0.1)  -- for fast-forward.
chForceDeltaT(0)    -- is normal speed.
chForceDeltaT(1/60) -- is also normal speed, but this is more proper way to do it.

Here's video with me using 1/60 and 1/2: *click*. (Note: I bound those commands to keys. This is not easiest thing to do, so I will post how to do it later.)
Seems like 0.2 (1/5) and higher breaks parachute mechanics.
---

Because this is first time I'm posting those, here's a bonus:
Code:
chSndSwitchMusic(-1) -- Switches music off.
chSndSwitchMusic(1)  -- Switches music to main menu theme.
chSndSwitchMusic(n)  -- Switches music to N.

---

Let's spawn some doc stuff in!
Code:
mdkDocGiveItem(mdkGetPlayerGob(), OBJ_LIGHTER, 1) -- Gives you 1 of Lighter.
mdkDocGiveItem(mdkGetPlayerGob(), 360, 1337)      -- Gives you 1337 of Baguette.

mdkDocGiveItem(docGob, gobId, quantity)           -- This is syntax of function


Thing you didn't knew: Toaster + Baguette = Toast.

Note: Your game will crash, if you use Plutonium without having Hyde created. This is done automatically on levels 6, 9 and 12 (a.k.a. 10 with Doctor), but for other levels you will need to type this:
Code:
CreateHyde()


Now, this is science!
---

Before we move on, there's similar commands to previous one:
Code:
mdkKurtRemoveItem(mdkGetPlayerGob(),OBJ_GRENADEITEM, 1)
mdkDocRemoveItem(mdkGetPlayerGob(),OBJ_LIGHTER, 1)

I don't think I have to explain it.
Also there's two more for doctor:
Code:
mdkDocRemoveHeldItem(mdkGetPlayerGob(),0,1) -- Removes 1 of item that you hold in left hand
mdkDocRemoveHeldItem(mdkGetPlayerGob(),1,1) -- Removes 1 of item that you hold in right hand

mdkDocGetHeldItem(mdkGetPlayerGob(), 0)     -- Returns item hold in left hand
mdkDocGetHeldItem(mdkGetPlayerGob(), 1)     -- Returns item hold in right hand

---

Now it's time to kinda explain gobs and bobs.
Basicaly, gob is any object in-game that's not static. Each gob type have an ID.
Bob is gob that's controled by player.

This is code that creates function for spawning gobs in front of bob.
Code:
function make(type)
b=mdkGetPlayerGob()
g=mdkCreateObjectLua("",type,scene)
QuatYDir(g.position,b.orientation)
VectorMul(g.position,6)
VectorAdd(g.position,b.position)
end

Note: You can type it all in one line.

Let's go through it really quick:
Code:
function make(type)                 -- Define function make with one parameter called type
b=mdkGetPlayerGob()                 -- Set b to bob (See note 1 below)
g=mdkCreateObjectLua("",type,scene) -- Set g to new gob, with no name, but with specified type.
QuatYDir(g.position,b.orientation)  -- This does some manipulations with position of gob. (See note 2 below)
VectorMul(g.position,6)             -- This multiplies position of gob by 6, so gob will be 6 units away from bob, instead of one.
VectorAdd(g.position,b.position)    -- This adds bob's position to gob, moving it right in front of gob.
end                                 -- End of function

Note 1: due to nature of lua (especially the version they used in MDK2) you never need to update b, because lua transfers pointers and not values. What that means: if you have x=5, and you do y=x, then do x=x+1, in the end y==6. That doesn't seem to work everywhere, but it works with gobs. It's really hard to explain if you don't know programming, but I guess I could do it: In lua things stored using pointers, i.e. variables are storing pointers instead of values. Pointer is basicaly memory address to value, so when I have y=x they point at same address, because = operator transfers address instead of value.

Note 2: After this operation, gob will be in 1 unit away from 0,0,0 in direction you're looking at.

Now you can use it using make(OBJ_something)
---

Time for difficulty info!
Difficulty is floating point value.
That means it's can be any number:
Code:
mdkSetDifficulty(0.2)  -- Easy
mdkSetDifficulty(0.35) -- Normal
mdkSetDifficulty(0.5)  -- Hard
mdkSetDifficulty(1.0)  -- Jinkies!
mdkSetDifficulty(2.0)  -- Something I call Jinkies! 2.0


Side note: In MDK 2 HD those didn't changed. They tweaked difficulty some other way.

I recommend you try anything from 2 to 10 and also try 100, -1 and 0.

Now on how to add new items to New Game menu. (Side note: Menu manipulation is huge! More on this later.)
Code:
item = mdkCreateMenuItem(menu.diff, "Jinkies! 2.0")
item.Select = function() mdkSetDifficulty(2.0) menu.diff.Go() end

-- Also code below will work
mdkCreateMenuItem(menu.diff, "Jinkies! 2.0").Select = function() mdkSetDifficulty(2.0) menu.diff.Go() end

---

Now onto auto save info:
Here's auto.sav
Code:
## |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
---+-------------------------------------------------
00 | 00 00 00 00 00 00 00 00 01 00 00 00 09 00 00 00
10 | cd cc 4c 3e

(Level 1 - Easy)

You can see 0x8 and 0xC are 1 and 9, which is starting level/room combination for first level.
Last four bytes are difficulty, but if we convert it, we will not get 0.2.
Conclusion: Things are little endian, and 0xCD 0xCC 0x4C 0x3E are actually meaning 0x3E4CCCCD, which is 0.2.

Oh, I think I forgot to say that floating point numbers are stored in IEEE 754.

Full file format can be written as:
Code:
0x00 - 0x07 - Unknown
0x08 - 0x0b - Level
0x0c - 0x0f - Room
0x10 - 0x13 - Difficulty (float)
All values are little-endian.


I will make my own program for generating those.
---

I'm actually runing out of material. I'm making new one slower than I post old one.

Code:
mdkGobSyncEnterStasis(gob) -- Makes gob disappear, and unable to move.
mdkGobSyncExitStasis(gob)  -- Reverts previous command.
PlayerEnterStasis()        -- Those two commands are same as previous ones, except for that they work on player.
PlayerExitStasis()         -- ^
omGobIsStasis(gob)         -- returns 1 if gob is in stasis.
luaGobExitStasis(gob)      -- Checks if gob exists, and then exits it from stasis. (basicaly, this is more secure version of normal exit command)
mdkDisableGui()            -- Disables GUI
mdkEnableGui()            -- Enables GUI

---

Time to do put some information about gob manipulation:
Code:
gob.position
gob.positon.x
gob.positon.y
gob.positon.z --note that this is height
-- Do I even need to explain it?

-- Here's example code of what you can do with those:
pos=bob.position
omGobEnterStasis(camera) -- Removes old camera, to fix rendering glitches.
CreateMax()
bob.position=pos

Note that bob is equal to last player gob created with CreateSomething() command

Also note that if you do x=bob.position.x, x will not auto update, but if you do pos=bob.position, bob.x will auto update.
This is because lua pointers are weird.

There's really alot of stuff you can do with those...
---

Comming Soon:
  • Cool trick I discovered, that's not related to scripts/console.
  • Keybinds
  • Menu manipulation.
  • ------stuff above this line was discovered like year ago, but I had technical problems with this forum, and couldn't post it before. I will post it durning this/next week------
  • More gob manipulation.
  • Demos.
  • Some lua lessons (maybe).

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


Last edited by Egor305 on 05 Jun 2014, 09:37, edited 9 times in total.



29 May 2014, 12:55
Profile
Administrator
Administrator
User avatar

Joined: 25 Jun 2010, 10:43
Posts: 74
Post Re: Topic about derping around with MDK2's scripts/console.
Hi Egor! It's nice to see you here after your problems with registration. I hope everything is good now.

You've found very interesting things, I must say. Can't wait for more info ;) I've found something similar some time ago.

This is a command for spawning enemies. We can spawn almost every enemy (it works only on the second level [first room]) :

mdkCreateObjectLua("grunt", OBJ_GRUNT, mdkGetScene())

And here is the example of script for spawning weapons at certain points :

SpawnObject(l2_r1, OBJ_UZI,"l2_r1magnum1").

l2 - level 2
r1 - room 1
obj_uzi - weapon to spawn, in this case - uzi
l2_r1magnum1 - this is a point where our weapon will be spawned

KurtGetNaked() - this will allow us to play as Kurt in boxer shorts.

There is also a command for changing / creating player's model :

CreateKurt()
CreateMax()
CreateDoc()
CreateHyde()

But unfortunately we can't move after this.

_________________
http://hectichq.com


29 May 2014, 21:38
Profile WWW
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Re: Topic about derping around with MDK2's scripts/console.
Mnich wrote:
Hi Egor! It's nice to see you here after your problems with registration. I hope everything is good now.

You've found very interesting things, I must say. Can't wait for more info ;)

Thanks!

Mnich wrote:
I've found something similar some time ago.

This is a command for spawning enemies. We can spawn almost every enemy (it works only on the second level [first room]) :

mdkCreateObjectLua("grunt", OBJ_GRUNT, mdkGetScene())

Actually, there's way more parameters to this function, but for now, I will say that you can use scene instead of mdkGetScene(). Also mdkCreateObjectLua/SpawnObject are interchangeable functions (i.e. you can do SpawnObject(l2_r1,OBJ_GRUNT,"l2_r1magnum1"))

Mnich wrote:
KurtGetNaked() - this will allow us to play as Kurt in boxer shorts.

That's well known one. :/
One thing that I recently found, is that there are 6 unused keybinds: COM_CHEATEN1, COM_CHEATEN2, COM_CHEATA, COM_CHEATB, COM_CHEATX, COM_CHEATY (leftovers from dreamcast version) and if you bind all of them, you can actually activate this cheat. To do so, you hold CHEATEN1 and CHEATEN2, and they you press X,X,Y,X cheat buttons. This works only on title screen. There are more cheats, but most of them won't work unless you modify scripts (i.e. they are commented out)

Mnich wrote:
There is also a command for changing / creating player's model :

CreateKurt()
CreateMax()
CreateDoc()
CreateHyde()

But unfortunately we can't move after this.

Yeah, I know those. There is a way to move player around. ;)

--

I will edit my first post later this day, and will add info on spawning items with doctor.

EDIT: edited first post.

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


Last edited by Egor305 on 31 May 2014, 13:15, edited 1 time in total.



30 May 2014, 11:16
Profile
Administrator
Administrator
User avatar

Joined: 25 Jun 2010, 10:43
Posts: 74
Post Re: Topic about derping around with MDK2's scripts/console.
I really need to install my MDK2 again. I always wanted to spawn an enemy or weapons. It's not like I want to cheat, but you know, after all these years .. it can be fun! :)

_________________
http://hectichq.com


31 May 2014, 07:54
Profile WWW
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Re: Topic about derping around with MDK2's scripts/console.
Added info on mdkDocRemoveItem() and mdkDocRemoveHeldItem()
EDIT: Also added mdkDocGetHeldItem()
EDIT: Added auto-save/difficulty info.

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


01 Jun 2014, 09:42
Profile
Administrator
Administrator
User avatar

Joined: 25 Jun 2010, 10:43
Posts: 74
Post Re: Topic about derping around with MDK2's scripts/console.
Egor305 wrote:
Mnich wrote:
There is also a command for changing / creating player's model :

CreateKurt()
CreateMax()
CreateDoc()
CreateHyde()

But unfortunately we can't move after this.

Yeah, I know those. There is a way to move player around. ;)


Write something more about this.

Besides,

Egor305 wrote:
chForceDeltaT(0.01) -- for slo-mo.


This isn't slo-mo. It's quite fast actually.

_________________
http://hectichq.com


03 Jun 2014, 13:09
Profile WWW
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Re: Topic about derping around with MDK2's scripts/console.
Mnich wrote:
Egor305 wrote:
Mnich wrote:
There is also a command for changing / creating player's model :

CreateKurt()
CreateMax()
CreateDoc()
CreateHyde()

But unfortunately we can't move after this.

Yeah, I know those. There is a way to move player around. ;)


Write something more about this.


Still doing research on those, so probably going to post info about it tomorrow. (EDIT: I might post it little bit late than usual)

Mnich wrote:
Egor305 wrote:
chForceDeltaT(0.01) -- for slo-mo.


This isn't slo-mo. It's quite fast actually.

Well, people at Bioware called this slow-mo in their debug menu. You can use some thing like 0.009 or 0.005 for slower results.

---
EDIT (6 june): Today I'm not posting anything, because I'm lazy :)

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


04 Jun 2014, 08:26
Profile
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Re: Topic about derping around with MDK2's scripts/console.
Sorry for not posting this long. General lazyness hit me. Here some code for you:
Code:
omMakeCommand(COM_VV1,      "1",        CON_BUTTON_FALL, 0, 0)
comfuncs.game[COM_VV1] = function()
    error("It's a test!")
end
omBindCommandI(COM_VV1,2)

Note 2 in last command. It's the actual keycode. (1 = escape, 2 = 1, 3 = 2, 4 = 3, etc)

Also there's few button modes:
Code:
CON_BUTTON_FALL -- Triggers on press
CON_BUTTON_RISE -- Triggers on release
CON_BUTTON_HELD -- Spams function when button is held.


Also, COM_VV1 through COM_VV0 are unused keys for variable view.
You could use any number instead of those, but you will need to make sure, it doesn't overlap with any constant.

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


08 Jun 2014, 18:21
Profile
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 15 Feb 2013, 15:56
Posts: 20
Post Re: Topic about derping around with MDK2's scripts/console.
Woo, hi there. I'm back. Just wanted to show off my code golfing skills.
I can make this:
Code:
function make(type) b=mdkGetPlayerGob() g=mdkCreateObjectLua("",type,scene) QuatYDir(g.position,b.orientation) VectorMul(g.position,6) VectorAdd(g.position,b.position) end

into this:
Code:
make=function(t)p="position"b=mdkGetPlayerGob()g=mdkCreateObjectLua("",t,scene)QuatYDir(g[p],b.orientation)VectorMul(g[p],6)VectorAdd(g[p],b[p])end

23 chars diff, and no spaces! *such swag*
Disclaimer: Tested it in lua 5.1. MDK2's lua might have more strict syntax. Syntax rules are inconsistent even between lua builds. For example: Windows build of 5.2 from LuaBinaries allows x=1337y=7331, but that only works if letter following number isn't any from a to f (hex digits). On other side, somebody told me that on their build of 5.2 there must be space between number and letter.

_________________
Programming is love. Programming is life. Respect C. Love Java. Enjoy C#. Like C++. Have fun with Lua. Hate Python. Abuse Low-level. Blame Microsoft. Be always off by one. Remember 3 features of OOP: Encapsulation, Inheritance, Polymorphism.


03 Oct 2014, 15:27
Profile
Puppy Wuppy
Puppy Wuppy
User avatar

Joined: 17 Nov 2012, 19:34
Posts: 10
Post Re: Topic about derping around with MDK2's scripts/console.
Is there a command to make the game play certain sound effects on demand? I thought I could use this method to extract sounds "the hard way".


24 Jan 2016, 15:47
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.