Modding Help..

Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
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-->

Comments

  • CrispyCrispy Jaded GD Join Date: 2004-08-22 Member: 30793Members, Constellation
    Most of us here just use the entities and wouldn't no where to begin when actually coding one. I'd suggest Off-Topic. For instance, there's one topic there about someone coding a C++ game which had a fair few responses from like-minded programmers.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Thanks Crispy..

    Can a Mod move this to Off-Topic?
  • BigDBigD [OldF] Join Date: 2002-10-25 Member: 1596Members
    edited July 2007
    <a href="http://www.nsmod.org" target="_blank">www.nsmod.org</a> (Go to coders corner.)

    Lots of programmer types in modNS as well.
  • KungFuDiscoMonkeyKungFuDiscoMonkey Creator of ns_altair 日本福岡県 Join Date: 2003-03-15 Member: 14555Members, NS1 Playtester, Reinforced - Onos
    <!--quoteo(post=1636861:date=Jul 1 2007, 01:17 PM:name=Soul_Rider)--><div class='quotetop'>QUOTE(Soul_Rider @ Jul 1 2007, 01:17 PM) [snapback]1636861[/snapback]</div><div class='quotemain'><!--quotec-->
    Can a Mod move this to Off-Topic?
    <!--QuoteEnd--></div><!--QuoteEEnd-->
    Moved
  • GeminosityGeminosity :3 Join Date: 2003-09-08 Member: 20667Members
    ick... this is kinda stuff I love helping with but I've not had a chance to look at the HL2 code yet I'm afraid :(
Sign In or Register to comment.