Forum

misc_model

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

misc_model

Postby Chip » Wed Mar 10, 2010 1:47 pm

Hi, I have some issues with a function. I'm trying to place a misc_model inside a map. misc_model has a field called 'name' which holds the model path and name.

Everything works except that the model is not solid.

Here is the function:

Code: Select all
void() misc_model_touch =
{
   sprint(self, "This should be a model!\n");
};

void() misc_model =
{
   precache_model(self.model);

   setmodel(self, self.model);
   self.solid = SOLID_BSP;
   self.touch = misc_model_touch;
   setsize(self, self.mins, self.maxs);

//   self.modelflags = MF_GIB | MF_ROTATE;

   StartItem();
};


The model appears on the map and the compiler displays no errors. What am I doing wrong?
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby Teiman » Wed Mar 10, 2010 2:49 pm

If the obj end not solid, then has to be because of that StartItem() function.

I don't know, but It could be that StartItem calls PlaceItem, and PlaceItem change the solid type, or something like that.

health box and the like are not solid, so I can see how other objs want to be not solid ( probably SOLID_TRIGGER )
Teiman
 
Posts: 309
Joined: Sun Jun 03, 2007 9:39 am

Postby frag.machine » Wed Mar 10, 2010 3:58 pm

StartItem() changes the .solid to SOLID_TRIGGER. You may want to change your line setting it to SOLID_BSP after StartItem().
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Chip » Wed Mar 10, 2010 5:45 pm

frag.machine wrote:StartItem() changes the .solid to SOLID_TRIGGER. You may want to change your line setting it to SOLID_BSP after StartItem().


I added SOLID_BSP after StartItem(). Nothing.

StartItem() and PlaceItem() functions:

Code: Select all
/*
============
PlaceItem

plants the object on the floor
============
*/
void PlaceItem()
{
   local float   oldz;

   self.mdl = self.model;      // so it can be restored on respawn
   self.flags = FL_ITEM;      // make extra wide
   self.solid = SOLID_TRIGGER;
   self.movetype = MOVETYPE_TOSS;
   self.velocity = '0 0 0';
   self.origin_z = self.origin_z + 6;
   oldz = self.origin_z;
   
   // DRESK
   // Check for Exploding Item Box
   // NOTE: Check BEFORE Dropping Original Item to Floor
   CheckExplodingItemBox();
   // Check for Legacy Item
   CheckLegacyItemSpawn();
   
   if (!droptofloor())
   {
      // DRESK
      // Increment Debug Counter
      nNumItemsDroppedOut = nNumItemsDroppedOut + 1;
      
      dprint ("Bonus item fell out of level at ");
      dprint (vtos(self.origin));
      dprint ("\n");
      remove(self);
      return;
   }
   
   // Register Advanced Statistics
   if(self.touch == weapon_touch)
   {
      RegisterAdvancedGameStatistic(ADVANCEDSTATISTIC_TYPE_WEAPON);
      // Angle Weapons
      self.angles_x = 20;
   }
   else
   if(self.touch == powerup_touch)
      RegisterAdvancedGameStatistic(ADVANCEDSTATISTIC_TYPE_POWERUP);
   else
   if(self.touch == health_touch
      || self.touch == ammo_touch
      || self.touch == armor_touch)
   {
      RegisterAdvancedGameStatistic(ADVANCEDSTATISTIC_TYPE_HEALTHARMORAMMO);
         // Slightly Angle all Items
      self.angles_y = random() * 15;
      if(random() < 0.5)
         self.angles_y *= -1;
   }
   else
      RegisterAdvancedGameStatistic(5);
};


/*
============
StartItem

Sets the clipping size and plants the object on the floor
============
*/
void StartItem()
{
   self.nextthink = time + 0.2;   // items start after other solids
   self.think = PlaceItem;
   
   // DRESK
   // Check for Ambient Sound Spawn
   CheckAmbientSoundSpawn();
}


I tried even removing StartItem() from the misc_model function. Still not solid.

I'm using DarkPlaces + Kleshik.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby c0burn » Wed Mar 10, 2010 5:57 pm

Edit: wrong thread
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Teiman » Wed Mar 10, 2010 6:40 pm

Chip wrote:
frag.machine wrote:StartItem() changes the .solid to SOLID_TRIGGER. You may want to change your line setting it to SOLID_BSP after StartItem().


I added SOLID_BSP after StartItem(). Nothing.

StartItem() and PlaceItem() functions: ..


Maybe you need something like that:

Code: Select all
 
void () patchSolidBSP_Again = {
  self.solid = SOLID_BSP;
}

.function rethink;//is written like that?

void() misc_model =
{
   precache_model(self.model);

   setmodel(self, self.model);
   self.solid = SOLID_BSP;
   self.touch = misc_model_touch;
   setsize(self, self.mins, self.maxs);

//   self.modelflags = MF_GIB | MF_ROTATE;

   StartItem();
   
   self.rethink = patchSolidBSP_Again;
};



void PlaceItem()
{

..

  //final last  line
  if ( self.rethink)  self.rethink() ;
}


This code could be wrong, I am poor at QC.
Teiman
 
Posts: 309
Joined: Sun Jun 03, 2007 9:39 am

Postby Chip » Wed Mar 10, 2010 7:14 pm

Nope, it says unknown value 'rethink'. Compiling error.

EDIT: the sprint function doesn't work either. So the player is basically not touching the model, otherwise the sprint function should work. Hmmm. I'll do some more testing and I'll come back with the results.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby Teiman » Wed Mar 10, 2010 7:20 pm

Chip wrote:Nope, it says unknown value 'rethink'. Compiling error


I don't know QC. But thats sounds like a easy to fix problem. Move the definition of rethink early on your code ( to defs.qc if you like ).

Also, take my suggestions about QC with a grain of salt. Like.. he!.. I have miss all these ";" after "}" in the functions body..
Teiman
 
Posts: 309
Joined: Sun Jun 03, 2007 9:39 am

Postby Chip » Wed Mar 10, 2010 7:53 pm

Teiman wrote:
Chip wrote:Nope, it says unknown value 'rethink'. Compiling error


I don't know QC. But thats sounds like a easy to fix problem. Move the definition of rethink early on your code ( to defs.qc if you like ).

Also, take my suggestions about QC with a grain of salt. Like.. he!.. I have miss all these ";" after "}" in the functions body..


Thanks for that. It still does not work. And I added the necessary ; after }.

Placed the rethink in several more locations, but still doesn't work. What puzzles me is why is the sprint not working. It works with other functions. Even if not solid, like weapons.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby Lardarse » Wed Mar 10, 2010 9:01 pm

The sprint might be failing because self is not a player. Try dprint instead, and remove the entity argument from the function call. Then remember to set the developer cvar to 1.
Roaming status: Testing and documentation
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Teiman » Wed Mar 10, 2010 9:03 pm

Chip wrote:[
Placed the rethink in several more locations, but still doesn't work. What puzzles me is why is the sprint not working. It works with other functions. Even if not solid, like weapons.


About rethink.

Now that I have acces to a computer (the other comments where send using lightwaves and birds) here is the proper syntax:

.void() rethink;

You could place it at the end of defs.qc, and only once, or the compiler will get angry at you.

we really need the help of other people, more versed in QC ... :-)
Teiman
 
Posts: 309
Joined: Sun Jun 03, 2007 9:39 am

Postby Chip » Wed Mar 10, 2010 9:21 pm

@Teiman: Did what you said step by step, no compiler error, but no printing or getting the model solid.

@Lardarse: Developer activated, dprint modified, no printing, neither on-screen, nor in console.

I found a tutorial and I scavenged an old mod and I may be onto something. Did not checked yet, as I'm caught with some sites, but the syntax seems a bit diferrent. I'll try the modifications later.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby frag.machine » Wed Mar 10, 2010 9:41 pm

What are you trying exactly to do ? Some kind of item or simply a decorative entity ? If it's the second option, you may not call PlaceItem(), and avoid some obscure part of the code messing your setup.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Chip » Wed Mar 10, 2010 9:57 pm

frag.machine wrote:What are you trying exactly to do ? Some kind of item or simply a decorative entity ? If it's the second option, you may not call PlaceItem(), and avoid some obscure part of the code messing your setup.


I'm trying to place trees, barrels, pipes, decorative items.

I tried not to include the StartItem() function which in turn calls the PlaceItem() function. No success there.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby frag.machine » Thu Mar 11, 2010 1:57 am

Try this, I use it in my mod.
Set .model in the map with the desired model name (ex: "progs/player.mdl"). You may also set .frame and .skin in the same way.
.spawnflags & 1 > 0 = solid, otherwise the entity becomes static;
.spawnflags & 2 > 0 = uses shambler collision box, otherwise uses player's one.
There's lots of room for improvement, but it's a start point.
Code: Select all
// =============================================================================

void()  misc_decor =
{
    if (!self.model)
    {
        remove (self);
    }

    precache_model (self.model);
    setmodel (self, self.model);
    if (self.spawnflags & 3 > 0)
    {
        self.solid = SOLID_SLIDEBOX;
        self.movetype = MOVETYPE_STEP;
    }
    else
    {
        makestatic (self);
    }

    if (self.spawnflags & 2)
    {
        setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
    }
    else
    {
        setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
    }
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest