Jump to content
The Loot

Error Adding Restrictions When Calling Units From "Off-Map" Via Script

Recommended Posts

I'm trying to recreate the restriction of one bomb robot when it comes to calling additional ambulances from off map.

 

So far, I've added this to the top of the script:

const char NAME_AMBULANCE03[]             = "Ambulance03";const char NAME_AMBULANCE04[]             = "Ambulance04";const char NAME_AMBULANCE05[]             = "Ambulance05";

And then used this as the script for creating a vehicle:

{System::Log("Buy ALS Ambulance");            bool Ambulance03 = true;            bool Ambulance04 = true;            bool Ambulance05 = true;                        GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03)                if (list.GetNumObjects() > 0) Ambulance03 = false;            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04)                if (list.GetNumObjects() > 0) Ambulance04 = false;            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05)                if (list.GetNumObjects() > 0) Ambulance05 = false;                        int Money = Mission::GetMoneyLeft();            if (Money <= 550) Ambulance04 = false;            else if (Money <= 850)(Ambulance03 = false && Ambulance05 = false);                        Vehicle n;            if (Ambulance04 = true)                {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED);                    int NewMoney = Money - 550;                }            else if (Ambulance05 = true)                {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED);                    int NewMoney = Money - 850;                }            else if (Ambulance03 = true)                {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED);                    int NewMoney = Money - 850;                }            else {Mission::PlayHint(HINT_NOAMBULANCE); return;}                        Mission::SetMoney(NewMoney);            n.SetSpeed(12.0f);                        Person p1; Person p2;            p1 = Game::CreatePerson(OBJ_PM, UNNAMED); p2 = Game::CreatePerson(OBJ_PM, UNNAMED);            n.SetPlayerMP(Caller->GetPlayerMP()); p1.SetPlayerMP(Caller->GetPlayerMP()); p2.SetPlayerMP(Caller->GetPlayerMP());            p1.SetUpgradeLevel(3); p2.SetUpgradeLevel(3);            n.SetMaxPassengers(2); n.SetMaxTransports(1); n.AddPassenger(&p1); n.AddPassenger(&p2); n.SetPosition(Spawn); n.UpdatePlacement(); n.Hide();            n.PushActionTurnTo(ACTION_NEWLIST, Rotate); n.PushActionWait(ACTION_APPEND, 35.0f); n.PushActionShowHide(ACTION_APPEND, false); n.PushActionMove(ACTION_APPEND, CmdPos); n.RemoveCommand("VcmdToFireStation"); n.RemoveCommand("VcmdToHospital"); n.RemoveCommand("VcmdPatrolAmbulance");            if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed()) Game::ExecuteCommand(CMD_SIREN, &n, &n); Mission::PlayHint(HINT_ALSAMBUBOUGHT);                    }

 

I end up with the following script errors:

  • ?(_LACallAmbulance80504): Error: Game::GetGameObjects(NAME_AMBULANCE03)if(list.GetNumObjects()>0)Ambulance03  Syntax error?
  • ?(_LACallAmbulance80504):  FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203
  • ?(_LACallAmbulance80504): Error: if(list.GetNumObjects()>0)Ambulance03  Syntax error?
  • ?(_LACallAmbulance80504):  FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203
  • ?(_LACallAmbulance80504): Error: Symbol list is not defined in current scope
  • ?(_LACallAmbulance80504):  FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203
  • ?(_LACallAmbulance80504): Error: Failed to evaluate list.GetNumObjects()
  • ?(_LACallAmbulance80504): Possible candidates are...
  • ?(_LACallAmbulance80504): filename       line:size busy function type and name  
  • ?(_LACallAmbulance80504):
  • ?(_LACallAmbulance80504): Error: improper lvalue
  • ?(_LACallAmbulance80504):  FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203
  • ?(_LACallAmbulance80504): !!!Dictionary position rewound...
  • ?(_LACallAmbulance80504): !!!Error recovered!!!

Obviously I'm missing some code from the LABombRobot script, but I haven't messed with this before.

 

I've added my "Call Ambulance" and "LA Bomb Robot" script files.

Scripts.rar

 

Link to comment
Share on other sites

 Try putting  the false declaration in brackets like i've done below. (Copy and paste this snippet over the current code.

	    GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03)		if (list.GetNumObjects() > 0)                 {                Ambulance03 = false;                }            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04)		if (list.GetNumObjects() > 0)                 {                Ambulance04 = false;                }            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05)		if (list.GetNumObjects() > 0)                 {                Ambulance05 = false;                {
Link to comment
Share on other sites

Found a few missing semicolons and added braces, so I've got this now.

 

bool Ambulance03 = true;            bool Ambulance04 = true;            bool Ambulance05 = true;                    GameObjectList list = Game::GetGameObjects(PROTO_AMBULANCE03);                if (list.GetNumObjects() > 0){Ambulance03 = false;}            list = Game::GetGameObjects(PROTO_AMBULANCE04);                if (list.GetNumObjects() > 0){Ambulance04 = false;}            list = Game::GetGameObjects(PROTO_AMBULANCE05);                if (list.GetNumObjects() > 0){Ambulance05 = false;}                                        int Money = Mission::GetMoneyLeft();            if (Money <= 550) {Ambulance04 = false;}            else if (Money <= 850) {Ambulance03 = false; Ambulance05 = false;}                        Vehicle n;            if (Ambulance04 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED);                    int NewMoney = Money - 550;                }            else if (Ambulance05 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED);                    int NewMoney = Money - 850;                }            else if (Ambulance03 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED);                    int NewMoney = Money - 850;                }            else {Mission::PlayHint(HINT_NOAMBULANCE); return;}

 

Problem is that it seems "GameObjectList" check isn't either finding the proto (if that's valid to use there), or isn't setting it to false if it is.

Link to comment
Share on other sites

Sorry to bump, but I've tried another method and I still can't get it to work.

 

*System::Log("Buy ALS Ambulance");        bool Ambulance03 = true;        bool Ambulance04 = true;        bool Ambulance05 = true;                ActorList l5 = Game::GetActors(PROTO_AMBULANCE03);        ActorList l6 = Game::GetActors(PROTO_AMBULANCE04);        ActorList l7 = Game::GetActors(PROTO_AMBULANCE05);        if(l5.GetNumActors() > 0)            Ambulance03 = false;        if(l6.GetNumActors() > 0)            Ambulance04 = false;        if(l7.GetNumActors() > 0)            Ambulance05 = false;        int Money = Mission::GetMoneyLeft();        if (Money <= 550)            Ambulance04 = false;        if (Money <= 850)        {            Ambulance03 = false;            Ambulance05 = false;        }        Vehicle n;        if (Ambulance04)        {            n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED);            int NewMoney = Money - 550;        }        else if (Ambulance03)        {            n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED);            int NewMoney = Money - 850;        }        else if (Ambulance05)        {            n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED);            int NewMoney = Money - 850;        }        else        {            Mission::PlayHint(HINT_NOAMBULANCE);            return;        }
     

Anyone have ideas?

Link to comment
Share on other sites

I'm trying to recreate the restriction of one bomb robot when it comes to calling additional ambulances from off map.

 

So far, I've added this to the top of the script:

const char NAME_AMBULANCE03[]             = "Ambulance03";const char NAME_AMBULANCE04[]             = "Ambulance04";const char NAME_AMBULANCE05[]             = "Ambulance05";

And then used this as the script for creating a vehicle:

                  GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03)                if (list.GetNumObjects() > 0) Ambulance03 = false;            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04)                if (list.GetNumObjects() > 0) Ambulance04 = false;            GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05)                if (list.GetNumObjects() > 0) Ambulance05 = false;
 

 

Here your using NAME_AMBULANCE03 to define your ambulance

 

Found a few missing semicolons and added braces, so I've got this now.

bool Ambulance03 = true;            bool Ambulance04 = true;            bool Ambulance05 = true;                    GameObjectList list = Game::GetGameObjects(PROTO_AMBULANCE03);                if (list.GetNumObjects() > 0){Ambulance03 = false;}            list = Game::GetGameObjects(PROTO_AMBULANCE04);                if (list.GetNumObjects() > 0){Ambulance04 = false;}            list = Game::GetGameObjects(PROTO_AMBULANCE05);                if (list.GetNumObjects() > 0){Ambulance05 = false;}                                        int Money = Mission::GetMoneyLeft();            if (Money <= 550) {Ambulance04 = false;}            else if (Money <= 850) {Ambulance03 = false; Ambulance05 = false;}                        Vehicle n;            if (Ambulance04 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED);                    int NewMoney = Money - 550;                }            else if (Ambulance05 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED);                    int NewMoney = Money - 850;                }            else if (Ambulance03 == true)                {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED);                    int NewMoney = Money - 850;                }            else {Mission::PlayHint(HINT_NOAMBULANCE); return;}

Problem is that it seems "GameObjectList" check isn't either finding the proto (if that's valid to use there), or isn't setting it to false if it is.

And here your using this PROTO_AMBULANCE05!

 

Did you change the Objects list to match your script or vise versa? ( PROTO_AMBULANCE00 shout be NAME_AMBULANCE00) Right?

You said the gameobjects list wasn't find the prototypes and this would be a cause of that!

 

 

Also const char NAME_AMBULANCE03[]             = "Ambulance03"; <- Define the hole path to your ambulance mod:prototypes/vehicles/ambulance/...

 

There could be one more problem but try that and see what you get!

And i think if the other error is what i think it will be it shouldn't be hard to fix!

Link to comment
Share on other sites

Update: Seems the one step I was missing was actually naming spawned vehicles, as the script was looking for object names. I should be able to finally implement this.

 

Edit: Hmm, nope.

 

?(_LACallAmbulances836a0): Error: Can't call ActorList::ActorList((class GameObjectList)753413496) in current scope

ActorList l5 = Game::GetGameObjects("Ambulance03");

Is ActorList or GetGameObjects the wrong function for getting vehicles assigned certain names?

BOOM! "Actor" was wrong completely, and of course doesn't mix with "Object". Works perfectly now.

bool Ambulance03 = true;bool Ambulance04 = true;bool Ambulance04_1 = true;bool Ambulance05 = true;		bool Ambulance05_1 = true;		bool SUV = true;GameObjectList l5 = Game::GetGameObjects("Ambulance03");GameObjectList l6 = Game::GetGameObjects("Ambulance04");GameObjectList l7 = Game::GetGameObjects("Ambulance04_1");GameObjectList l8 = Game::GetGameObjects("Ambulance05");GameObjectList l9 = Game::GetGameObjects("Ambulance05_1");GameObjectList l10 = Game::GetGameObjects("SUV");if(l5.GetNumObjects() > 0)	Ambulance03 = false;if(l6.GetNumObjects() > 0)	Ambulance04 = false;if(l7.GetNumObjects() > 0)	Ambulance04_1 = false;if(l8.GetNumObjects() > 0)	Ambulance05 = false;if(l9.GetNumObjects() > 0)	Ambulance05_1 = false;if(l10.GetNumObjects() > 0)	SUV = 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...