Jump to content
eggcarton

Scripting Help

Recommended Posts

I am currently working on a script based on the 3 pistol scripts (Draw, Shoot and Holster weapon).

I have been successful in drawing the weapon (OBJ_WEAPON) and having the new commands appear. But when I click on Holster weapon it doesn't do anything.

I think when I had the PushActionDrawWeapon it drew and holstered properly, but I had the problem since I took it out.

The commented code is shown below


const char CMD_SHOOTGUN[] = "Shoot";
const char CMD_HOLSTERGUN[] = "Holster";
const char CMD_DRAWGUN[] = "Draw";
const char SND_DRAW[] = "mod:Audio/FX/Misc/DrawWeapon.wav";
const char OBJ_WEAPON[] = "QLD Equipment/aim.v3o";
const char HINT_HELICOPTER[] = "Draw PA";
const char HINT_HELICOPR[] = "Holster PA";
const char HINT_HCOPTER[] = "Shoot PA";

object Draw : CommandScript
{

Draw()
{
SetValidTargets(ACTOR_PERSON);
SetDoubleClickable(true);
SetGroupID(CGROUP_GETEQUIPMENT);
SetGroupLeader(true);
SetPossibleEquipment(EQUIP_NONE);
SetRestrictions(RESTRICT_SELFEXECUTE);
SetDeselectCaller(false);
SetPriority(700);
}

bool CheckGroupVisibility(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;
return !Caller->IsEquipped();
}

bool CheckPossible(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;
Person p(Caller);
if(p.IsValid() && !p.IsLinkedWithPerson() && !p.IsCarryingPerson() && p.GetEnteredCarID() == -1)
return true;
return false;
}

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

Person p(Caller);
if(p.IsValid() && !p.IsEquipped() && !p.IsLinkedWithPerson() && !p.IsCarryingPerson())
return true;

return false;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
//this all works - plays hint, gets OBJ_WEAPON, modifies commands etc.
Mission::PlayHint(HINT_HELICOPTER);
Person p(Caller);
p.PlaceObjectInRightHand(OBJ_WEAPON);
p.PushActionSwitchAnim(ACTION_APPEND, "idlegun");
p.AssignCommand(CMD_SHOOTGUN);
p.AssignCommand(CMD_HOLSTERGUN);
p.RemoveCommand(CMD_DRAWGUN);

Vector Pos = Caller->GetPosition();
Audio::PlaySample3D(SND_DRAW, Pos);
}
};

object Holster : CommandScript
{

Holster()
{
SetValidTargets(ACTOR_PERSON);
SetDoubleClickable(false);
SetGroupID(CGROUP_DRAW_WEAPON); //this should be GETEQUIPMENT
SetRestrictions(RESTRICT_SELFEXECUTE);
SetDeselectCaller(false);
SetPriority(700);
}

bool CheckGroupVisibility(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;
return true; //???
}

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

//if(Caller->GetEquipment()==EQUIP_PISTOL)
//return false;

return false;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
//this is what it should execute. I have added the hint to see if it does anything, which it does not.
Mission::PlayHint(HINT_HELICOPR);
Person p(Caller);
p.RemoveObjectInRightHand();
p.RemoveCommand(CMD_SHOOTGUN);
p.RemoveCommand(CMD_HOLSTERGUN);
p.AssignCommand(CMD_DRAWGUN);

Vector Pos = Caller->GetPosition();
Audio::PlaySample3D(SND_HOLSTER, Pos);
}
};

object Shoot : CommandScript //this doesn't do anything either, but lets ignore this for the moment
{
Shoot()
{
SetValidTargets(ACTOR_PERSON | ACTOR_VEHICLE | ACTOR_OBJECT);
SetRestrictions(RESTRICT_SHOOTABLE | RESTRICT_NOTDESTROYED | RESTRICT_NOTINJURED);
SetPriority(700);
}

bool CheckPossible(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
return false;
Person p(Caller);
if(!p.IsValid() || p.IsLinkedWithPerson() || p.GetEnteredCarID() != -1)
return false;
}

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

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

GameObject obj(Target);
if(!obj.IsValid())
return false;

if(Target->GetType()==ACTOR_VEHICLE)
{
Vehicle v(Target);
if (!v.IsCivilCar())
SetPriority(-700); // low priority for shooting at squad cars

if (!v.IsValid() || ((v.GetVehicleType() == VT_POLICE_PHC || v.GetVehicleType() == VT_AMBULANCE_RHC || v.GetVehicleType() == VT_THW_FGRT_BH) && !v.IsOnGround()))
return false;
}


return false;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Mission::PlayHint(HINT_HCOPTER);
Caller->PushActionTurnTo(ACTION_NEWLIST, Target);
Caller->PushActionShoot(ACTION_APPEND, Target);
}
};

Thanks

eggcarton

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