First Weapon mod for Hexen

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

First Weapon mod for Hexen

Post by Sanjurodlc »


-=WARNING=- This mod is made just for fun and for me to learn. It is not at all complete, so try at your own discretion. -=WARNING=-

Hey, new guy around here, Video above was the concept of my first weapon mod for Hexen, it replaces the default Sapphire Wand of Daedolon and is intended to be balanced but fun too. Also, intended to be played with the Archmage difficulty.
The current state of the mod has a lot more visual eyecandy and improved functionality. Remember to autoload your Brightmaps and Lights in GZDoom! :D

--== Power, give me more, power... ==--

Whats up until now:
- Uses Bloodscourge sprites, may change in future.
- Primary is the default Sapphire Wand Magic Missile, recolored red and Damage nerfed to 1 to balance for the new faster cadence.
- Secondary is a outrageously amazing lazor that one-shot almost anything. It has huge recoil, really difficult to shoot near falls and hazardous places.
- Secondary takes a LONG time to shoot again and/or allow you to shoot primary after shooting secondary, so gotta be wise when and against who you want to shoot secondary at.
- Primary uses no ammo and it's fast, but weak. Secondary uses your enemy's souls. Harvest 10 of them by killing enemies and you can shoot once for a total of 10 shots when full.
- Enemies drop Souls at different rates, some have 100% chance (bosses and very tough creatures) and some have random chances. You'll have to work for those Souls...
- Complete new sounds made from scratch by me. Secondary randomly play 1 of 4 samples when "preloading" the shot. And the shot itself has enough oomph. Proud about this.
- Trying to fire Secondary without ammo is particularly fun. Hehehehehe... (Blood's Caleb voice samples)
- Every time you switch weapons to or back this weapon, Corvus laugh, cause that sfx is just plain amazing.
- Added custom sprites for the Soul item when dropped by enemies and a custom icon for the ammo on HUD.

Current bugs:
- When out of ammo, secondary reselects weapon or change to another when trying to fire it. Trying to solve this for now. "I live, again..."
- Default Hexen hud does not show ammo type or how much ammo you have, have to use AltHud or a custom hud. I'll probably do one in the future.
- Not a bug, but the Decorate is crowded with declarations, i'll probably clean it and put some sections in other files to #include.

Update:
- Uploaded my custom mini hud if anyone likes what they see in the video. Near the end i switch weapons to show the ammo and items placement.

--== Download Link ==--

[MEGA] Akira Wand Version 0.4 Size: 376 KB

--== Recommended Mods ==--

[MEGA] Mini Mage Hud Size: 2 KB | This is my mini Hud like shown in the video, it only works with the Mage for now replacing the Fullscreen Hud (Screen Size 11).

MaxED's Widescreen HUDs for Heretic and Hexen | These are simple, use the original status bars as sprite base and support custom ammo, give it a try.

------------------------------------------------------------------------------------------------------------------------------
Feel free to give any feedbacks, i'm more than willing to listen and learn. :)
:twisted: Now go harvest your enemies souls, Archmage, for Korax will not wait you to get stronger... :twisted:
Last edited by Sanjurodlc on Sat Sep 17, 2016 10:09 am, edited 13 times in total.
User avatar
Luigi2600
Posts: 420
Joined: Tue Oct 27, 2015 3:41 pm
Location: New Russia

Re: First Weapon mod for Hexen

Post by Luigi2600 »

This seems like a promising mod, The weapons look nice not bad for a conversion.
CeeJay
Posts: 1467
Joined: Sun Mar 14, 2010 2:52 am

Re: First Weapon mod for Hexen

Post by CeeJay »

I like the sound effects.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: First Weapon mod for Hexen

Post by VICE »

Heh, sounds like maybe you've seen and maybe even replicated the Brutal Doom carnage bonus, it's simply an invisible pickup that has a ridiculously large height and radius. It's clever, but it requires the player to be on roughly the same elevation when it spawns and to move in order to "pick it up".

I don't like that though, so I propose you try something like this:

1. Give your weapon a new damage type, "Soul", for example.
2. Define a new death.Soul state for the monsters (you can use inheritence and "####" frames to keep your definitions short and efficient, and mod-friendly).
3. During the death.soul state have them drop an actor like this:

Code: Select all

Actor SoulAmmoGiver
{
	+NOINTERACTION
	+NOTONAUTOMAP
	+NOTELESTOMP
	RenderStyle None
	States
	{
	Spawn:
		TNT1 A 0 NoDelay 
		{
			A_GiveInventory("SoulAmmo",1, Player1);
		}
		Stop
	}
}
It will cause the player to recieve soul "ammo" as soon as the ammo giver spawns, so the player gets it instantly once the monster dies.
You can have different monsters drop different amounts of these actors.
The damage type hack ensures that only this particular weapon can harvest souls, and that monsters not killed by the player don't reward the player with souls.
The only caveat is that this will only work for monsters that you edit in this way, so it will need editing to be compatible with monsters from other mods.

There might be a more elegant way to do this, though, I'm not an expert.

Some helpful links:
http://zdoom.org/wiki/Using_inheritance
http://zdoom.org/wiki/Custom_damage_types
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

Re: First Weapon mod for Hexen

Post by Sanjurodlc »

Megaherz wrote:1. Give your weapon a new damage type, "Soul", for example.
2. Define a new death.Soul state for the monsters (you can use inheritence and "####" frames to keep your definitions short and efficient, and mod-friendly).
3. During the death.soul state have them drop an actor like this: *example code*

It will cause the player to receive soul "ammo" as soon as the ammo giver spawns, so the player gets it instantly once the monster dies.
You can have different monsters drop different amounts of these actors.
The damage type hack ensures that only this particular weapon can harvest souls, and that monsters not killed by the player don't reward the player with souls.
The only caveat is that this will only work for monsters that you edit in this way, so it will need editing to be compatible with monsters from other mods.

There might be a more elegant way to do this, though, I'm not an expert.s
That seems like a very good way of doing it to me, you may not be an expert but for sure knows a lot more than people like me who are just starting. :D
I'll try the way you suggested (probably will bash my head a lot against the keyboard while trying to understand step 2 haha), and update here when i got some results. Thanks a lot!
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

Re: First Weapon mod for Hexen

Post by Sanjurodlc »

So, i tried at first replacing the damage of A_RailAttack to a string and it seems it's impossible to make it use anything other than raw number damage.
prints.png
If i put the string between comas the compiler lets me go ingame, but with a yellow error saying an integer was expected, so it defaults to the default rail damage.
Not sure how to proceed since this pretty much makes it impossible to change how the rail projectile behaves.
Maybe set the damage in the sprites i spawn as the rail laser? But then they would do continuous damage over tics...

Also, why the "tried to register class X more than once" error? I'm pretty sure i'm not replacing or calling anything more than one time in all my code. :?
You do not have the required permissions to view the files attached to this post.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: First Weapon mod for Hexen

Post by VICE »

Sanjurodlc wrote:You may not be an expert but for sure knows a lot more than people like me who are just starting. :D
Thanks, I've been playing around with Doom mods for a couple of years on and off, I learned mostly by reverse engineering my favorite mods and through reading the wiki when I get stuck. :)
So, i tried at first replacing the damage of A_RailAttack to a string and it seems it's impossible to make it use anything other than raw number damage.
http://zdoom.org/wiki/A_RailAttack
Looks like you can't assign damage types to rail attacks directly, but you can use the "pufftype" paramater to spawn a custum puff with the damage type that you need (I'd give that puff actor the "+ALWAYSPUFF" flag to be safe). I'm guessing you tried editing the first parameter called "damage", but that just defines how much damage is done. That's why the game is telling you it was expecting an integer.

Btw, I'm not entirely sure about this (haven't tested it), but I believe that if you add the damage type directly to your weapon actor, it should apply to all of its attacks by default.
Sanjurodlc wrote:Also, why the "tried to register class X more than once" error? I'm pretty sure i'm not replacing or calling anything more than one time in all my code
See how your screenshot says "script error in (filename) line 95" twice? Unless you wrote "Telefrag" twice on that exact line with perfect space between (don't see why you would), that means the game is trying to load that file twice, which would explain the "more than once" errors. Might be something else, though, check your DECORATE lump, especially if you're loading other lumps from it, could be a duplicate line there.
User avatar
BFG
Posts: 603
Joined: Tue Feb 17, 2015 5:54 am
Location: Germany

Re: First Weapon mod for Hexen

Post by BFG »

that laser wand really reminds me of Doom64 !
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

Re: First Weapon mod for Hexen

Post by Sanjurodlc »

Well, update on my current status:
I simply can not for the life of me understand how the A_GiveInventory target goddamn pointer/giveto works. I'm probably too dumb, or the wiki is really bad written in this part:
This how wiki says it works:

Code: Select all

A_GiveInventory (string type [, int count [, pointer giveto]])
This how i made my line in the Ammo item:

Code: Select all

Spawn:
  FASO AB 16 Light("AFSoul") A_GiveInventory("FallenSoul",1,X)
  Stop
So i thought "Well, giveto must be the Player class" and tried it. No. Tried numbers. No. Tried player. No. Then back to wiki, enough guessing around.
Clicked on "Actor Pointer Selector" to see what it must be since the default AAPTR_DEFAULT seems to give the item to the monster who spawned the item. Then on the Actor Pointer page, pure text mess. Lots of strings, none well explained, and when i copy pasted any of them, none do absolutely nothing even though no compile errors on launch. No examples, no nothing. frustration ensues. :cry:
Tried with if/else, did not work also. There is simply no easy way to tell the engine "hey, give this spawned item to the player!". /rant

So far i got to make a Ettin (as test) spawn the ammo item, and when picked up, it adds to the Soul counter of the player. But you must go pick it up...
And while bashing my head against the keyboard trying to do the giveto pointer work, i also found another bug that is not apparently my code:

Code: Select all

AltFire:
    MSTF A 0 A_JumpIfNoAmmo("Ready")
This is how i was supposed to check when pressing AltFire if my weapon has the necessary quantity of secondary ammo to fire, right?
Well, when you press AltFire, it apparently ignores my jump to Ready above and Deselect and Select the weapon...

So, i need help, my stupidity and dumbness must be clouding my logic.

Edit: Oh, the "tried to register class X more than once" error was because i was auto loading my mod while at the same time launching it within Slade, so it indeed tried to register the Decorate twice. Yeah, i gotta pay more attention... :?
Last edited by Sanjurodlc on Sat Aug 27, 2016 10:59 am, edited 2 times in total.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: First Weapon mod for Hexen

Post by VICE »

Here is some annotated code for the Ettin, hopefully this helps:

Code: Select all

// This Ettin is identical to the standard Ettin, but it has a new death state.
ACTOR AEttin : Ettin replaces Ettin // Inherits all of Ettin's definitions, and replaces it.
{
  States
  {
  Death.Soul:  //This death state is only triggered if it was brought to 0 HP with "Soul" type damage.
     TNT1 A 0 A_SpawnItem("SoulAmmoGiver",0,0) // This will spawn the ammo giver in the game world
  Goto Death 
  // This line tells it to go to its original death state, so after spawning the soul it will continue the regular death animation.
  }
}


Actor SoulAmmoGiver // This actor will spawn when your monster is killed. Its job is to give the player some ammo and then disappear immedietly.
{
   +NOINTERACTION // This guarantees no funny business from other actors interacting with it somehow, we want this guy to run in the background.
   +NOTONAUTOMAP  
   +NOTELESTOMP  // Ditto
   RenderStyle None
   States
   {
   Spawn:
      TNT1 A 0 NoDelay // NoDelay means that this line runs immedietly. The engine ignores the first line in the spawn state unless you specify "NoDelay".
	  //This line has a code block below, everything inside the brackets happens during that frame:
      {
         A_GiveInventory("FallenSoul",1, AAPTR_PLAYER1); // Gives 1 Soul ammo to player 1. Every line in a code block need to have a semicolon (";") at the end. 
      } //End of block
      Stop //This erases the actor.
   } //End of states
} //End of actor
You should be able to replicate this for all monsters in the game by copy-pasting and changing some definitions.

Btw, you forgot to give your primary attack the soul damage type.
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

Re: First Weapon mod for Hexen

Post by Sanjurodlc »

Megaherz wrote:Here is some annotated code for the Ettin, hopefully this helps:
Spoiler:
You should be able to replicate this for all monsters in the game by copy-pasting and changing some definitions.

Btw, you forgot to give your primary attack the soul damage type.
YES!!! AAPTR_PLAYER1, that's what i was looking for! Now my spawner looks like this:

Code: Select all

Spawn:
    FASO AB 16 Light("AFSoul") A_GiveInventory("FallenSoul",1,AAPTR_PLAYER1)
	 Stop
Enemy dies, item spawns and instantly gives the player 1 ammo! Thank you so much man! :D :D :D
Now i have to create a separate file overriding the default monsters in Hexen to spawn the item. I can have problems with AAPTR_PLAYER1 if i consider coop, but that's a problem for another time.

As for the DamageType, i thought i don't really need it because i ended up using Inventory.RestrictedTo on the ammo spawner, so only my player class can receive it, no need to filter it with damage now if i'm not wrong. I'm possibly wrong though. :P

AS for the code and explanation, you did not like the way i did? :cry: Did you gave the code in my WAD a look? I thought it was very tight and simple. Any reason to make additional indentations on the states and proprieties?
Here's how i made the Ettin drop the spawner (used DropItem rather than inheritance, i thought was more clean than adding another state as it only takes one line):

Code: Select all

ACTOR AEttin : Ettin replaces Ettin
{
  DropItem "FallenSoul",255,1
}
The code above is in a separate file that i #include at the Decorate start to call all monsters and add DropItem to them in the future.
Here is the entire spawner that gets called by DropItem:

Code: Select all

ACTOR FallenSoul : Ammo
{
  +FLOATBOB
  +VISIBILITYPULSE
  RenderStyle Translucent
  Inventory.MaxAmount 40
  Inventory.Icon "FASOA0"
  Inventory.PickupMessage "Power, give me more, power..."
  Inventory.RestrictedTo "ReBornAnew"
  States
  {
  Spawn:
    FASO AB 16 Light("AFSoul") A_GiveInventory("FallenSoul",1,AAPTR_PLAYER1)
	 Stop
  }
}
As for the weapon skipping the A_JumpIfNoAmmo making it Deselect and Select again, any ideas? I looked over all the weapon again to make sure i didn't type something wrong.
I'll re-upload the WAD when i make the change and add the monster list.
User avatar
VICE
Posts: 405
Joined: Wed Mar 28, 2012 4:03 am
Location: The Shadow Realm (no cap)

Re: First Weapon mod for Hexen

Post by VICE »

Sanjurodlc wrote: AS for the code and explanation, you did not like the way i did? :cry: Did you gave the code in my WAD a look? I thought it was very tight and simple. Any reason to make additional indentations on the states and proprieties?
Only if you want to use the damage type method (I assumed you did). Since you don't, your way is simpler.
Sanjurodlc wrote: As for the weapon skipping the A_JumpIfNoAmmo making it Deselect and Select again, any ideas? I looked over all the weapon again to make sure i didn't type something wrong.
I'll re-upload the WAD when i make the change and add the monster list.
I wasn't able to spot anything so I didn't comment on that. I could have another look though.
HexaDoken
Posts: 325
Joined: Thu Dec 01, 2011 7:34 am

Re: First Weapon mod for Hexen

Post by HexaDoken »

Precisely why you are not just giving the player ammo directly from the monsters' death states?

When a monster dies, it automatically puts the killer into the Target pointer. You can easily give ammo to the killer via A_GiveToTarget from there. This has the added bonus of not breaking multiplayer
User avatar
Sanjurodlc
Posts: 7
Joined: Tue Aug 23, 2016 11:46 pm

Re: First Weapon mod for Hexen

Post by Sanjurodlc »

Megaherz wrote:I wasn't able to spot anything so I didn't comment on that. I could have another look though.
Give the Wad i uploaded a try, start a new game and try to fire secondary as soon as you spawn, you'll see the weapon lowers (Deselect) and raises again (Select, playing the sound i made the weapon play every time you switch to it, Corvus laugh).
It's like the engine ignores completely my A_JumpIfNoAmmo to return to Ready state. It just switch the weapon to itself, which is very odd, like the game was trying to switch out to a weapon with ammo in the inventory, but there is no other weapon except the one you're using, so it pulls it back.
HexaDoken wrote:Precisely why you are not just giving the player ammo directly from the monsters' death states?

When a monster dies, it automatically puts the killer into the Target pointer. You can easily give ammo to the killer via A_GiveToTarget from there. This has the added bonus of not breaking multiplayer
Well:
- I though DropItem had the advantage of no need to change the Death state of each monster, was a lot easier and less lines/characters in the override file, thus smaller file overall.
- DropItem has a Chance Parameter which lets me make the actual drop to some monsters not always happen for example. While with A_GiveInventory or A_GiveToTarget i would need to make a whole conditional state to make chances of drop.

And i have a doubt (since i don't really understand how it works, just took a peak at the wiki): Wouldn't A_GiveToTarget give the item erratically to other monster if when i kill them they were infighting (since his actual target would be another monster at the death moment)?

If it's better to use the A_GiveToTarget i can switch to it no problem, just want to understand first. :P

Edit: Just updated main post with current info, version of current state, and external link.
HexaDoken
Posts: 325
Joined: Thu Dec 01, 2011 7:34 am

Re: First Weapon mod for Hexen

Post by HexaDoken »

Sanjurodlc wrote:And i have a doubt (since i don't really understand how it works, just took a peak at the wiki): Wouldn't A_GiveToTarget give the item erratically to other monster if when i kill them they were infighting (since his actual target would be another monster at the death moment)?
No. ZDWiki also states somewhere that every monster automatically sets its target to it's killer upon death, which means that in Death state the Target field will always refer to the killer, unless changed by outside means.
Sanjurodlc wrote:If it's better to use the A_GiveToTarget i can switch to it no problem, just want to understand first. :P
Yeah it is. You're already modifying the monsters anyway, so monster compatbility is out of the window, extra code is not really a concern, and the target way ensures you only get ammo for kills that are actually yours, + makes multiplayer work.
Sanjurodlc wrote:- DropItem has a Chance Parameter which lets me make the actual drop to some monsters not always happen for example. While with A_GiveInventory or A_GiveToTarget i would need to make a whole conditional state to make chances of drop.
Use A_Jump with a frame offset instad of destination state.
Example:

Code: Select all

TNT1 A 0 A_Jump(100,2)
TNT1 A 0 A_GiveToTarget("foo", 27)
FOOB AR 4 A_Whatever
In this case, the state has a 100/256 chance(about 0.39) to not give the ammo to the killer by virtue of jumping two frames down and landing on FOOB A 4 A_Whatever, thus skipping the A_GiveToTarget frame

EDIT:
Sanjurodlc wrote:- When out of ammo, secondary reselects weapon or change to another when trying to fire it. Trying to solve this for now.
Try the +WEAPON.AMMO_OPTIONAL or +WEAPON.ALT_AMMO_OPTIONAL flags, then at the beginning of Altfire state do A_JumpIfInventory for ammo, throwing the flow to true altfire state if ammo is found, and letting it fall to Goto Ready or Goto Fire otherwise.

Return to “Gameplay Mods”