Chaosforge Forum

DoomRL => Modding => Topic started by: Trar on March 29, 2013, 07:00

Title: A couple questions
Post by: Trar on March 29, 2013, 07:00
I'm looking to create a mod that modifies the enemies, weapons, pickups and consumables of DOOMRL, but not the levels. Basically, new stuff but no new levels (for now). Is this possible? I can't seem to find the tables for the original game stuff, so I can't modify them. Is it possible for me to find the tables that display the enemy, weapon and item (powerups and pickups) and mods in the game so I can modify them from there, or do I have to start from scratch? I was also wondering if you can re-name klasses. Thank you in advance.
Title: Re: A couple questions
Post by: tehtmi on March 29, 2013, 11:47
All the basic things that you normally have access to in a module (cells, items, beings, etc) are declared in code that runs from doomrl.wad which is still closed source.  You can, however, still modify things after they are declared.  (This doesn't always work quite as you expect since the declaration functions do some processing.  Feel free to ask if something in particular isn't working.)  Prototypes stored in global tables indexed by both number id and string id.  For example, items are in "items" and beings are in "beings".  There's nothing preventing you from printing out the contents of these tables if you need more info.  In fact, I've attached a logging library (from my own module "inferno") should help with logging the contents of the tables (although I haven't bothered to make it print in the correct order).

Use this code to print out the contents of e.g. the items tables (replace MY_MODULE_NAME):
Code: [Select]
require "MY_MODULE_NAME:lib_item"
require "MY_MODULE_NAME:lib_being"
require "MY_MODULE_NAME:lib_log"

MY_MODULE_NAME.log = lib_log.make_log_function("lib_log")

for _, it in ipairs(items) do -- It may take a minute to print all this out.
  MY_MODULE_NAME.log(it)
end
Then check log.txt.

To actually modify stuff, just do e.g.
Code: [Select]
items.pistol.name = "my pistol" -- P.S., this doesn't work great for starting equipment

To create a game with all the basic levels, you want an "episode" type module.  Since you say "no new levels", the hooks you care about are OnCreateEpisode which sets up special levels and the over all path of the game, and OnGenerate which creates random levels.  If you don't want to do anything special, you can just call DoomRL.CreateEpisode() and DoomRL.OnGenerate() respectively.

Edit:
Apparently you can't call DoomRL.CreateEpisode, but you can still replicate it pretty closely.  See here (http://forum.chaosforge.org/index.php/topic,6234.msg54131.html#msg54131)
Title: Re: A couple questions
Post by: Trar on April 01, 2013, 11:13
Thanks for the info and files. However, I was looking for the original stats for the items and beings in DOOMRL. I was wondering if you could, er, 'loan' them to me. If that's not possible I can make up my own stats, but I'm really looking to make modified versions of the vanilla stuff.
Title: Re: A couple questions
Post by: shark20061 on April 01, 2013, 18:59
Most stats should be on the wiki, but you can also just use a value directly while registering your item:
Code: [Select]
register_item "yourid" {
  ...
  <item_property> = items.<itemid>.<desiredproperty>,
  ...
}

or after registering the item:
Code: [Select]
items.yourid.<item_property> = items.<itemid>.<desiredproperty>

This should work for most properties.
Title: Re: A couple questions
Post by: shark20061 on April 01, 2013, 19:08
...you can just call DoomRL.CreateEpisode()

Edit:
Apparently you can't call DoomRL.CreateEpisode, but you can still replicate it pretty closely.  See here (http://forum.chaosforge.org/index.php/topic,6234.msg54131.html#msg54131)
Isn't it DoomRL.OnCreateEpisode()?
Title: Re: A couple questions
Post by: tehtmi on April 01, 2013, 20:46
Isn't it DoomRL.OnCreateEpisode()?

Ah, yes.  It does work after all.  Good catch!
Title: Re: A couple questions
Post by: SPTX on April 02, 2013, 01:56
Ah! I no longer have to worry about that then.
Title: Re: A couple questions
Post by: Trar on April 02, 2013, 13:36
Again, thank you. Feel a bit embarrassed that most of the stats were on the wiki to begin with, though...
Title: Re: A couple questions
Post by: SPTX on April 04, 2013, 09:53
I have this :
Code: [Select]
function Repercussions.OnLoaded()
ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH")
if ui.msg_choice == "S" then player.eq[SLOT_WEAPON] = "SPTXlostsoul"
elseif ui.msg_choice == "H" then player.eq[SLOT_WEAPON] = "SPTXformerhuman"
end end
However the procedures aren't executed when chosen. What am I doing wrong?

Note that the player.eq[SLOT_WEAPON] procedures work properly when used alone. Is ui.msg_choice really returning S or H?
I tried with
Code: [Select]
if ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH") == "S" then player.eq[SLOT_WEAPON] = "SPTXlostsoul"which yielded the same non-result.

Also, how do I put characters in bold (like the mod install asks with armor boots weapon [abw])?
Title: Re: A couple questions
Post by: shark20061 on April 04, 2013, 20:35
I have this :
Code: [Select]
function Repercussions.OnLoaded()
ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH")
if ui.msg_choice == "S" then player.eq[SLOT_WEAPON] = "SPTXlostsoul"
elseif ui.msg_choice == "H" then player.eq[SLOT_WEAPON] = "SPTXformerhuman"
end end
However the procedures aren't executed when chosen. What am I doing wrong?

Note that the player.eq[SLOT_WEAPON] procedures work properly when used alone. Is ui.msg_choice really returning S or H?
I tried with
Code: [Select]
if ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH") == "S" then player.eq[SLOT_WEAPON] = "SPTXlostsoul"which yielded the same non-result.

Maybe it doesn't like the uppercase letters.  Try lowercase letters for the choice.

Also, how do I put characters in bold (like the mod install asks with armor boots weapon [abw])?

Use "@<" to make the text bolder and "@>" to stop bolding.

Code: [Select]
"Do you want to become a Lost @<S@>oul or a Former @<H@>uman?"
Title: Re: A couple questions
Post by: tehtmi on April 04, 2013, 20:52
I have this :
...
However the procedures aren't executed when chosen. What am I doing wrong?
This isn't working because you aren't storing the return value of the function call, you are comparing the function itself.

Quote
I tried with
Code: [Select]
if ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH") == "S" then player.eq[SLOT_WEAPON] = "SPTXlostsoul"

This is working for me (although there is no end statement).  Are you sure it isn't something else that is wrong?
Title: Re: A couple questions
Post by: SPTX on April 05, 2013, 02:48
This isn't working because you aren't storing the return value of the function call, you are comparing the function itself.
This is working for me (although there is no end statement).  Are you sure it isn't something else that is wrong?
I just tried again and it worked, can't tell what I did wrong the first time since I erased it. However since I use "if" I have to print the text twice (and make the choice twice) which makes the use of msg_choice useless compared to msg_confirm.
I'll use this until I can figure out something more... elegant.

Speaking of it, I don't seehow to return the value from the function call after calling it.

Use "@<" to make the text bolder and "@>" to stop bolding.
Code: [Select]
"Do you want to become a Lost @<S@>oul or a Former @<H@>uman?"
Wonderful, thanks. How come I didn't find anything about it on the internet, is it exclusive to the Pascal engine?

Side question : I'll need to check which weapon has been equipped later-on. How do?
Title: Re: A couple questions
Post by: tehtmi on April 05, 2013, 20:57
Speaking of it, I don't seehow to return the value from the function call after calling it.
This is probably what you want:
Code: [Select]
function Repercussions.OnLoaded()
  local choice = ui.msg_choice("Do you want to become a Lost Soul(S) or a Former Human(H)?","SH")
  if choice == "S" then
    player.eq.weapon = "SPTXlostsoul" -- SLOT_WEAPON works as well, but this is the more standard way
  elseif choice == "H" then
    player.eq.weapon = "SPTXformerhuman"
  end
end

Quote
How come I didn't find anything about it on the internet, is it exclusive to the Pascal engine?
I believe this is valkyrie (the chaosforge-roguelike-pascal library) specific.  P.S. there are codes to switch to any color http://doom.chaosforge.org/wiki/Modding:Color

Quote
Side question : I'll need to check which weapon has been equipped later-on. How do?
Example
Code: [Select]
-- make sure the player has a weapon at all (will be nil if nothing is equipped)
if player.eq.weapon then
  if player.eq.weapon.id == "SPTXlostsoul" then
    do_one_thing()
  elseif player.eq.weapon.id == "SPTXformerhuman" then
    do_another_thing()
  end
end 
Title: Re: A couple questions
Post by: SPTX on April 08, 2013, 03:42
Perfect, thanks.

Now about these melee attacks I talked about earlier (maybe not ITT). How are they called by the game? I am talking about the melee attacks or non-melee monsters and the player when he has a weapon equipped. When bumping into other beings.

I basically need to change the default 1d3 given by fists.
Do fists have an ID? "fists" or items.fists doesn't seem to work.
Title: Re: A couple questions
Post by: Equality on April 14, 2013, 02:51
What are proper sizes of properties variables?
From wiki,

armor
durability
ammo
ammomax
res_bullet (and res_melee and so on)
movemod, knockmod and (undocumented) dodgemod

all are integers. Far from it! When created a new instance of item object,
armor - byte
durability - word
ammo, ammomax - word
resistances, movemod, knockmod - signed doubleword

well, for most cases no matter what is it - from 0 to 250 quite enough. But what about level depth? danger level? Hp and hpmax? Who knows?
Title: Re: A couple questions
Post by: Equality on April 24, 2013, 00:02
and one more: what is "ystairs" purpose? Yellow stairs, just a "down" in game, but you can't descend.
Title: Re: A couple questions
Post by: Kornel Kisielewicz on April 24, 2013, 04:26
They're a leftover from the times where I wanted to have dungeon branches. Red stairs would go to special levels, while yellow stairs would change branch.
Title: Re: A couple questions
Post by: SPTX on May 07, 2013, 13:27
I was also wondering if you can re-name klasses. Thank you in advance.
A bit late to the party regarding that, but I just found that you could rename klasses using :

klasses[player.klass].name = "name" -- where player.klass is currently used klass
or replace [player.klass] by ["marine"] ["scout"] ["technician"] respectively.
Doesn't apply until the mod is loaded obviously.
Title: Re: A couple questions
Post by: Trar on May 31, 2013, 08:19
Thanks for that, SPTX. This thread is proving to be quite the information source! And Kornel, would it still be possible to implement branches in a mod?
Title: Re: A couple questions
Post by: Kornel Kisielewicz on May 31, 2013, 08:27
I guess you could hack that in. Just keep the information on which stairs the player took in player custom properties, and make the generator react accordingly.
Title: Re: A couple questions
Post by: SPTX on June 15, 2013, 05:32
Is there a way to prevent an item from spawning or replacing it in special maps?
Title: Re: A couple questions
Post by: yaflhdztioxo on June 15, 2013, 08:58
Interrogative: what are you trying to do exactly?
Title: Re: A couple questions
Post by: Equality on June 15, 2013, 11:45
...well, I see 3 ways:
a) change weights. If you change weight for some item to 0, it never spawn until you direct place that on map
b) for special levels - reusing existent: may be try iterate all items on map and delete/replace unwanted item? If it is not a reward from Agony Elemental or Arena Master but just ordinary item on level like envirosuit or large med-pack. At OnEnter event
c) in documentation I see a level.OnCreate(being/item) event. Looks like place to control everything including special rewards like sculls-Arena staff-lava element ?