Forum Mod Bakery Docs

Additional Script Functionality Ideas

Please login to contribute to the conversation.
EXPECT ME TO UPDATE THE LIST WITH IDEAS EVERYONE ELSE HAD ALREADY THOUGHT OF.

I had a bunch of ideas for more commands in ASF that posting them in the Discord felt like copypasta. So uh... here it is.


AddObjective("losecars");
    AddCondTargetModel("AICAR");
    AddCondTargetModel("ANOTHERAICAR");
    SetObjDistance(x);
    TargetsAlwaysActive();
Similar to the new "destroycars" objective but it's a "losetail" variant. TargetsAlwaysActive will make it so that even if the player loses one of the targets but not the rest, it'll still have a chance to catch up. If it's not there, AI cars that lost the player despawn.


AddObjective("pushcars");
    AddCondTargetModel("AICAR");
    AddCondTargetModel("ANOTHERAICAR");
    AddTrigger("TRIGGER");
    AddTrigger("ANOTHERTRIGGER");
Target vehicles need to hit any of the triggers assigned for the player to clear the stage. Maybe I want an AI car to avoid going to the beach in Level 3, and I want the player to push it towards the beach.


//x = Maximum ambush cars that can appear at once.
//    Must be greater than 0. If left blank, default to 1.
AddCondition("ambush", x);
    AddCondVehicle("AICAR");
    AddCondVehicle("DIFFERENTAICAR");
Previously suggested in a Twitter post, but I had so little room to write how Ambush could work. Ambush works similar to Hit & Run, but these vehicles can't bust you (and they can be any vehicle and not just the cop cars that the level has already loaded). They spawn and despawn just like the H&R cops.


SetStageAsResetPoint(x);    //x = Locator where player will respawn after reset
I'm sure a lot of you have had an idea like this before. When the player fails/restarts the mission during or after the stage that contains this, they will go back to the last stage containing this command at the locator defined.


AddObjective("delivery or dump");
     AddCollectible("COLLECTIBLE");
     SetTargetValue(x);
     SetFakeTargetValue(y);
     SetInstantCompleteCollectible("COLLECTIBLE");

//x = Target number of things the player needs to collect,
//    even if there's more than enough items to collect.

//y = Target number the HUD will display even if SetTargetValue
//    is set to something else.
Road Rage Returns did something similar, but collecting the last items will play a barrage of "collect" sounds.


AddObjective("race");
    AddCollectible("LOCATOR", "MODEL");
    AddCollectible("ANOTHERLOCATOR", "MODEL");
    AddCollectible("YETANOTHERLOCATOR", "MODEL");
    NoCollectSound();
Don't play a sound when hitting a checkpoint. Useful for missions like The Fat and Furious.


AddObjective("timer");
    SetDurationTime(TIME);
    StageIsCutscene(x, "PLAYER_LOCATOR_IF_SKIPPED");
    AddCutscenePlayerWaypoint("player", "WAYPOINT");
    AddCutscenePlayerWaypoint("npc", "ANOTHERWAYPOINT");
    SetStageCam("CAMERA_LOADED_IN_M#L.MFK");

//x = Number of stages to skip when cutscene is skipped. If 0, it cannot be skipped at all.
StageIsCutscene adds the black bars during a start cam transition or dialogue stage, and it makes the player lose control of their character.


AddCondition("race");
    NoDistantFailure();
Player will not fail the mission if the target car is too far away. Some mods have missions that have this problem.


EDIT 1

SetStageTime(x);
DisplayTimeAt(y);

//y = anything below x
Surprise people and make them say, "Wait. This mission has a time limit?" The time limit won't appear until it has reached below the value in DisplayTimeAt.


AddStageVehicle("AICAR", "LOCATOR", "ANYTHING_BUT_NULL", "STAT_FILE","DRIVER", "DELAY_TYPE", x, GROUP_NUMBER);
ActivateVehicle("AICAR", "DONT_KNOW_WTH_THIS_IS", "ANYTHING_BUT_NULL", "DELAY_TYPE", x, GROUP_NUMBER);

//x = depends on the delay type
//y = group number
DELAY_TYPE and x are used for activating an AI car after a certain amount of time.
If DELAY_TYPE is "distance", x is the minimum distance the player can be away from the target before it starts moving.
If DELAY_TYPE is "time", x is the number of seconds the target waits for before moving. Can be a decimal.
The group number is explained in the next idea.


AddStageGroupWaypoint(x, "LOCATOR");

//x = AI cars with the matching group number will go this waypoint
One AI car may want to go to Kwik-E-Mart, while another may want to go to the Power Plant. This command allows different AI cars to take different paths.


UseRandomWaypoints();
AddStageRandomWaypoint("LOCATOR1", x);
AddStageRandomWaypoint("LOCATOR2", x);
AddStageRandomWaypoint("LOCATOR3", x);

//x =  Chance the AI cars will go to this locator
AI cars will randomly choose which waypoint to go to first (but they won't all go to the same ones), and each waypoint reached will make the AI car randomly choose the next waypoint (as long as it's not the waypoint they just touched).


SetStageAIChaseParams("AICAR", x1, x2, x3, y1, y2, y3, y4, y5);

//x1 = Whether or not AI cars will chase the player (0 or 1)
//x2 = Minimum time AI car will change targets while currently chasing the player
//x3 = Maximum time AI car will change targets while currently chasing the player

//y1 = Whether or not AI cars will chase other AI cars (0 or 1)
//y2 = Minimum time AI car will change targets while currently chasing another AI car
//y3 = Maximum time AI car will change targets while currently chasing another AI car
//y4 = Whether AI car will always go back to targeting the player (0) or another AI car (1)
//y5 = The only other AI car that the car will chase

//EXAMPLES

SetStageAIChaseParams("wiggu_v", 0, 0, 0, 1, 0, 0, 0, "snake_v");
//Wiggum will only chase Snake. All six of the 0's don't matter.

SetStageAIChaseParams("snake_v", 1, 0, 0, 0);
//Snake will only chase the player

SetStageAIChaseParams("plowk_v", 1, 20, 60, 1, 5, 10, 0);
//Barney will chase the player and other AI cars, but the player is his primary target

SetStageAIChaseParams("otto_v", 1, 1, 2, 1, 20, 20, 1);
//Otto will chase the player and other AI cars, but the other AI cars are his primary targets
Um... ok. I don't know how to explain this one.


StageVehiclesCanDamageOthers();
Some mods use AddStageVehicle to place the player inside another vehicle mid-mission. Unfortunately, they can't deal damage to other vehicles. This command will fix this. Would've suggested this as a standalone hack, but what if I want a 1v3 fight and don't want AI cars to accidentally blow themselves up?
[deleted user]
5 yrs ago (Statistics)
These ideas are cool! Hope some of them will be implemented in ASF
We'll keep these in mind when making more functionality for this hack. I have more specific comments about each one but I'm not currently at my computer so I'll get back to you later today with those.

In general though, these are pretty solid ideas.
Alright, I'm now able to give my full opinions on these.

AddObjective("losecars");
    AddCondTargetModel("AICAR");
    AddCondTargetModel("ANOTHERAICAR");
    SetObjDistance(x);
    TargetsAlwaysActive();
I like this one in concept though I can't think of how we'd convey to the player how far they are from each car.

AddObjective("pushcars");
    AddCondTargetModel("AICAR");
    AddCondTargetModel("ANOTHERAICAR");
    AddTrigger("TRIGGER");
    AddTrigger("ANOTHERTRIGGER");
This one sounds more feasible, in this case I think it would be up to the mod to decide how to illustrate to the player where they need to get the cars. Maybe the HUD could just have a count for how many cars you've gotten to the designated zones.

Also if this were implemented, there should probably be a way to specify that a trigger can only be used once. So if you have two cars, you need to get each one to a different trigger and not the same one.

Lastly, I'm guessing the most logical thing to do is "shutdown" the AI car when it enters one of the target triggers (probably by just changing what AI controller it's using midway through the stage). Maybe this should also be configurable if a developer wants the cars to remain active until every one of them as entered one of the zones (which could allow for some extra challenge).

//x = Maximum ambush cars that can appear at once.
//    Must be greater than 0. If left blank, default to 1.
AddCondition("ambush", x);
    AddCondVehicle("AICAR");
    AddCondVehicle("DIFFERENTAICAR");
The game on some level already supports multiple chase managers so maybe this could build on that. Though in the release game they only ever allow one to exist, there's a possibility this limit could be increased for mission specific ones like this.

It would also require a way to disable the cars "busting" you if you just want to use the chase manager to harass the player instead of punish them (though this would be configurable as well).

AddObjective("delivery or dump");
     AddCollectible("COLLECTIBLE");
     SetTargetValue(x);
     SetFakeTargetValue(y);
     SetInstantCompleteCollectible("COLLECTIBLE");

//x = Target number of things the player needs to collect,
//    even if there's more than enough items to collect.

//y = Target number the HUD will display even if SetTargetValue
//    is set to something else.
This is definitely a cleaner idea for achieving what we did in RRR. Jake actually suggested something like this sometime ago and I did pitch it to Lucas last night before I went to bed (I don't quite remember what he said about it right now though).

The concept of specifying a target value (like the actual amount the player needs to get and not the fake one displayed on the HUD) is interesting. I could see collection stages where there's more collectibles than you need and the player is able to decide which ones they want to get for the most optimal route.

NoCollectSound();
This is probably easy though I don't really know anything about how this effect works so I might be wrong.

AddObjective("timer");
    SetDurationTime(TIME);
    StageIsCutscene(x, "PLAYER_LOCATOR_IF_SKIPPED");
    AddCutscenePlayerWaypoint("player", "WAYPOINT");
    AddCutscenePlayerWaypoint("npc", "ANOTHERWAYPOINT");
    SetStageCam("CAMERA_LOADED_IN_M#L.MFK");

//x = Number of stages to skip when cutscene is skipped. If 0, it cannot be skipped at all.
The "camera" objective might interest you since it already covers the camera part of this. As for the walking stuff, maybe we could utilize the functionality of the "SetInitialWalk" function Radical often uses at the start of levels to achieve this.

AddCondition("race");
    NoDistantFailure();
This is also probably easy though again, I'm not 100% sure.



In conclusion, these are great ideas. We'd probably use different command names for several of these but the concepts behind them are great and I'll have some conversations with Lucas about them.
[deleted user]
5 yrs ago (Statistics)
This is what I thought of for today, but I will almost definitely update this post with more ideas.
EDIT: Added an "avoidguards" condition to my suggestions.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Command Modification:
 ActivateVehicle(“vehicle”, “NULL”, “chase”, “targetvehicle”); 

Additional fourth argument sets a target AI car for a vehicle with the ‘chase’ behavior. If left blank it will default to targeting the player.

Example of an ‘escort’ stage using this functionality:

AddStage(); //Protect the armored truck
	SetStageMessageIndex(00); 
	SetHUDIcon(“arm_v”);
	ActivateVehicle(“cArmor”, “NULL”, “target”);
ActivateVehicle(“snake_v”, “NULL”, “chase”, “cArmor”);
AddStageWaypoint(“armor_waypoint”);
AddObjective(“follow”);
	SetObjTargetVehicle(“cArmor”);
CloseObjective();
AddCondition(“destroycars”);
	SetCondTotal(1);
	AddCondModel(“cArmor”);
CloseCondition();
ShowStageComplete();
CloseStage();

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

New Command:
 AttachStatePropCollectible(“spcollectible”, “vehicle”); 

Attaches a State Prop Collectible (like the nuclear barrel) to an AI car or the player’s car if the second argument is left blank.

New Objective:
AddObjective(“destroyspcollectibles”);
	AddObjSPCollectible(“spcollectible”);
	SetObjTotal(1);
CloseObjective();

The objective is passed if the specified State Prop Collectibles are knocked off of an AI car or the player’s car in the specified amount

New Condition:
AddCondition(“keepspcollectible”);
	SetCondSPCollectible(“spcollectible”);
	SetCondTotal(1);
CloseCondition();

The mission is failed if the specified State Prop Collectibles are knocked off of an AI car or the player’s car in the specified amount.

Example stage using the State Prop Collectible command, objective, and condition.

AddStage(); //Keep your flag while destroying the enemies’
	SetStageMessageIndex(00);
	SetHUDIcon(“flags”);
	AttachStatePropCollectible(“greenflag”);
	AttachStatePropCollectible(“redflag”, “loren_v”);	
	AttachStatePropCollectible(“blueflag”, “jake_v”);
	AttachStatePropCollectible(“yellowflag”, “kenny_v”);
	ActivateVehicle(“loren_v”, “NULL”, “chase”);
	ActivateVehicle(“jake_v”, “NULL”, “chase”);
	ActivateVehicle(“Kenny_v”, “NULL”, “chase”);
	AddObjective(“destroyspcollectibles”);
		AddObjSPCollectible(“redflag”);
		AddObjSPCollectible(“blueflag”);
		AddObjSPCollectible(“yellowflag”);
		SetObjTotal(3);
	CloseObjective();
	AddCondition(“keepspcollectibles”);
		AddCondSPCollectible(“greenflag”);
		SetCondTotal(1);
	CloseCondition();
	ShowStageComplete();
CloseStage();

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Command Modification:
AddCondition(“condition”, #);
AddCondition(“condition”, “sethitandrun”);

The extra argument can act in two ways. The first variant sets the player back the number of stages specified by the argument integer when the condition is triggered instead of failing the player, similar to how the ‘keepbarrel’ condition works in the vanilla game. The second variant activates a Hit and Run in the stage when the condition is triggered instead of failing the player.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Objective Modification:
AddObjective(“delivery”);
	AddCollectible(“collectible1”);
	AddCollectible(“collectible2”);
	AddCollectible(“collectible3”);
	SetObjTotal(2);
CloseObjective();

Sets a cap on the amount of items required to be collected in the stage, meaning more items can be spawned than the player needs to collect.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

New Condition:
AddCondition(“avoidguards”);
        AddCondGuardNPC(“npc_name”, detect_radius, dradius_front, detect_speed, dspeed_walk, dspeed_run, dspeed_sprint, dspeed_drive, dspeed_faceplayer, detect_decay “kicked_action”);
        AddCondGuardVehicle(“vehicle_name”, detect_radius, dradius_front, detect_speed, dspeed_drive, dspeed_faceplayer, detect_decay, collide_action);
        SetCondMessageIndex(##);
        SetCondSound(“enter_guard_radius”, “sound_name”);
        SetCondSound(“inside_guard_radius”, “soundname”, timebetween, startdelay);
        SetCondSound(“exit_guard_radius”, “soundname”);
CloseCondition();

This condition would allow you to specify NPCs and vehicles in the mission as guards the player needs to avoid.

Command Specifics:
 AddCondGuardNPC() – Sets an NPC in the world as a guard the player must avoid. The NPCs would be able to use walkpoints in order to create patterns that the player must work around. 
 AddCondGuardVehicle() – Sets an AI vehicle in the world as a guard the player must avoid. The vehicle’s behavior could be set to anything, including “NULL”. 

Arguments common to both of the above commands:
 detect_radius: Sets the radius of detection for the NPC/vehicle. 
 dradius_front: Sets the line of sight for the NPC/vehicle facing forward. 
 detect_speed: Sets the rate at which the detection meter increases -- the time it takes for the NPC/vehicle to “notice” the player and trigger the condition -- when the player is inside its detection radius. 
 dspeed_drive: Sets a multiplier for the detection speed if the player is driving in a car. 
 dspeed_faceplayer: Sets a multiplier for the detection speed if the NPC/vehicle is facing the player. 
 detect_decay: Sets the rate at which the detection meter decays for a NPC/vehicle when the player is out of its detection radius. 

Arguments specific to AddCondGuardNPC():
 “npc_name”: Sets the NPC which is to become a guard. 
 dspeed_walk: Sets a multiplier for the detection speed if the player is walking. 
 dspeed_run: Sets a multiplier for the detection speed if the player is running. 
 dspeed_sprint: Sets a multiplier for the detection speed if the player is sprinting. 
 “kicked_action”: Sets an action to occur if the NPC is kicked. This can either be set to “alert” which triggers the condition if the NPC is kicked, or “knockout” which disables the NPC as a guard after being kicked. Not including this argument will trigger no additional action when the NPC is kicked. 

Arguments specific to AddCondGuardVehicle():
 “vehicle_name”: Sets the vehicle which is to become a guard. 
 collide_action: Sets a portion of the detection meter to be filled if the vehicle is collided with by the player vehicle. 

Other commands:
 SetCondMessageIndex() – Sets a message to be displayed when the player enters a guard’s detection radius. 

SetCondSound() – Sets sounds to be played on various actions involving the condition.
        “enter_guard_radius”: Plays a sound upon entering a guard’s detection radius.
        “inside_guard_radius”: Plays a sound while inside a guard’s detection radius.
	“exit_guard_radius”: Plays a sound upon exiting a guard’s detection radius.
I made more ideas in the main post. Try not to get lost up there.