Back to the Vavoom Forum Archives


Forum

Fire-damaging melee weapon (Hexen)

Sun, 10 Sep 2006 05:04:48

TheCount

Hello. I've been tweaking around with the Quietus and used some code from the cleric mace to give it a melee attack. So the attack function looks like this:
void A_FSwordAttack()
{
	int damage;
	int i;
	int as;//the variable is called as because of the as de espadas, ace of spades (mora accurately transatable for "ace of swords") :P
	TAVec angles;
	TVec vforward;

	damage = 200 + (P_Random() & 15);
	for (i = 0; i < 16; i++)
	{
		angles = Player.MO.Angles;
		angles.yaw = AngleMod360(angles.yaw + itof(i) * (45.0 / 16.0));
		Actor(Player.MO).AimLineAttack(&angles, 2.0 * Actor::MELEERANGE);
		if (Actor(Player.MO).linetarget)
		{
			AngleVector(&angles, &vforward);
			if (Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff))
			{
				Player.MO.PlaySound('FighterHammerMiss', CHAN_WEAPON);
				as=1;
			}
			Player(Player).AdjustPlayerAngle();
			return;
		}
		angles = Player.MO.Angles;
		angles.yaw = AngleMod360(angles.yaw - itof(i) * (45.0 / 16.0));
		Actor(Player.MO).AimLineAttack(&angles, 2.0 * Actor::MELEERANGE);
		if (Actor(Player.MO).linetarget)
		{
			AngleVector(&angles, &vforward);
			if (Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff))
			{
				Player.MO.PlaySound('FighterHammerMiss', CHAN_WEAPON);
				as=1;
			}
			Player(Player).AdjustPlayerAngle();
			return;
		}
	}
	// didn't find any creatures, so try to strike any walls
	angles = Player.MO.Angles;
	Actor(Player.MO).AimLineAttack(&angles, Actor::MELEERANGE);
	AngleVector(&angles, &vforward);
	if (Actor(Player.MO).LineAttack(vforward, Actor::MELEERANGE, damage, HammerPuff))
	{
		Player.MO.PlaySound('FighterHammerMiss', CHAN_WEAPON);
		as=1;
	}
	if (as==1)
	{
		PlayerPawn Owner = PlayerPawn(Player.MO);
	
		Player(Player).Mana[HexenDefs::MANA_1] -=
			WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon);
		Player(Player).Mana[HexenDefs::MANA_2] -=
			WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon);
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, -10.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw + 45.0 / 4.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, -5.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw + 45.0 / 8.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin, FighterSwordMissile,
			Owner.Angles.yaw);
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, 5.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw - 45.0 / 8.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, 10.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw - 45.0 / 4.0));
		Owner.PlaySound('FighterSwordFire', CHAN_WEAPON);
	}
	
	
}
So, I want to make it fire-damaging. I've tried to look it up in the cone of shards code, but I don't understand <!-- s:? --><img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /><!-- s:? --> Actually, I don't understand this melee attack either, but all I did was changing the damage and creating an "as" variable to control whether to fire missiles or not. All other escapes my understanding. Another thing, the weapon doesn't consume mana in melee attacks, just as I want, but it can't attack either way if it's out of mana. Any help is appreciated. Thank you very much
Sun, 10 Sep 2006 07:55:51

Crimson Wizard

First of all, may I suggest you look in my tiny tutorial about weapon modifying? It's very short but maybe it will answer on some of your questions: <!-- m --><a class="postlink" href="http://www.vavoom-engine.com/wiki/index.php?title=Tutorials:Repeater_Cannon">http://www.vavoom-engine.com/wiki/index ... ter_Cannon</a><!-- m --> Then... Fire damaging. If you want fire damage for melee attacks add following in "defaultproperties" section of WeaponFighterSword class (i.e. Quietus itself):
bFireDamage = true;
If you want projectiles have fire damage, add the same line to FighterSwordMissile class. As for using melee attack w/o mana check WeaponFighterAxe class, it acts the same (with only difference that it doesn't has missile attack ,just more strong melee with mana available).
Sun, 10 Sep 2006 10:38:44

Janis Legzdinsh

Fire damaging. If you want fire damage for melee attacks add following in "defaultproperties" section of WeaponFighterSword class (i.e. Quietus itself):
bFireDamage = true;
Wrong, weapon class is not an actor. For melee weapons you must temporarely set player to have this flag and clear it afterwards. Take a look how mage's ice damage works.
Sun, 10 Sep 2006 12:32:54

Crimson Wizard

Oops, my mistake. Yes, this how it should look like:
Actor(Player.MO).bFireDamage = true;
Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff);
Actor(Player.MO).bFireDamage = false;
Sun, 10 Sep 2006 12:53:15

Crimson Wizard

By the way, Janis, why not change Damage function so it take damage type as additional parameter? I made this in my mod earlier, it seemed to me rather convenient. You can simply declare damage type for every weapon class and projectile class, then if a weapon/missile damages actor it sends its DamageType value to Damage function. And you may get rid of LavaInflictor class.
Sun, 10 Sep 2006 16:48:09

Janis Legzdinsh

Yes, it's a good idea.
Sun, 10 Sep 2006 18:25:40

TheCount

Thank you very much for helping <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
Mon, 11 Sep 2006 05:45:10

Crimson Wizard

I noticed a mistake in my code above there again <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarassed" /><!-- s:oops: --> please, check it once more.
Mon, 11 Sep 2006 22:20:44

TheCount

Yeah, that code didn't work for me. But you gave me an idea of what I should do, and now I've made it work <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> I created a "fuego" Actor that does the actual attack and assigned it Actor(Player.MO). I set fuego fire-damaging at the beginning of the attack function, and never ser it back normal-damaging, as it would be useless (I think).
Tue, 12 Sep 2006 08:55:30

Crimson Wizard

I am not sure it is right way to do this. At first, there's no sense in making additional "fuego" actor since you may directly use Player.MO and there won't be any difference since they both refer to one object. Secondly, if you won't reset FireDamage flag, then all melee attacks will be counted as Fire damage - such as Fist or Timon Axe.
Wed, 13 Sep 2006 02:57:50

TheCount

Oops <!-- s:? --><img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /><!-- s:? --> I thought fuego would be, like, another Actor that would act exactly like Player.MO without being Player.MO <!-- s:? --><img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /><!-- s:? --> I didn't think that fuego would reference to the actual Player.MO. Well, I suppose I didn't think it through <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> Well, now I think it works fine:
void A_FSwordAttack()
{
	int damage;
	int i;
	int as;
	TAVec angles;
	TVec vforward;
	Actor(Player.MO).bFireDamage = true;
	damage = 200 + (P_Random() & 15);
	for (i = 0; i < 16; i++)
	{
		angles = Player.MO.Angles;
		angles.yaw = AngleMod360(angles.yaw + itof(i) * (45.0 / 16.0));
		Actor(Player.MO).AimLineAttack(&angles, 2.0 * Actor::MELEERANGE);
		if (Actor(Player.MO).linetarget)
		{
			AngleVector(&angles, &vforward);
			if (Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff))
			{
				Player.MO.PlaySound('FighterSwordFire', CHAN_WEAPON);
				as=1;
			}
			Player(Player).AdjustPlayerAngle();
			Actor(Player.MO).bFireDamage = false;
			return;
		}
		angles = Player.MO.Angles;
		angles.yaw = AngleMod360(angles.yaw - itof(i) * (45.0 / 16.0));
		Actor(Player.MO).AimLineAttack(&angles, 2.0 * Actor::MELEERANGE);
		if (Actor(Player.MO).linetarget)
		{
			AngleVector(&angles, &vforward);
			if (Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff))
			{
				as=1;
			}
			Player(Player).AdjustPlayerAngle();
			Actor(Player.MO).bFireDamage = false;
			return;
		}
	}
	// didn't find any creatures, so try to strike any walls
	angles = Player.MO.Angles;
	Actor(Player.MO).AimLineAttack(&angles, Actor::MELEERANGE);
	AngleVector(&angles, &vforward);
	if (Actor(Player.MO).LineAttack(vforward, Actor::MELEERANGE, damage, HammerPuff))
	{
		as=1;
	}
	if (Player(Player).Mana[HexenDefs::MANA_1] <
		WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon))
	{
		as=0;
	}
	if (Player(Player).Mana[HexenDefs::MANA_2] <
		WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon))
	{
		as=0;
	}
	
	Actor(Player.MO).bFireDamage = false;
	
	if (as==1)
	{
		PlayerPawn Owner = PlayerPawn(Player.MO);
	
		Player(Player).Mana[HexenDefs::MANA_1] -=
			WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon);
		Player(Player).Mana[HexenDefs::MANA_2] -=
			WeaponManaUse(Player.PClass, Player(Player).ReadyWeapon);
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, -10.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw + 45.0 / 4.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, -5.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw + 45.0 / 8.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin, FighterSwordMissile,
			Owner.Angles.yaw);
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, 5.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw - 45.0 / 8.0));
		Player(Player).SpawnPlayerMissileAngleXYZ(Owner.Origin + vector(0.0, 0.0, 10.0),
			FighterSwordMissile, AngleMod360(Owner.Angles.yaw - 45.0 / 4.0));
		Owner.PlaySound('FighterSwordFire', CHAN_WEAPON);
	}
	
	
}
It's a very nasty weapon <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> Thanks a lot
Wed, 13 Sep 2006 05:38:32

Crimson Wizard

[quote="TheCount":1mtku39p]I thought fuego would be, like, another Actor that would act exactly like Player.MO without being Player.MO I didn't think that fuego would reference to the actual Player.MO. Well, I suppose I didn't think it through Well, seems you've got the same problem with understanding VavoomC as I had for the first time. All the class-type variables should be treated as references to objects, not objects themselves.
Wed, 13 Sep 2006 13:19:31

Firebrand

Looking at all this, it would really be effective to add a new parameter for damage as Crimson Wizard says <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->.
Wed, 13 Sep 2006 14:25:12

Crimson Wizard

Don't know what be more appropriate for Vavoom, as for my mod, I used DamageType as binary set instead of enum, thus was able to define 2 and more damage type for one weapon, for example - fire & poison, etc. Hexen does not has much damage types, however advanced mod may use more.
Wed, 13 Sep 2006 16:30:21

TheCount

[quote="Crimson Wizard":2khd0xtm] All the class-type variables should be treated as references to objects, not objects themselves. What if I want to make a class variable that is an object? Uh, what if I want to make a duplicate of Player.MO? <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: -->
Wed, 13 Sep 2006 16:31:54

Janis Legzdinsh

Spawn a new instance.
Wed, 13 Sep 2006 16:40:27

TheCount

Right... thanks. PS that was fast
Wed, 13 Sep 2006 17:54:16

Crimson Wizard

Yes, use HexenLevelInfo::Spawn() or Actor::Spawn(). [quote="TheCount":3dmxi6ib]Uh, what if I want to make a duplicate of Player.MO? <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> Do not forget this means spawning extra playerpawn on map... though uncontrollable.
Thu, 14 Sep 2006 16:54:27

TheCount

Yeah, I know <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: -->
Fri, 15 Sep 2006 17:11:11

TheCount

Another question, sligthly out of topic. What is the best function to spawn projectiles in random directions? I want to make a projectile like fireball1 but that spawns fireball1 projectiles. I've taken the iceguymissile exploding function, but I can't figure out how to set it random angle and vertical speed. I've tried P_Random(), but it returns an int, and I need a float. Any suggestions?
Fri, 15 Sep 2006 17:21:37

Janis Legzdinsh

Use Random().
Sat, 16 Sep 2006 02:29:08

TheCount

Thanks

Back to the Vavoom Forum Archives