Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
maxmanium

Redefined weapons with EDF, now berserk no longer autoswitches

Recommended Posts

Posted (edited)

I redefined the DoomMarine player class as follows:

 

setdialect("alfheim")

playerclass DoomMarine
{
   defaultskin    marine
   thingtype      DoomPlayer
   altattackstate S_PLAY_ATK2
   superhealth    200

   default true

   weaponslot 1 { weapons : CoolChainsaw, CoolFist }
   weaponslot 2 { weapons : CoolPistol }
   weaponslot 3 { weapons : CoolSuperShotgun, CoolShotgun }
   weaponslot 4 { weapons : CoolChaingun }
   weaponslot 5 { weapons : CoolMissileLauncher }
   weaponslot 6 { weapons : CoolPlasmaRifle }
   weaponslot 7 { weapons : CoolBFG9000 }
   weaponslot 8 { weapons : CoolChainsaw }
   weaponslot 9 { weapons : CoolSuperShotgun }

// rebornitem AmmoClip, 50
   rebornitem CoolPistol
   rebornitem CoolFist
}

 

The only difference between these weapons and the regular ones is the tic duration of the fire sequence, which is slightly faster. For example, the fist:

 

weaponinfo CoolFist : Fist, 0
{
	selectionorder 9.0
	States
	@"
	  Fire:
		PUNG B 4
		PUNG C 3 A_Punch
		PUNG D 4
		PUNG C 3
		PUNG B 5 A_ReFire
		goto Ready
	"@
	sisterweapon EpicFist
}

The sisterweapon is the same but even faster, obviously a tome of power variant.

 

The problem is, picking up a berserk pack no longer auto-switches to the fist, and I can't figure out why. It might have to do with selectionorder, but if I don't put that there, the old selectionorder is not inherited. I hope one of the devs can help me here; is this a bug or am I missing something?

 

Share this post


Link to post
Posted (edited)

You probably need to add a "pickupeffect BerzerkBox" definition with a "changeweapon CoolFist" in it (in a custom "sprites.edf" file).

Share this post


Link to post
Posted (edited)

This isn't reaallly a bug. The BerzerkBox references the Fist weapon directly. To avert this issue I'd suggest using deltas instead.

playerdelta
{
    name DoomMarine

    // The below won't work until the next DRDTeam build
    clearrebornitems
    // Pistol ammo used to be here but now it's long long gone
    rebornitem Pistol
    rebornitem Fist
}

This is what the delta for fist would look like. I think there will still be issues if you're tomed whilst you get the powerup. I'll need to think about suitable fixes for that. I have an idea for one but I'm sure there'll be some weird edge-cases. Frankly I'm surprised people are even using the tomed weapon stuff so soon. Makes me nervous about comitting stuff in devbuilds that I might want to change prior to a major release.

weapondelta
{
    name Fist

	States
	@"
	  Fire:
		PUNG B 4
		PUNG C 3 A_Punch
		PUNG D 4
		PUNG C 3
		PUNG B 5 A_ReFire
		goto Ready
	"@
	sisterweapon EpicFist
}

I lied about DRDTeam I'm just gonna attach an exe w/ the changes so you don't have to wait. Here you go: Eternity.7z

Share this post


Link to post
Posted (edited)

What attracted you to use inheritance instead of deltas, if I may ask? My goal here is to try identify how to adjust to docs so that in future the best course of action is more obvious.

Share this post


Link to post
5 hours ago, Altazimuth said:

I lied about DRDTeam I'm just gonna attach an exe w/ the changes so you don't have to wait. Here you go: Eternity.7z

 

You're the best. Unfortunately the delta solution doesn't quite work as intended for a few reasons:

 

- The weapondelta entry, for whatever reason, uses the sisterweapon's attack speed

- Using playerdelta like that doesn't account for the rest of the weapons (I also defined WeaponGivers, just didn't post them here)

- For whatever reason, I am unable to switch to the pistol regularly, even after using "rebornitem CoolPistol"

 

Also:

- When running out of pistol ammo, or any other situation which causes a switch to the fist, the game crashes:

 

Spoiler

Eternity caused an Access Violation Exception (0xc0000005)
in module Eternity.exe at 0023:00496297.

Error occurred at 3/10/2020 14:30:44.
c:\Doom\Eternity\Eternity.exe, run by Connor.
Operating system: 6.2.9200
4 processors, type 586.
67% memory in use.
2048 MB physical memory.
2048 MB physical memory free.
0 MB page file.
0 MB paging file free.
2048 MB user address space.
1697 MB user address space free.
Access violation at 00000004. The memory could not be read.

Context:
EDI:    0x007ae0b8  ESI: 0x00778310  EAX:   0x00000000
EBX:    0x0019fe08  ECX: 0x03f08f60  EDX:   0x03f0836c
EIP:    0x00496297  EBP: 0x0019fe00  SegCs: 0x00000023
EFlags: 0x00210246  ESP: 0x0019fdd8  SegSs: 0x0000002b

Bytes at CS:EIP:
8a 40 04 88 47 10 be 1c 00 00 00 80 be 90 63 7b 

Stack:
0x0019fdd8: 00000000 00000001 6dbce300 00000000 ...........m....
0x0019fde8: 0000000d 00000000 00000001 00000032 ............2...
0x0019fdf8: 03f38cb0 00778310 0019fe30 0044e149 ......w.0...I.D.
0x0019fe08: 00000308 0044e149 00000000 00000000 ....I.D.........
0x0019fe18: 0019fe58 b9af7270 000003fc 0019fe58 X...pr......X...
0x0019fe28: 00000000 00000000 0019fe50 0044ea8d ........P.....D.
0x0019fe38: 00000000 00000000 00000000 b9af726f ............or..
0x0019fe48: 00000001 00000000 0019fe78 0044ef4b ........x...K.D.
0x0019fe58: 00000001 0044ef4b 009f72b0 009f8200 ....K.D..r......
0x0019fe68: 0027c000 ffffffff 00000001 00000000 ..'.............
0x0019fe78: 0019fefc 0044dc5f 009f72b0 009f8200 ...._.D..r......
0x0019fe88: 0019feb4 00000004 00000000 00000000 ................
0x0019fe98: 00000000 00000000 00000000 fffffffd ................
0x0019fea8: 00000000 00000000 00000000 00000020 ............ ...
0x0019feb8: 00000005 00000000 a5dcbf10 11d26530 ............0e..
0x0019fec8: c0001f90 ed51b94f 00000000 00000000 ....O.Q.........
0x0019fed8: 6db1bfdc 00004000 6db1be40 00000000 ...m.@..@..m....
0x0019fee8: 00004220 6daf1575 00000000 0027c000  B..u..m......'.
0x0019fef8: 0056fe1c 0019ff28 005788fd 009f72b0 ..V.(.....W..r..
0x0019ff08: 009f8200 0027c000 0019ff04 0019f81c ......'.........
0x0019ff18: 0019ff60 006638c0 006f8240 00000000 `....8f.@.o.....
0x0019ff28: 0019ff70 0065f38e 00000005 009f8200 p.....e.........
0x0019ff38: 009f72b0 75ca96be 0065f461 0065f461 .r.....ua.e.a.e.
0x0019ff48: 0027c000 00000000 00000000 00000000 ..'.............
0x0019ff58: 0019ff3c 00000000 0019ffcc 0065f196 <.............e.
0x0019ff68: 75bcbd2e 00000000 0019ff80 75bb6359 ...u........Yc.u
0x0019ff78: 0027c000 75bb6340 0019ffdc 77857b74 ..'.@c.u....t{.w
0x0019ff88: 0027c000 fb5934ef 00000000 00000000 ..'..4Y.........
0x0019ff98: 0027c000 00000000 00000000 00000000 ..'.............
0x0019ffa8: 00000000 00000000 00000000 00000000 ................
0x0019ffb8: 00000000 00000000 00000000 0019ff8c ................
0x0019ffc8: 00000000 0019ffe4 77869f90 8ccfa9cb ...........w....
0x0019ffd8: 00000000 0019ffec 77857b44 ffffffff ........D{.w....
0x0019ffe8: 77878f0b 00000000 00000000 0065f461 ...w........a.e.
0x0019fff8: 0027c000 00000000                   ..'.....


===== [end of CRASHLOG.TXT] =====

 

 

2 minutes ago, Altazimuth said:

What attracted you to use inheritance instead of deltas, if I may ask? My goal here is to try identify how to adjust to docs so that in future the best course of action is more obvious.

 

Probably my (limited) past experience with GZDoom's DECORATE. Seems more straightforward to me, since I've had a shot at redefining player classes that way in the past. Also, I didn't really know what deltas were. It seemed simpler to just copy the relevant information from the Doom EDF files and change only what I needed to change. All things considered it works pretty much exactly how I want. I'll probably use @andrewj's solution and just work around the sisterweapon problem when it comes up. I'm kind of dumb, I didn't even think to redefine the BerzerkBox.

Share this post


Link to post

Won't quote for brevity, but your dashed points in order:

  • Thaaat sounds like a really bizarre bug. That needs fixing.
  • You should be able to add the rest of the weapons too just fine to the delta.
  • I'm not quite sure about this one. Also sounds like a bug.
  • A crash is a crash. I fixed most of these sorts of bugs but I'm not surprised a few linger.

Would you be able to provide me we any WIPs (privately if you want) that I can test and fix this with? The third point you have it'd also be super helpful if you could figure out the circumstances of being unable to switch to the pistol.

Share this post


Link to post

PM'd. Some clarification:

 

- Disregard points 2 and 3, those were on my end.

- The sisterweapon attack speed is only upon initial spawn. After switching to the fist again it works as intended. In fact, when picking up berserk it even "switches" to the regular version.

 

It's probably still on my end, I don't really know what I'm doing :/

Share this post


Link to post

OK thanks. I might be a smidge slower to react to this than the past couple things. Contrary to quick changes I made recently I expect to be inundated with work fairly soon.

Share this post


Link to post
Posted (edited)

For a line like `weaponinfo Foo: Bar, 8` you don't need the `, 8`. That is the dehackednum, and is for internal use only, basically.

 

The crash and wonky starting weapon are due to your 'Epic*' weapons having a selectionorder. I just realised now, but weapons with POWERED_UP cannot have this property set so I've explicitly disallowed this and it will cause an error at startup if it occurs from now on.

The wonky starting weapon in particular happens because when you have two weapons with the same selectionorder which are eligible for being chosen the one with the lowest alphabetical value is chosen. Following this, EpicFist is chosen over Fist. It worked before because CoolFist comes before EpicFist alphabetically. When a player is spawned the "best" weapon is chosen by picking the weapon the player owns current w/ the lowest selectionorder (falling back on the alphabetical check).

 

You don't need to specify selectionorder in a delta unless you're actually changing it, for what it's worth. Inheriting weapons do need their own selectionorders for the moment to actually end being autoselectable once you run out of ammo, but I might change that. I'm not sure if I intentionally made it that way back when I first implemented it...

 

Anyway in the meantime I'd suggest using deltas and remove selectionorder from the powCancelered up weapons. The code change I made only adds an error message.

 

I appreciate you reporting these issues, by the way. Helping find these edge-cases is super handy. Let me know if there's any further problems.

Share this post


Link to post

That works! Good info to know. I probably would have used deltas had there been more info on it (I don't think there's any examples of weapondelta or playerdelta).

 

Also, unfortunately, I did find one more thing... if the tome of power variant is active upon exiting a level, the active weapon stays "powered up" to the next level until another one is selected. I've implemented weapondeltas for all non-powered versions and removed all selectionorders in the weaponinfo definitions. I'm sure there's some way to work around this with ACS, but maybe there's an easier method.

Share this post


Link to post
10 minutes ago, maxmanium said:

if the tome of power variant is active upon exiting a level, the active weapon stays "powered up" to the next level until another one is selected

Fixed.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×