Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

misc_model Goto page 1, 2 Next

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 1:47 pm Post subject: misc_model |

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:
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?
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

Teiman Joined: 03 Jun 2007 Posts: 309 |

Posted: Wed Mar 10, 2010 2:49 pm Post subject: |

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 )

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Wed Mar 10, 2010 3:58 pm Post subject: |

StartItem() changes the .solid to SOLID_TRIGGER. You may want to change your line setting it to SOLID_BSP after StartItem(). _________________ frag.machine - Q2K4 Project http://fragmachine.quakedev.com/

Back to top |

Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 5:45 pm Post subject: |

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:
/* ============ 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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

c0burn Joined: 05 Nov 2004 Posts: 158 Location: Liverpool, England |

Posted: Wed Mar 10, 2010 5:57 pm Post subject: |

Edit: wrong thread

Back to top |

Teiman Joined: 03 Jun 2007 Posts: 309 |

Posted: Wed Mar 10, 2010 6:40 pm Post subject: |

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:
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.

Back to top |

Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 7:14 pm Post subject: |

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

Teiman Joined: 03 Jun 2007 Posts: 309 |

Posted: Wed Mar 10, 2010 7:20 pm Post subject: |

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..

Back to top |

Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 7:53 pm Post subject: |

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

Lardarse Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK |

Posted: Wed Mar 10, 2010 9:01 pm Post subject: |

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. _________________ <ekiM> Son, you're writing data structures your CPU can't cache.

Back to top |

Teiman Joined: 03 Jun 2007 Posts: 309 |

Posted: Wed Mar 10, 2010 9:03 pm Post subject: |

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 ...

Back to top |

Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 9:21 pm Post subject: |

@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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Wed Mar 10, 2010 9:41 pm Post subject: |

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. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/

Back to top |

Chip Joined: 21 Jan 2009 Posts: 314 Location: Romania |

Posted: Wed Mar 10, 2010 9:57 pm Post subject: |

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.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Thu Mar 11, 2010 1:57 am Post subject: |

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:
// ============================================================================= 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);
}
};

_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT Goto page 1, 2 Next
Page 1 of 2

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 © 2004 phpBB Group