Modding Help..
Soul_Rider
Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
in Off-Topic
OK, I know this is the mapping section, but we don't have a modding section yet, and I am trying to work on some things for a HL2MP MOD I am creating, which by the time it's ready for release, will hopefully come out as a mod for NS2, as it ties in with this very much.
All the important elements I am creating are being saved so I can easily port over and make the neccesary modifications in the NS2 source. This will hopefully add more support to NS2.
Anyway.....
I am currently trying to create a brush based entity called trigger_objective......
<u><b>Trigger objective</b></u>
What I want it to do.
create a brush entity that detects the number of people touching it from a specific team and fires an output to a target (The Objective ie, capture a flag, blow up a target, etc) on completion of timer. The target will be an independant entity, so that is irrelevant. What I need help with is authoring the entity.
The details:
Detect # of players from team "x" touching triggerbox send output to all players touching entity informing of the number of people in area. (HUD Icon).
If 0, do nothing.
If 1, start counting and fire event after 30 secs
if 2, 3/4 the remianing time till event fire
If 3, 1/2 remianing time till event fire
if 4, 1/4 remaining time until event fire
if 5, 1/6 remaining time until event fires
if >5, 1/10th remaining time until event fires
when event fires +3 score to player 1
when event fires +1 score to all other players.
If player leaves area and players left =0 reset counter
if player leaves area and players left >0 move player 2-1, 3-2 etc,
recalculating time left.
Currently I have a created a map based version, but it only works on the first
player.
Trigger_presence, set's off timer, at end of timer event happens.
This is ok for now, but not what i want. Can anyone help with the coding. I am very new to c++, been using Source SDK and C++ for a week now and have no previous programming experience so forgive me if my attempts are way off the mark....
The Breakdown of instruction as i see it at the moment:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
//========================Trigger Objective=================================
// Purpose: create a brush entity that detects the number of people touching
// it from a specific team and fires an output to a target (The Objective ie,
// capture a flag, blow up a target, etc) on completion of timer. The target
// will be an independant entity,
// Andy
//====================================================================
#include "cbase.h"
#include "c_baseentity.cpp"
class CObjectiveEntity : public CBaseToggle
{
public:
DECLARE_CLASS( CObjectiveEntity, CBaseToggle;) //Declare it's class
DECLARE_DATADESC();
void Spawn( void ); //This is where we define spawn characteristics
void BrushTouch( void ); //This is the function that will tell us when it is touched.
void Timer( void ); //This will calculate the time left to output
};
// Give the entity the name "Trigger_Objective"
LINK_ENTITY_TO_CLASS( Trigger_Objective, CObjectiveEntity );
// The rest of this is just placeholder logic that needs to be turned into code, but i want to make
// sure the logic is right before attempting the code.
BEGIN_DATADESC( CObjectiveEntity )
DEFINE_FIELD( ******* ) ,// This field needs to grab the team number selected that
// will trigger the entity. Either team_combine or team_rebels
DEFINE_ENTITYFUNC( BrushTouch ),//Define it as being a touch function
END_DATADESC()
void CObjectiveEntity::Spawn( void )
{
// Here I want to make it so it captures touches from player entities on the correct team
SetTouch( &CObjectiveEntity::BrushTouch ); //This to me says set touch to record touch between
// my entity and the result of the BrushTouch function. I may be wrong
SetMoveType( MOVETYPE_NONE ); // Will not move on its own
SetSolid( SOLID_NONE ); // Will not collide with anything
}
// This is the touch function that records all touches. If the teamnumber matches the yet unplanned define_field, then it should record as a touch. If it doesn't match it won't. Not sure about true/false though.
bool CObjectiveEntity::BrushTouch( void )
{
if ( GetLocalTeam() == (The Define_field i haven't yet worked out))
{
return Timer()
}
else if (GetLocalTeam() /= (The Define_field i havent worked out))
{
//Do nothing
}
}
void CObjectiveEntity::Timer( void )
{
//Need function to count down from 30, but with a subroutine that checks if more than one player is active in the area and works out the percentage difference. This will probably need more functions but after 6 hours on this my head is begining to hurt..........
}
<!--c2--></div><!--ec2-->
All the important elements I am creating are being saved so I can easily port over and make the neccesary modifications in the NS2 source. This will hopefully add more support to NS2.
Anyway.....
I am currently trying to create a brush based entity called trigger_objective......
<u><b>Trigger objective</b></u>
What I want it to do.
create a brush entity that detects the number of people touching it from a specific team and fires an output to a target (The Objective ie, capture a flag, blow up a target, etc) on completion of timer. The target will be an independant entity, so that is irrelevant. What I need help with is authoring the entity.
The details:
Detect # of players from team "x" touching triggerbox send output to all players touching entity informing of the number of people in area. (HUD Icon).
If 0, do nothing.
If 1, start counting and fire event after 30 secs
if 2, 3/4 the remianing time till event fire
If 3, 1/2 remianing time till event fire
if 4, 1/4 remaining time until event fire
if 5, 1/6 remaining time until event fires
if >5, 1/10th remaining time until event fires
when event fires +3 score to player 1
when event fires +1 score to all other players.
If player leaves area and players left =0 reset counter
if player leaves area and players left >0 move player 2-1, 3-2 etc,
recalculating time left.
Currently I have a created a map based version, but it only works on the first
player.
Trigger_presence, set's off timer, at end of timer event happens.
This is ok for now, but not what i want. Can anyone help with the coding. I am very new to c++, been using Source SDK and C++ for a week now and have no previous programming experience so forgive me if my attempts are way off the mark....
The Breakdown of instruction as i see it at the moment:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
//========================Trigger Objective=================================
// Purpose: create a brush entity that detects the number of people touching
// it from a specific team and fires an output to a target (The Objective ie,
// capture a flag, blow up a target, etc) on completion of timer. The target
// will be an independant entity,
// Andy
//====================================================================
#include "cbase.h"
#include "c_baseentity.cpp"
class CObjectiveEntity : public CBaseToggle
{
public:
DECLARE_CLASS( CObjectiveEntity, CBaseToggle;) //Declare it's class
DECLARE_DATADESC();
void Spawn( void ); //This is where we define spawn characteristics
void BrushTouch( void ); //This is the function that will tell us when it is touched.
void Timer( void ); //This will calculate the time left to output
};
// Give the entity the name "Trigger_Objective"
LINK_ENTITY_TO_CLASS( Trigger_Objective, CObjectiveEntity );
// The rest of this is just placeholder logic that needs to be turned into code, but i want to make
// sure the logic is right before attempting the code.
BEGIN_DATADESC( CObjectiveEntity )
DEFINE_FIELD( ******* ) ,// This field needs to grab the team number selected that
// will trigger the entity. Either team_combine or team_rebels
DEFINE_ENTITYFUNC( BrushTouch ),//Define it as being a touch function
END_DATADESC()
void CObjectiveEntity::Spawn( void )
{
// Here I want to make it so it captures touches from player entities on the correct team
SetTouch( &CObjectiveEntity::BrushTouch ); //This to me says set touch to record touch between
// my entity and the result of the BrushTouch function. I may be wrong
SetMoveType( MOVETYPE_NONE ); // Will not move on its own
SetSolid( SOLID_NONE ); // Will not collide with anything
}
// This is the touch function that records all touches. If the teamnumber matches the yet unplanned define_field, then it should record as a touch. If it doesn't match it won't. Not sure about true/false though.
bool CObjectiveEntity::BrushTouch( void )
{
if ( GetLocalTeam() == (The Define_field i haven't yet worked out))
{
return Timer()
}
else if (GetLocalTeam() /= (The Define_field i havent worked out))
{
//Do nothing
}
}
void CObjectiveEntity::Timer( void )
{
//Need function to count down from 30, but with a subroutine that checks if more than one player is active in the area and works out the percentage difference. This will probably need more functions but after 6 hours on this my head is begining to hurt..........
}
<!--c2--></div><!--ec2-->
Comments
Can a Mod move this to Off-Topic?
Lots of programmer types in modNS as well.
Can a Mod move this to Off-Topic?
<!--QuoteEnd--></div><!--QuoteEEnd-->
Moved