PDA

View Full Version : Need some help/guidance on mod


PsychoPidgin
09-18-2010, 12:23 PM
Hey, so I'm working on a mod (puzzle kinda game) and I was wondering if someone could link me to similar things/examples/tips. I've looked over the wiki but it's very limited into helping with what I'm trying to do.

So basically I'm trying to do 2 things.
A. Have a weapon entity that when fired on an entity communicates with the entity (we'll be making our own entities anyway for other various functions) So that it can either call a function on the entity and on the player, as well as.
B. Have it so that 2 entities can communicate with each other via finding them in the map (aka not collisions)

As an example I shoot one object and then when I shoot another object the first one overrides the second and the second is removed. (There's other things but if I can get this working on the others should be easy enough)

Well thanks for playing I mean listening. If you can help, or link me to some tutorials/code snippets that be awesome.

z33ky
09-18-2010, 12:58 PM
Create a new entity-baseclass for those communicating entities. Let it have two virtual functions, I'll just name them ReactToPlayer and ReactToEntity.
Then in that weapon have a pointer to a communicating entity, upon creation set to NULL.
Additionally, add a virtual function to the CBaseEntity class checking if it is a communicating entity. Let the default implementation return the bool fase, and override it for the communicating entity baseclass to return true.

Upon shooting (after checking if it has hit a communicating entity via UTIL_TraceLine and calling that function I mentioned earlier) it'll check if the pointer is NULL and if so, set it to the hit entity and call ReactToPlayer( pPlayer ).
If it is not NULL, it shall call ReactOnEntity( pStoredEntity, pPlayer ) and set the pointer to NULL, so the process can be repeated.

I'm not sure what you mean by the first entity overriding the second and the second getting removed. What do you mean by an entity overriding another? Cloning/duplicating it?

PsychoPidgin
09-24-2010, 11:39 AM
Thanks for your help, I've gotten it setup so that there are pointers to props stored in the player file and you can cycle through them and overwrite another prop with selected props.

Basically what I've asked is working but if you can help with cloning an object that's another thing we're working on. Namely the weapon has a pointer to the stored entity in the player and it needs to create a new entity that is the same as the one scanned. Aka make a clone that is entirely separate from the scanned enitity.

I've seen some tutorials with getting the point where the gun is shooting and creating an object but they all ask for the modelname in the code where as I am doing mine dynamically based on what was scanned.