Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Today, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Sogou, Yahoo!

Members: 0
Guests: 16
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Adding affects from inventory...
Forum Rules | Mark all | Recent Posts

Adding affects from inventory - Solved :D
< Newer Topic :: Older Topic > ITEM_TREASURE addition

Pages:<< prev 1 next >>
* #1 Feb 19, 2011, 12:15 am
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Okay, so here's the deal. I'm attempting to allow treasures to give affects to players while remaining in their inventory. The problem is, I can't seem to figure out where to add the checks to allow this.

So, basically, this is what I want to have happen:
treasure has +5 hr/dr (or whatever) and placed in a player's inventory
+5 hr/dr (or whatever) is applied to the player from their inventory

Any help/guidance in accomplishing this is greatly appreciated. :)

Cheers,
Aurin
       
Post is unread #2 Feb 19, 2011, 6:22 pm
Go to the top of the page
Go to the bottom of the page

Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005

So, just for the sake of clarity, you want all items to impart their affects simply from being in inventory rather than needing to be equipped? Or are you saying that you've got certain specific items that you want to do so?

If the former, you're going to have to change the way affects are applied in the code. If the latter, you could just give the specific items progs based on the get (to apply affects) and drop (to remove affects) triggers.
       
Post is unread #3 Feb 19, 2011, 8:33 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

If it's a specific item type, I might have some code around here that could help, but I'll need a little bit of clarification to know for sure.
       
Post is unread #4 Feb 19, 2011, 9:04 pm   Last edited Feb 19, 2011, 9:05 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

To clarify...
obj->item_type == ITEM_TREASURE
This is what I want to have affects applied from. nothing else within the inventory. heh

So yeah, looks like the get/drop/give commands would need updated as possibly the easiest solution to what I wanted to do. Just thought that I mighta been able to add a check for inventory and obj->item_type == ITEM_TREASURE wherever it's currently being applied within the code when equipped.
       
Post is unread #5 Feb 20, 2011, 12:03 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Well, you might be able to, but it'd probably be easier to look at wear/remove and see how they do it and then do the same thing for get/drop/give for your treasure type.
       
Post is unread #6 Feb 22, 2011, 2:15 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Thanks for that guidance, Kayle. Was able to find how they do it, finally, within wear_obj and remove_obj. Kind of annoying, though, as the ac affect (not armor ac) is applied twice. Trying to track down why that is and correct it. Or, at least have it show properly on objects. The things you find while looking for other things, eh? *LOL*
       
Post is unread #7 Feb 22, 2011, 9:48 pm   Last edited Feb 22, 2011, 9:48 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

update...

Okay, I've got it all added in, didn't require too much in the way of addition either.
act_obj.c:
1. In do_get add the folowing:
a. find if(arg2[0] == '\0')
Add below that just before the else:
	  if(obj->item_type == ITEM_TREASURE)
	  {
	    AFFECT_DATA    *paf;
        if(IS_OBJ_STAT(obj, ITEM_MAGIC))
          ch->carry_weight -= obj->weight;
        for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
        for(paf = obj->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
	  }
b. find for(obj = ch->in_room->last_content; obj; obj = obj_next)
Add the below at the end of the ifcheck:
		  if(obj->item_type == ITEM_TREASURE)
		  {
		  AFFECT_DATA    *paf;
            if(IS_OBJ_STAT(obj, ITEM_MAGIC))
              ch->carry_weight -= obj->weight;
            for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
              affect_modify(ch, paf, TRUE);
            for(paf = obj->first_affect; paf; paf = paf->next)
              affect_modify(ch, paf, TRUE);
		  }
c. find if(!IS_OBJ_STAT(container, ITEM_COVERING) && IS_SET(container->value[1], CONT_CLOSED))
After that is another ifcheck for "all", within there before the else, add the following:
	  if(obj->item_type == ITEM_TREASURE)
	  {
	    AFFECT_DATA    *paf;
        if(IS_OBJ_STAT(obj, ITEM_MAGIC))
          ch->carry_weight -= obj->weight;
        for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
        for(paf = obj->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
	  }
d. after the else check, look for the for loop
At the end of the for loop before the closing bracket, add:
	  if(obj->item_type == ITEM_TREASURE)
	  {
	    AFFECT_DATA    *paf;
        if(IS_OBJ_STAT(obj, ITEM_MAGIC))
          ch->carry_weight -= obj->weight;
        for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
        for(paf = obj->first_affect; paf; paf = paf->next)
          affect_modify(ch, paf, TRUE);
	  }

		  
2. In do_drop add the following:
a. find if(number <= 1 && str_cmp(arg, "all") && str_prefix("all.", arg))
Add before the else:
  	if(obj->item_type == ITEM_TREASURE)
	{
	  AFFECT_DATA    *paf;
      if(IS_OBJ_STAT(obj, ITEM_MAGIC))
        ch->carry_weight -= obj->weight;
      for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
        affect_modify(ch, paf, FALSE);
      for(paf = obj->first_affect; paf; paf = paf->next)
        affect_modify(ch, paf, FALSE);
	} 
b. find for(obj = ch->first_carrying; obj; obj = obj_next)
Add the below at the end of the else:
		if(obj->item_type == ITEM_TREASURE)
		{
		AFFECT_DATA    *paf;
          if(IS_OBJ_STAT(obj, ITEM_MAGIC))
            ch->carry_weight -= obj->weight;
          for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
          for(paf = obj->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
		}
		
3. In do_give add the following:
a. find mprog_give_trigger(victim, ch, obj);
Add the below after:
  if(obj->item_type == ITEM_TREASURE)
  {
    AFFECT_DATA    *paf;
    if(IS_OBJ_STAT(obj, ITEM_MAGIC))
      ch->carry_weight -= obj->weight;
    for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
	{
      affect_modify(ch, paf, FALSE);
	  affect_modify(victim, paf, TRUE);
	}
    for(paf = obj->first_affect; paf; paf = paf->next)
	{
      affect_modify(ch, paf, FALSE);
	  affect_modify(victim, paf, TRUE);
	}
  }
  
4. In do_put add the following:
a. find if(number <= 1 && str_cmp(arg1, "all") && str_prefix("all.", arg1))
Add the following above the else:
		if(obj->item_type == ITEM_TREASURE)
		{
		AFFECT_DATA    *paf;
          if(IS_OBJ_STAT(obj, ITEM_MAGIC))
            ch->carry_weight -= obj->weight;
          for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
          for(paf = obj->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
		}
b. after the else check before the closing bracket for the for loop
Add the following:
		if(obj->item_type == ITEM_TREASURE)
		{
		AFFECT_DATA    *paf;
          if(IS_OBJ_STAT(obj, ITEM_MAGIC))
            ch->carry_weight -= obj->weight;
          for(paf = obj->pIndexData->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
          for(paf = obj->first_affect; paf; paf = paf->next)
            affect_modify(ch, paf, FALSE);
		}


handler.c:
1. in affect_modify
a. find case APPLY_AC:
Change to:
// Being doubled and can't find where...so it'll get halved here! -Aurin
      ch->armor += mod/2;
      break;

And, if I ever figure out where the armor is being doubled, i can remove this part that part in handler.c. heh
       
Pages:<< prev 1 next >>