Jump to content
Guest Overland

Creating a new command

Recommended Posts

Guest Overland

Hello guys. I am looking the ability to turn traffic lights on/off by simply clicking on them.

I am going to go about this by creating a command:

/Scripts/Game/Command.

My question is firstly, is there a tutorial on this subject? (not found using the search function).

And has anyone seen this done before?

Thanks,

Overland

Link to comment
Share on other sites

Unless you have quite extensive knowledge of C++ I woudlnt waste my time. Hell I know a little C++ but couldnt dream of scripting the things Hoppah has done.

Something is really wrong with you when you dream of my scripting experience... :smoke:

Link to comment
Share on other sites

Guest Overland

I am a Software Engineer. But Java not C++, but the syntax shouldn't be a problem.

It's just getting started, I see you guys declare the variables at the top of the page - but are the traffic lights and object with properties?

E.g. have the lights got a go/stop property?

Cheers guys,

Overland

P.s I have edited + commented a winterberg script, just see whether you think I have the "right idea"

object CheckVictim : CommandScript
{
CheckVictim()
{
// Setting a valid target.
SetValidTargets(ACTOR_PERSON);
// Setting a priority
SetPriority(1000);
// Setting a exit
SetPossibleExists(CPE_INJURED_PERSON);
// Setting required equipment.
SetPossibleEquipment(EQUIP_NONE);
}

bool CheckPossible(GameObject *Caller)
{
// If the caller is not valid or the caller is not an actor person. Return false.
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
{
return false;
}
else
{
return true;
}
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
// Is the caller is not valid OR if the caller is equiped OR is the target is not valid OR if the target ID is equal to the caller ID
if(!Caller->IsValid() || Caller->IsEquipped() || !Target->IsValid() || Target->GetID() == Caller->GetID())
{
return false;
}

// Declaring a variable previously called P, renamed to callerVariable.
Person callerVariable(Caller);
// Declaring a variable previously T, renamed to targetVariable.
Person targetVariable(Target);

// IS the target has a name prefix of "Corpse"
if (Target->HasNamePrefix("leiche"))
{
return true;
}
// IF the caller is valid AND the target is valid AND the target is dead AND the target is not carried AND the target is not an animal AND the target is not a rescue dog AND the target is not drowning.
if(callerVariable.IsValid() && targetVariable.IsValid() && targetVariable.IsDead() && !targetVariable.IsCarried() && targetVariable.GetRole()!=ROLE_ANIMAL && !targetVariable.IsRescueDog() && !targetVariable.IsDrowning())
{
// IF the callers get entered car ID NOT EQUALS -1 AND the callers get entered car target ID NOT EQUAL targets get entered house ID RETURN FALSE.
if (callerVariable.GetEnteredCarID() != -1 && callerVariable.GetEnteredCarTargetID() != targetVariable.GetEnteredHouseID())
{
return false;
}
// If the callers get entered car ID EQUALS -1 AND the targets get house ID NOT EQUAL -1 AND the targets get entered house ID NOT EQUAL the the callers get entered house ID and the target is NOT in house with ground enterance.
if (callerVariable.GetEnteredCarID() == -1 && targetVariable.GetEnteredHouseID() != -1 && targetVariable.GetEnteredHouseID() != callerVariable.GetEnteredHouseID() && !targetVariable.IsInHouseWithGroundEntrance())
{
return false;
}
// Is the target is NOT victim AND the target is NOT bulldozable return FALSE
if (!targetVariable.IsVictim() && !targetVariable.IsFlagSet(OF_BULLDOZABLE))
{
return false;
}
// Else return TRUE
else
{
return true;
}
}
// Else return FALSE.
else
{
return false;
}
}

Link to comment
Share on other sites

Guest Overland

I thought I had it then :rofl:

Back to the code.

P.s. in winterberg mod there is an event where the traffic lights break and someone has to come and fix them. Any idea where I could find the code for the events in the mod structure?

Link to comment
Share on other sites

And since it is part of the game it is likley hard coded into the game. Now being a software engineer, you may be able to reverse the games files to revel the code. I had a program to do it but i forgot what it was now. :( Anyways if you can do that you can see the code for the traffic light failure and perhaps modify this to suit your needs.

Link to comment
Share on other sites

Guest miked9372

i know

go to my computer > c: drive > program files > what ever > emergency 4 > mods > winterberg

specs > open "freeplayparameters" with notepad

find:

<!-- DG -->

<TrafficLightFailure AverageFrequency="0.1"/>

<!-- AverageFrequency: average number of events per 10 minutes -->

change "0.1" to what ever you want

ex "0.0" no traffic light failure

ex2: 9.9 a lot of traffic light failure's

hope that helps

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