Jump to content
Guest RunAwayScientist

Help - OnAskPerson command?

Recommended Posts

Guest RunAwayScientist

Alright, I need a little scripting help. I've never had such a bad-headache as I do having to test this thing by loading up the game and going through that in trial and error.

Anyway, this is what I'm trying to do. I'm looking for a OnAskPerson command. When a police officer goes up to someone and talks to them using AskPerson I want the person to switch behaviour to GANGSTER_ATTACK_ACTION_FORCE and then I'll switch his ObjectPath to some sort of flee path and have him shoot the cop and run off. That's the idea.

I could get it to work, if only I knew how to detect if a person has had the AskPerson command used on them. Anyone know of the method I'm looking for?

--RunAwayScientist

Link to comment
Share on other sites

Guest RunAwayScientist

No, a person I've already defined in the script. It's just one guy. All I need is the method header, such as OnAskPerson(Object User, Person person) or however it's supposed to go...if there even is a command. If not, I'll just have to find another way to do what I want.

--RunAwayScientist

Link to comment
Share on other sites

Ok

Here is the new script (askperson.script):

const char NAME_PERSON01[] 	= "badguy01"; 		//name of person
const char NAME_ESCAPE01[] = "escapepath01"; //name of escape path

object AskPerson : CommandScript
{
AskPerson()
{
SetValidTargets(ACTOR_PERSON);
SetRestrictions(RESTRICT_NOTARRESTED | RESTRICT_NOTINJURED);
SetDeselectCaller(false);
SetPossibleCallers(ACTOR_PERSON);
SetPossibleExists(CPE_ASKABLE_PERSON);
SetPriority(600);
SetSelfClickActivation(true);
}

bool CheckPossible(GameObject *Caller)
{
/*if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;*/
Person c(Caller);
if (c.IsLinkedWithPerson() || c.IsCarryingPerson())
return false;
//return Game::ExistsAskablePerson();
return true;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if(!Caller->IsValid() || !Target->IsValid() || Target->GetID() == Caller->GetID() )
return false;

if(Caller->GetType()!=ACTOR_PERSON)
return false;

Person c(Caller);
if (c.GetEnteredCarID() != -1 || c.IsLinkedWithPerson() || c.IsCarryingPerson())
return false;

if(Target->GetType()==ACTOR_PERSON)
{
Person p(Target);
if(p.GetRole() == ROLE_GANGSTER || !p.CanBeAsked())
return false;

return true;
}

return false;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Caller->PushActionMove(ACTION_NEWLIST, Target, TARGET_FOLLOW);
Caller->PushActionTurnTo(ACTION_APPEND, Target);
Person p(Target);
if (p.HasName(NAME_PERSON01))
{
p.SetRole(ROLE_GANGSTER);
p.SetBehaviour(BEHAVIOUR_GANGSTER_ATTACKSQUAD);
p.SetEscapePath(PATH_ESCAPE01);
p.SetStandardPath(PATH_ESCAPE01);
p.SetFleeing(true);
return;
}
Caller->PushActionAskPerson(ACTION_APPEND, Target);
}
};

The first two lines of the script:

The name of the person who attacks your squad must be: badguy01

The name of the escape path: escapepath01

Then I added this to the script:

if (p.HasName(NAME_PERSON01))

{

p.SetRole(ROLE_GANGSTER);

p.SetBehaviour(BEHAVIOUR_GANGSTER_ATTACKSQUAD);

p.SetEscapePath(PATH_ESCAPE01);

p.SetStandardPath(PATH_ESCAPE01);

p.SetFleeing(true);

return;

}

The person role changes to ROLE_GANGSTER, behaviour to BEHAVIOUR_GANGSTER_ATTACKSQUAD.

If the police officer is in range he will attack him, otherwise he will escape. So the escape path is added too.

Last thing:

The ROLE of the bad guy must be civilian, before you are going to "ask" him, because this command doesn't work with ROLE_GANGSTER persons. You can change names and roles in the editor.

Hoppah

Link to comment
Share on other sites

Guest RunAwayScientist

Great! That was exactly what I was looking for. I can finally finish my officer down mission. Thank you very much. I hope you enjoy playing it when I get to releasing it....sometime in the next few days.

--RunAwayScientist

Link to comment
Share on other sites

Guest RunAwayScientist

Thanks to Hoppah I've almost got it working. I have to tweak a few settings and play test it some more until I'm sure it's right. So, I think I'll be releasing this in about maybe one more hour. It's pretty much good to go.

--RunAwayScientist

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