#pragma semicolon 1#pragma newdecls required
#include<sourcemod>#include<sdktools>#include<actions>publicvoidOnActionCreated(BehaviorAction action,int actor,constchar[] name ){if( strcmp(name,"WitchAttack")==0){/* Hook OnStart handler */
action.OnStart=OnStart;}}publicActionOnStart(BehaviorAction action,int actor,BehaviorAction priorAction,ActionResult result ){/* When WitchAttack actions starts force it to end */
result.type = DONE;returnPlugin_Changed;}
Пользовательские действия:
#pragma semicolon 1#pragma newdecls required
#include<sourcemod>#include<sdktools>#include<actions>publicvoidOnActionCreated(BehaviorAction action,int actor,constchar[] name ){if( strcmp(name,"SurvivorAttack")==0)
action.OnStart=OnStart;}publicActionOnStart(BehaviorAction action,int actor,BehaviorAction priorAction,ActionResult result ){/* We suspend WitchAttack action for our action *//* That means WitchAttack will be like in frozen state *//* It's will not be updated until our action is done */return action.SuspendFor(MyCustomAction(),"Suspend example");}BehaviorActionMyCustomAction(){/* Creating action */BehaviorAction action =ActionsManager.Create("MyCustomAction");/* Setup event handlers */
action.OnStart=OnMyActionStart;
action.OnUpdate=OnMyActionUpdate;return action;}publicActionOnMyActionStart(BehaviorAction action,int actor,BehaviorAction priorAction,ActionResult result ){PrintToServer("We are started!");returnPlugin_Continue;}publicActionOnMyActionUpdate(BehaviorAction action,int actor,float interval,ActionResult result ){PrintToServer("MyCustomAction is updating...");if(GetRandomFloat()>=0.5){return action.Done("We are done");}returnPlugin_Continue;}
Изменение исходного результата:
#pragma semicolon 1#pragma newdecls required
#include<sourcemod>#include<sdktools>#include<actions>publicvoidOnActionCreated(BehaviorAction action,int actor,int actor,constchar[] name ){if( strcmp(name,"WitchIdle")==0|| strcmp(name,"WitchAngry")==0){/* We set post hook otherwise ActionDesiredResult will contain default values */
action.OnShovedPost=OnShovedPost;}}publicActionOnShovedPost(BehaviorAction action,int actor,int shover,ActionDesiredResult result ){if( result.type == SUSPEND_FOR ){
result.type = CONTINUE;returnPlugin_Changed;}returnPlugin_Continue;}
Заставить ботов лечить только вас или себя, только в состоянии ЧБ:
#pragma semicolon 1#pragma newdecls required
#include<sourcemod>#include<sdktools>#include<actions>
stock int m_bIsOnThirdStrike;publicvoidOnPluginStart(){
m_bIsOnThirdStrike =FindSendPropInfo("CTerrorPlayer","m_bIsOnThirdStrike");}publicvoidOnActionCreated(BehaviorAction action,int actor,constchar[] name ){/* Hooking self healing action (when bot wants to heal self) */if( strcmp(name,"SurvivorHealSelf")==0)
action.OnStart=OnSelfAction;/* Hooking friend healing action (when bot wants to heal someone) */if( strcmp(name,"SurvivorHealFriend")==0)
action.OnStartPost=OnFriendAction;/* Hooking take pills action (when bot wants to take pills) */if( strcmp(name,"SurvivorTakePills")==0)
action.OnStart=OnSelfAction;/* Hooking give pills action (when bot wants to give pills) */if( strcmp(name,"SurvivorGivePillsToFriend")==0)
action.OnStartPost=OnFriendAction;}publicActionOnSelfAction(BehaviorAction action,int actor,BehaviorAction priorAction,ActionResult result ){/* When bot will be about to start healing/taking pills we chech if he's black & white *//* if he is then we allow to heal otherwise no */
result.type =GetEntData(action.Actor, m_bIsOnThirdStrike,1)? CONTINUE : DONE;returnPlugin_Handled;}publicActionOnFriendAction(BehaviorAction action,int actor,BehaviorAction priorAction,ActionResult result ){/* When bot will be about to start healing/giving pills to someone, we chech if friend is black & white *//* if friend is then we allow to give heal otherwise no */int target = action.Get(0x34)&0xFFF;
result.type =GetEntData(target, m_bIsOnThirdStrike,1)? CONTINUE : DONE;returnPlugin_Handled;}
Расширение предоставляет собой встроенные средства для перехвата обработчиков событий действий и создания пользовательских действий.
Команды и ConVars:
Шаблоны:
Блокировка действий:
Пользовательские действия:
Изменение исходного результата:
Заставить ботов лечить только вас или себя, только в состоянии ЧБ:
Источник: https://forums.alliedmods.net/showthread.php?p=2771520#post2771520
actions.ext.l4d2.zip