ivanforum ivanforum
Forum for Iter Vehemens ad Necem
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   fchat fChat   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Item making
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    ivanforum Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Atomic
archangel


Joined: 12 Jan 2005
Posts: 1442
Location: In the fire

PostPosted: Tue Apr 05, 2005 2:31 am    Post subject: Item making Reply with quote

Posting here because this could be a tad spoily:

I've been poking at item/material codes, and am wondering a few things:

What file is used for special effects/tags (e.g. for stat-boost foods, and weapons that have special effects)?

OK, there were other things but I forgot them. Razz I've been trying to make a "shield of acid" (at Ighalli's suggestion), which would have a MainMaterial of steel etc and a SecondaryMaterial of some sort of acid, and that would harm people when I blocked an attack (or if they had a weapon, could damage/destroy the weapon). A few pointers would be appriciated.
_________________
"Also, I'm the only person I know capable of a pelvic pary and riposte." -- Squashmonster

I moderate in red.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Ighalli
gibberling


Joined: 18 Jan 2005
Posts: 138
Location: Pennsylvania

PostPosted: Tue Apr 05, 2005 3:05 am    Post subject: Reply with quote

I havent coded anything besides god type stuff, so I could be wrong. But it looks like you need to do the .dat file thing (which I left out here). Then you need to use a GetSpecialFlag command on the item. These go at the top of gear.cpp

Code:
int flamingsword::GetSpecialFlags() const { return meleeweapon::GetSpecialFlags()|ST_FLAME_1; }


Later on in gear.cpp there are sections like so:
Code:
truth flamingsword::HitEffect(character* Enemy, character* Hitter, v2 HitPos, int BodyPartIndex, int Direction, truth BlockedByArmour)
{
  truth BaseSuccess = meleeweapon::HitEffect(Enemy, Hitter, HitPos, BodyPartIndex, Direction, BlockedByArmour);

  if(Enemy->IsEnabled() && RAND() & 1)
  {
    if(Enemy->IsPlayer() || Hitter->IsPlayer() || Enemy->CanBeSeenByPlayer() || Hitter->CanBeSeenByPlayer())
      ADD_MESSAGE("%s sword burns %s.", Hitter->CHAR_POSSESSIVE_PRONOUN, Enemy->CHAR_DESCRIPTION(DEFINITE));

    return Enemy->ReceiveBodyPartDamage(Hitter, 3 + (RAND() & 3), FIRE, BodyPartIndex, Direction) || BaseSuccess;
  }
  else
    return BaseSuccess;
}


In gear.h there is something like this for every item:
Code:
ITEM(flamingsword, meleeweapon)
{
 public:
  virtual truth HitEffect(character*, character*, v2, int, int, truth);
  virtual int GetSpecialFlags() const;
};


You'll need to make one of each of those. It looks like only ego weapons are working at the moment, but I imagine you could change that too. Or just brute force flaming hammers, maces, 2-h swords, etc etc.

I think I picked up all the pieces, but we'll hopefully hear from Holy or Hexi to set us straight.
Back to top
View user's profile Send private message AIM Address
holybanana
Party Chairman


Joined: 04 Jan 2005
Posts: 155
Location: Above Valpurus

PostPosted: Wed Apr 06, 2005 7:13 pm    Post subject: Reply with quote

The GetSpecialFlags() only affects the outlook of the item, not its effects. It's poorly named; eg. GetSpecialDrawFlags() would be better. ST_FLAME_1 means a flame is generated rising from pixels which represent the first material in the item's picture.

When you add special weapons, HitEffect is the main function to override. However, when doing a special shield you'll have to hack more, since we haven't yet done any and so you can't copy code quite as easily from elsewhere.

You probably shouldn't try to add a second material to it, since you want to derive it from shield, not from materialcontainer (the base for cans, bottles, mines etc. which have two materials) or meleeweapon (which also have two materials). You could of course copypaste a lot of code from either of those classes to yours and get the second material working, but it probably isn't worth it. I suggest you use a single material and add a special function which is called when the shield blocks an attack. The most important blocking function is

Code:
int character::CheckForBlockWithArm(character* Enemy, item* Weapon, arm* Arm, double WeaponToHitValue, int Damage, int Success, int Type)
{
  // lots of code here
}


in char.cpp. You'll want to add a call to a virtual function of the blocking item here, since there's none currently. Something like

Code:
Blocker->BlockEffect(this, Enemy, Weapon);


could be fine (add more parameters if you need them, as there are a lot of variables which may be of help). Then add

Code:
virtual void BlockEffect(character*, character*, item*) { }


to class item in item.h and

Code:
virtual void BlockEffect(character*, character*, item*);


to your class in gear.h and

Code:
void acidshield::BlockEffect(character* Blocker, character* Hitter, item* Weapon)
{
  // your special effect
}


to gear.cpp. Start with something simple, like splashing sulphuric acid at the Hitter and his Weapon (remember to check the pointer isn't zero, for instance if Hitter is unarmed). There's a SpillFluid function in characters and items, you can find how they work from their definition or their use in eg. the rain or fountain code. When this works, you can try to produce more complicated effects.

I apologize there is far too little comments in the code, so it may be a little hard to understand at places. Embarassed
Back to top
View user's profile Send private message Send e-mail
Atomic
archangel


Joined: 12 Jan 2005
Posts: 1442
Location: In the fire

PostPosted: Wed Apr 06, 2005 8:14 pm    Post subject: Reply with quote

*sigh* I was hoping there would be a way to do it w/o mucking in anything more than the .dat files, as I have yet to successfully compile IVAN from source. Ah well. Thanks for the tips, if I ever get IVAN to compile I'll try to code my acid shield in... Splashing sulpheric acid on their weapon sounds like it could work. Although, wouldn't that then mean that when they actually hit me it would acidize me? *shrug* Oh well. Such are the dangers of using a shield coated in acid.
_________________
"Also, I'm the only person I know capable of a pelvic pary and riposte." -- Squashmonster

I moderate in red.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
holybanana
Party Chairman


Joined: 04 Jan 2005
Posts: 155
Location: Above Valpurus

PostPosted: Wed Apr 06, 2005 8:21 pm    Post subject: Reply with quote

Yeah, some acid enters your body each time you are hit, and will do constant damage there for some time until vanishing, unless you have resistance. :twisted:

A wonderful idea in fact, I love this kind of double-edged sword items (eg. Turox, thunder hammer...), if you do it I'll add it in the game. Laughing
Back to top
View user's profile Send private message Send e-mail
Atomic
archangel


Joined: 12 Jan 2005
Posts: 1442
Location: In the fire

PostPosted: Wed Apr 06, 2005 8:25 pm    Post subject: Reply with quote

Shweeeet...

I'll get crackin tonight then. Razz I'll sacrifice FFX game time to make something for a game...
_________________
"Also, I'm the only person I know capable of a pelvic pary and riposte." -- Squashmonster

I moderate in red.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Ighalli
gibberling


Joined: 18 Jan 2005
Posts: 138
Location: Pennsylvania

PostPosted: Thu Apr 07, 2005 5:29 pm    Post subject: Reply with quote

I'm trying to make the poisoned dagger and a few other items myself, but I need some help. I want to make it so that whenever the item has Be() called it adds a very small amount of fluid (a gram or so). I've been staring at the code for awhile now, but I can't make much sense of the way fluids are currently added. Could you give me a few pointers Holy??

heres what I did so far in gear.h
Code:
ITEM(daggerofvenom, meleeweapon)
{
  public:
     virtual void Be();
}


then in gear.cpp i want to add soemthing to the effect of:
Code:
void daggerofvenom::Be()
{
   meleeweapon::Be();
   add a tiny bit of fluid  <--  this is what I'm having trouble with
   if (item totally saturated)
        spill on players arm or the floor & remove some fluid
}


Thanks a ton!
Back to top
View user's profile Send private message AIM Address
holybanana
Party Chairman


Joined: 04 Jan 2005
Posts: 155
Location: Above Valpurus

PostPosted: Thu Apr 07, 2005 7:06 pm    Post subject: Reply with quote

First you must ensure the Be function is always called by modifying class daggerofvenom:

Code:
ITEM(daggerofvenom, meleeweapon)
{
 public:
  virtual void Be();
 protected:
  virtual truth CalculateHasBe() const { return true; }
}


Normally CalculateHasBe() checks if the entity is a mirror item or if some material needs a Be-function, for instance if it's rotting slowly. There's no need to add the entity to IVAN's global entity pool if such is not the case; it'd be a waste of clock ticks to run a Be() which does nothing for every granite wall in the level, for instance.

There's a SpillFluid function declared for items:

Code:
virtual void SpillFluid(character*, liquid*, int = 0);


defined as:

Code:
void item::SpillFluid(character*, liquid* Liquid, int SquareIndex)
{
  // something
}


That character* is the spiller. It's reserved for future, 0 means no spiller. SquareIndex is only necessary for items larger than one tile, for instance Elpuri's corpse. So if you want to spill poison with a volume of X cubic centimeters, do this in the Be():

Code:
SpillFluid(0, liquid::Spawn(POISON_LIQUID, X));


SpillFluid might have problems adding the liquid to the dagger's image if X is too small, as there might be right shifts and other calculations which are rounded down. If such problems occur, consider the following alternative:

Code:
if(!RAND_N(N))
  SpillFluid(0, liquid::Spawn(POISON_LIQUID, N * X));


Where N is an integer.

Hmm. I wonder which way would be the best to check if there's too much liquid, and drop some... At least something like this should work:

Code:
fluidvector FluidVector;
FillFluidVector(FluidVector);

for(uint c = 0; c < FluidVector.size(); ++c)
{
  liquid* L = FluidVector[c]->GetLiquid();

  if(L->GetVolume() >= Y) // define yourself Y = limit volume
  {
    long Z = ??? // define yourself Z = how much to drop

    if(!game::IsInWilderness())
      GetLSquareUnder()->SpillFluid(0, L->SpawnMoreLiquid(Z));

    L->EditVolume(-Z);
  }
}


(If always Z < Y, this is actually not the optimal loop, but the fastest solution crashes if Z >= Y and a fluid is removed because of this, so you should probably play safe.)

If you really like to drop the poison to the arm, it would probably be easiest to do like this:

Code:
if((*Slot)->IsGearSlot())
  static_cast<gearslot*>(*Slot)->GetBodyPart()->SpillFluid(0, L->SpawnMoreLiquid(Z));


I don't guarantee that any of this actually works, since I tested nothing. Confused May Valpurus be with you when compiling!
Back to top
View user's profile Send private message Send e-mail
Atomic
archangel


Joined: 12 Jan 2005
Posts: 1442
Location: In the fire

PostPosted: Thu Apr 07, 2005 8:27 pm    Post subject: Reply with quote

This reminds me of something: could objects/characters that are "covered in fluid" actually drip that fluid onto the ground as they move? The animations show it dripping off, so...
_________________
"Also, I'm the only person I know capable of a pelvic pary and riposte." -- Squashmonster

I moderate in red.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
holybanana
Party Chairman


Joined: 04 Jan 2005
Posts: 155
Location: Above Valpurus

PostPosted: Thu Apr 07, 2005 9:41 pm    Post subject: Reply with quote

That would be most consistent, we'll do it eventually.
Back to top
View user's profile Send private message Send e-mail
Ighalli
gibberling


Joined: 18 Jan 2005
Posts: 138
Location: Pennsylvania

PostPosted: Fri Apr 08, 2005 12:11 am    Post subject: Reply with quote

Thanks for the help Holy! My new dagger of venom is working now (but needs balanced). I'm gonna make at least 2 more items and then I'll send you guys some code!
Back to top
View user's profile Send private message AIM Address
Ighalli
gibberling


Joined: 18 Jan 2005
Posts: 138
Location: Pennsylvania

PostPosted: Sat Apr 09, 2005 6:43 pm    Post subject: Reply with quote

OK, the program refuses to use Be on the weapons unless it already wanted to use it in the first place. Ommel tooth versions work, but other materials don't. I think it comes down to this function:

Code:
truth meleeweapon::CalculateHasBe() const
{
  return LifeExpectancy
    || (MainMaterial && MainMaterial->HasBe())
    || (SecondaryMaterial
      && SecondaryMaterial->GetVolume()
      && SecondaryMaterial->HasBe());
}


I did include
Code:
 
protected:
  virtual truth CalculateHasBe() const { return true; }

in the gear.h, but it looks like the melee weapon CalculateHasBe is overriding that one.

Any suggestion for modifying that main CalculateHasBe function?
Back to top
View user's profile Send private message AIM Address
holybanana
Party Chairman


Joined: 04 Jan 2005
Posts: 155
Location: Above Valpurus

PostPosted: Sun Apr 10, 2005 11:28 pm    Post subject: Reply with quote

Naah, it can't override your function. However, it seems CalculateHasBe() only ensures the item isn't disabled by material changes etc. So the initial enabling must be done manually be adding a constructor:

Code:
ITEM(daggerofvenom, meleeweapon)
{
 public:
  daggerofvenom() { Enable(); }
  virtual void Be();
 protected:
  virtual truth CalculateHasBe() const { return true; }
}
Back to top
View user's profile Send private message Send e-mail
Atomic
archangel


Joined: 12 Jan 2005
Posts: 1442
Location: In the fire

PostPosted: Wed Apr 13, 2005 1:57 am    Post subject: Reply with quote

Another item I'm thinking about making are a pair of gauntlets. Well, not really a pair, but two different gauntlets, that are made as singular items. I still havn't made that acid shield yet. But, I'm going to put my thoughts on these two gauntlets down so I don't forget them, and if someone else thinks they're cool and wants to code them theirselves I won't stop them.

Fist of Flames:
Artifact
Resist Fire 30
Adds a little fire damage to melee attacks with that arm
Adds lots of fire damage (plus normal damage) to unarmed melee attacks with that arm
Chance to cause a small but powerful explosion when attacking unarmed
ASTR +2 (+1 per enchantment)
Made of "Red Steel" (basically, a harder/lighter form of meteoric steel, only red)

Fist of Storms:
Artifact
Resist Electricity 30
Adds a little electricity damage to melee attacks with that arm
Adds lots of electricity damage (plus normal damage) to unarmed melee attacks with that arm
Chance to spit out a powerful lightning bolt when attacking unarmed
DEX +2 (+1 per enchantment)
Made of "White Steel" (same as Red Steel, except white)
_________________
"Also, I'm the only person I know capable of a pelvic pary and riposte." -- Squashmonster

I moderate in red.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
blob
elder dark mage


Joined: 28 Mar 2005
Posts: 999
Location: Idling in AFK-land

PostPosted: Wed Apr 13, 2005 3:02 am    Post subject: Reply with quote

They seem really powerful. isnt resist 30 too much ?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    ivanforum Forum Index -> Programming All times are GMT
Goto page 1, 2, 3  Next

Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group