Fire-damaging melee weapon (Hexen)

Talk about editing and creation of Vavoom mods

Fire-damaging melee weapon (Hexen)

Postby TheCount » 10 Sep 2006 05:04

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:
Code: Select all
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 :? 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
TheCount
 
Posts: 18
Joined: 05 Sep 2006 17:47
Location: Buenos Aires, Argentina

Postby Crimson Wizard » 10 Sep 2006 07:55

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:
http://www.vavoom-engine.com/wiki/index ... ter_Cannon

Then...
Fire damaging.
If you want fire damage for melee attacks add following in "defaultproperties" section of WeaponFighterSword class (i.e. Quietus itself):
Code: Select all
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).
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby Janis Legzdinsh » 10 Sep 2006 10:38

Fire damaging.
If you want fire damage for melee attacks add following in "defaultproperties" section of WeaponFighterSword class (i.e. Quietus itself):
Code: Select all
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.
User avatar
Janis Legzdinsh
Site Admin
 
Posts: 1952
Joined: 13 Jan 2002 08:30
Location: Limassol, Cyprus

Postby Crimson Wizard » 10 Sep 2006 12:32

Oops, my mistake.
Yes, this how it should look like:
Code: Select all
Actor(Player.MO).bFireDamage = true;
Actor(Player.MO).LineAttack(vforward, 2.0 * Actor::MELEERANGE, damage, HammerPuff);
Actor(Player.MO).bFireDamage = false;
Last edited by Crimson Wizard on 11 Sep 2006 05:44, edited 2 times in total.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby Crimson Wizard » 10 Sep 2006 12:53

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.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby Janis Legzdinsh » 10 Sep 2006 16:48

Yes, it's a good idea.
User avatar
Janis Legzdinsh
Site Admin
 
Posts: 1952
Joined: 13 Jan 2002 08:30
Location: Limassol, Cyprus

Postby TheCount » 10 Sep 2006 18:25

Thank you very much for helping :)
TheCount
 
Posts: 18
Joined: 05 Sep 2006 17:47
Location: Buenos Aires, Argentina

Postby Crimson Wizard » 11 Sep 2006 05:45

I noticed a mistake in my code above there again :oops: please, check it once more.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby TheCount » 11 Sep 2006 22:20

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 :)
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).
TheCount
 
Posts: 18
Joined: 05 Sep 2006 17:47
Location: Buenos Aires, Argentina

Postby Crimson Wizard » 12 Sep 2006 08:55

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.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby TheCount » 13 Sep 2006 02:57

Oops :?
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 :roll:
Well, now I think it works fine:
Code: Select all
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 :)

Thanks a lot
TheCount
 
Posts: 18
Joined: 05 Sep 2006 17:47
Location: Buenos Aires, Argentina

Postby Crimson Wizard » 13 Sep 2006 05:38

TheCount wrote: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.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby Firebrand » 13 Sep 2006 13:19

Looking at all this, it would really be effective to add a new parameter for damage as Crimson Wizard says :).
User avatar
Firebrand
 
Posts: 1000
Joined: 11 Feb 2004 08:12
Location: Mexico

Postby Crimson Wizard » 13 Sep 2006 14:25

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.
Crimson Wizard
 
Posts: 881
Joined: 09 Nov 2005 14:21
Location: St. Petersburg, Russia

Postby TheCount » 13 Sep 2006 16:30

Crimson Wizard wrote: 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?
:roll:
TheCount
 
Posts: 18
Joined: 05 Sep 2006 17:47
Location: Buenos Aires, Argentina

Next

Return to Editing

Who is online

Users browsing this forum: No registered users and 1 guest

cron