Jump to content
BxPanxi

How to add Police Barricade tool to other mod cars?

Recommended Posts

Hi, I am trying to get the Police Barricade tool into a mod called Northview South County. It has the script, but the script points to some .e4p files, how do I make a e4p for a Vehicle? I thought I needed to add the tool name in the unit.xml but I don't know the tool name either. Please help!

 

i am also aware this is a very old game and I probably won't get a response. 

Link to comment
Share on other sites

Units xml has nothing to do with any of the custom equipment found in mods.

You need to edit the script files. They contain the list of units that have the barricades. The scripts for ballistic shields, guns, and traffic cones also operate on the same logic.

Untitled.png

  • Upvote 1
Link to comment
Share on other sites

@itchboySorry I don't respond for a while, I don't expect to get a response immediately.

 

Here's a link to a GIF which shows what section I changed. If you just want the code, it is below; https://gyazo.com/675636db75500ccda8f627721769ff1d

 

Spoiler

            if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/hummerh2_lasd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 US Army/hmmwv.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/us_army_truck.e4p") == 0)
                return true;

            return false;
        }
    }

    void PushActions(GameObject *Caller, Actor *Target, int childID)
    {
        Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);

        Caller->PushActionMove(ACTION_NEWLIST, TargetPos);
        Caller->PushActionTurnTo(ACTION_APPEND, Target);
        Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);
        Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_BARRICADE, Target, 1, false);
    }
};

object PcmdBarricadeRemove : CommandScript
{
    
    PcmdBarricadeRemove()
    {
            SetIcon("policebarricaderemove");
            SetCursor("policebarricaderemove");
        SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);
        SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASROADBLOCK);
        SetPossibleCallers(ACTOR_PERSON);
        SetNeedsCarWithFlagSet(OF_HAS_ROADBLOCK);
    }

    /*bool CheckPossible(GameObject *Caller)
    {
        if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
            return false;
        Person p(Caller);
        if (p.IsCarryingPerson()||p.IsLinkedWithPerson()|| p.GetFirehoseID()!=0 || p.IsPulling())
            return false;
        if (!Game::ExistsNormalObjectWithFlagSet(OF_HAS_ROADBLOCK))
            return false;
        return true;
    }*/

    bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    {
        if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)
            return false;
        
        if(Caller->GetObjectType()==TYPE_PERSON)
        {
            Person p(Caller);
            Vehicle v(Target);

            if (v.IsDestroyed())
                return false;

            if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) 
                return false;

            Vehicle v(Target);

            if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/hummerh2_lasd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/hmmwv.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/us_army_truck.e4p") == 0)
                return true;

            return false;
        }
    }

 

Link to comment
Share on other sites

I found that the simplest way to do it was to make dummy commands and assign them to any applicable vehicle, which the equipment script would then check for.

object FlagHasBarricade : CommandScript
{
	FlagHasBarricade()
	{
		SetGroupID(20);
	}
	bool CheckGroupVisibility(GameObject *Caller)
	{
		return false;
	}

	bool CheckPossible(GameObject *Caller)
	{
		return false;
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		return false;
	}

	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
	}
};

And then in the script CheckTarget section, just add this:

if (!Target->HasCommand("FlagHasBarricade")) 
            return false;

It makes it very simple to add new vehicles later: just add the dummy command and they're all set.
 

Link to comment
Share on other sites

Alright so I'm having a few troubles. I tried to do it again and now it says theres an error with the parenthesis. 

I don't know what's wrong here? 

@itchboy

And, @The LootI'm not really the best at this stuff so I didn't get what you meant by that script at all, sorry!

 

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0
				return true;

			return false;
		}
	}

	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
		Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);

		Caller->PushActionMove(ACTION_NEWLIST, TargetPos);
		Caller->PushActionTurnTo(ACTION_APPEND, Target);
		Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);
		Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_BARRICADE, Target, 1, false);
	}
};

object PcmdBarricadeRemove : CommandScript
{
	
	PcmdBarricadeRemove()
	{
    		SetIcon("policebarricaderemove");
    		SetCursor("policebarricaderemove");
		SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);
		SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASROADBLOCK);
		SetPossibleCallers(ACTOR_PERSON);
		SetNeedsCarWithFlagSet(OF_HAS_ROADBLOCK);
	}

	/*bool CheckPossible(GameObject *Caller)
	{
		if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
			return false;
		Person p(Caller);
		if (p.IsCarryingPerson()||p.IsLinkedWithPerson()|| p.GetFirehoseID()!=0 || p.IsPulling())
			return false;
		if (!Game::ExistsNormalObjectWithFlagSet(OF_HAS_ROADBLOCK))
			return false;
		return true;
	}*/

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)
			return false;
		
		if(Caller->GetObjectType()==TYPE_PERSON)
		{
			Person p(Caller);
			Vehicle v(Target);

			if (v.IsDestroyed())
				return false;

			if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) 
				return false;

			Vehicle v(Target);

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 
				return true;

			return false;
		}
	}

 

Link to comment
Share on other sites

Alright seems what I did didn't work. What happened here..?  @itchboy

 

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0) 
				return true;
			return false;
			}
		}
	}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...