Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Google

Members: 0
Guests: 4
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Obj if checks
Forum Rules | Mark all | Recent Posts

Obj if checks
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 May 16, 2010, 5:58 am
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts144
JoinedJan 24, 2008

I'm posting this here, because I'm thinking this is something that would prove difficult on any codebase. However, I'm using it on an SWR (heavily-heavily modified) with most of the FUSS fixes applied.

I am writing a skill called checkmicrophone. Basically, it checks a players inventory for microphones and then returns the number to the player.

I'm using this for check to search through their things.
   for ( obj = victim->last_carrying; obj; obj = obj->prev_content )
   {

Below is a series of if checks for item types. For instance, if it's a container - it checks its contents as well.

The problem I'm having is that if objects are stacked - whether in the inventory or in a container - if only shows up as 1. Is there a better way to do this? Am I doing something wrong?
       
Post is unread #2 May 16, 2010, 7:37 am
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

Check whether count is greater than 1 or not. If it's greater than 1 add count to your number, if not, add one. Look at separate_obj() for why.
       
Post is unread #3 May 16, 2010, 8:20 am
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts144
JoinedJan 24, 2008

Awesome, thanks.

I'm trying to make it so each obj has a chance of showing up and I'm not sure how to do that with the obj->count. Should I just use a for statement to run through the count number and run the chance there?
       
Post is unread #4 May 16, 2010, 7:39 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

Something like:

for( int x = 0; x <= obj->count; x++ )
{
   //chance check
   //whatever here
}


Should work.
       
Pages:<< prev 1 next >>