14 12
发新话题
打印

[转载] Controllable NPC插件

這個插件可以讓NPC擁有更多功能,例如攻擊、走路等
0.3c之後的版本似乎都不能使用,希望有人能解決此問題
以下我只翻譯一些我常用的代碼
主要代碼:
复制内容到剪贴板
代码:
native CreateNPC(npcid,npcname[]);//建立NPC(npcid,"NPC名字")

native CreateNPCPlayer(id,name[]);//建立NPC(npcid,"NPC名字")(註1)
(註1:上面的代碼會讓NPC顯示在玩家列表,這個插件因為該功能而被SAMP論壇刪除了,真的很可惜,這就是之後沒有更新版的原因)

native IsValidNPC(npcid);
native DestroyNPC(npcid);//消除NPC
native KillNPC(npcid);//殺掉NPC
native SpawnNPC(npcid);//重生NPC
native PutNPCInVehicle(npcid,vehicleid,seat);//將NPC放進交通工具
native StopNPC(npcid););//停止NPC動作
native SetNPCImpregnable(npcid,istate);//設定該NPC的無敵狀態
native IsNPCImpregnable(npcid);//該NPC是否為無敵
native GetNPCState(npcid);//取得NPC狀態
native ToogleVisualDeath(tstate);
native DisableJoinPartLogging();
native FindLastFreeSlot();
普通代碼:
复制内容到剪贴板
代码:
native SetNPCPos(npcid,Float:X,Float:Y,Float:Z);//設定NPC座標
native GetNPCPos(npcid,&Float:X,&Float:Y,&Float:Z);//取得NPC座標
native SetNPCFacingAngle(npcid,Float:angle);//設定NPC角度
native Float:GetNPCFacingAngle(npcid);//取得NPC角度
native SetNPCVelocity(npcid,Float:X,Float:Y,Float:Z);//設定NPC速度
native GetNPCVelocity(npcid,&Float:X,&Float:Y,&Float:Z);//取得NPC速度
native SetNPCKeys(npcid,updown,leftright,keys);//設定NPC按鍵
native GetNPCKeys(npcid,&updown,&leftright,&keys);//取得NPC按鍵
native SetNPCSkin(npcid,skin);//設定NPC的SKIN
native GetNPCSkin(npcid);//取得NPC的SKIN
native SetNPCInterior(npcid,interior);//設定NPC的室內編號
native GetNPCInterior(npcid);//取得NPC室內編號
native SetNPCSpecialAction(npcid,action);//設定NPC特殊動作(跳舞、喝酒等)
native GetNPCSpecialAction(npcid);//取得NPC特殊動作
native SetNPCWeapon(npcid,weaponid);//設定NPC的武器
native GetNPCWeapon(npcid);//取得NPC的武器
native SetNPCWeaponSkillLevel(npcid,weapontype,level);//設定NPC武器等級
native GetNPCWeaponSkillLevel(npcid,weapontype);//取得NPC武器等急
native SetNPCHealth(npcid,Float:amount);//設定NPC的血量
native Float:GetNPCHealth(npcid);//取得NPC血量
native SetNPCArmour(npcid,Float:amount);//設定NPC的防彈衣
native Float:GetNPCArmour(npcid);//取得NPC防彈衣
native SetNPCSurfing(npcid,Float:X,Float:Y,Float:Z);
native GetNPCSurfing(npcid,&Float:X,&Float:Y,&Float:Z);
native SetNPCSurfingVehicle(npcid,vehicleid);
native GetNPCSurfingVehicle(npcid);
動作代碼:
复制内容到剪贴板
代码:
//is_z_map 是設定NPC是否照著SA的地形行走(似乎只能在室外使用,室內及物件地圖上建議設置為0)
native NPC_WalkTo(npcid,Float:X,Float:Y,Float:Z,is_z_map);//設定NPC走向座標
native NPC_RunTo(npcid,Float:X,Float:Y,Float:Z,is_z_map);//設定NPC跑向座標
native NPC_SprintTo(npcid,Float:X,Float:Y,Float:Z,is_z_map);//設定NPC奔向座標
native NPC_LookAt(npcid,Float:X,Float:Y,Float:Z);//設定NPC面向座標
native NPC_AimAt(npcid,Float:X,Float:Y,Float:Z);//設定NPC瞄準座標
native NPC_ShotAt(npcid,Float:X,Float:Y,Float:Z);//設定NPC攻擊座標
native NPC_DriveTo(npcid,Float:X,Float:Y,Float:Z,Float:speed,is_z_map);//設定NPC開車開向座標
傷害代碼:
复制内容到剪贴板
代码:
native SetWeaponDamageForNPC(weaponid,Float:damage);//設定某武器對NPC的傷害值(註2)
註2:建議把38設成0,不然格林打一下就掛了實在不好玩
SetWeaponDamageForNPC(38,0);//

native SetWeaponReloadTimeForNPC(weaponid,mstime);//設定某武器對NPC的裝填時間
其他代碼:
复制内容到剪贴板
代码:
// aim controls
native SetNPCCameraPos(npcid,Float:X,Float:Y,Float:Z);//設定NPC的視角座標(不知道有什麼用=_=)
native GetNPCCameraPos(npcid,&Float:X,&Float:Y,&Float:Z);//取得NPC視角座標
native SetNPCCameraFrontVector(npcid,Float:X,Float:Y,Float:Z);
native GetNPCCameraFrontVector(npcid,&Float:X,&Float:Y,&Float:Z);
native SetNPCCameraMode(npcid,mode);
native GetNPCCameraMode(npcid);
native SetNPCWeaponState(npcid,wstate);
native GetNPCWeaponState(npcid);

// driver controls
native SetNPCVehiclePos(npcid,Float:X,Float:Y,Float:Z);//設定該NPC所開的車的座標
native GetNPCVehiclePos(npcid,&Float:X,&Float:Y,&Float:Z);//取得該NPC所開的車的座標
native SetNPCVehicleQuaternion(npcid,Float:X,Float:Y,Float:Z,Float:Scal);
native GetNPCVehicleQuaternion(npcid,&Float:X,&Float:Y,&Float:Z,&Float:Scal);
native SetNPCVehicleVelocity(npcid,Float:X,Float:Y,Float:Z);//設定該NPC所開的車的速度
native GetNPCVehicleVelocity(npcid,&Float:X,&Float:Y,&Float:Z);//取得該NPC所開的車的速度
native SetNPCVehicleKeys(npcid,updown,leftright,keys);
native GetNPCVehicleKeys(npcid,&updown,&leftright,&keys);
native SetNPCVehicleSiren(npcid,vstate);//設定該NPC所開的車的警鈴聲狀態
native GetNPCVehicleSiren(npcid);//取得該NPC所開的車的警鈴聲狀態
native SetNPCVehicleWeapon(npcid,weaponid);//設定該NPC開車時所持有的武器
native GetNPCVehicleWeapon(npcid);//取得該NPC開車時所持有的武器

// .rec playbacks
native StartRecordingPlayback(npcid,name[]);
native PauseRecordingPlayback(npcid);
native ContinueRecordingPlayback(npcid);
native StopRecordingPlayback(npcid);

// GTA SA paths
//似乎可以讀取SA的行人路徑(NODE),不過我也不太會用
native Node:OpenNode(name[]);
native CloseNode(Node:nodeid);
native GetNodeHeader(Node:nodeid,&nodes,&vehicle_nodes,&ped_nodes,&navi_nodes);
native SetNodePoint(Node:nodeid,pointid);
native GetNodePoint(Node:nodeid);
native GetNodePointPos(Node:nodeid,&Float:X,&Float:Y,&Float:Z);
native GetNodePointLinkId(Node:nodeid);
native GetNodePointAreaId(Node:nodeid);
native GetNodePointWidth(Node:nodeid);
native GetNodePointLinkCount(Node:pointid);
native GetNodePointTrafficLevel(Node:nodeid);
native IsNodePointRoadBlock(Node:nodeid);
native IsNodePointBoats(Node:nodeid);
native IsNodePointEmergency(Node:nodeid);
native IsNodePointNotHighway(Node:nodeid);
native IsNodePointSpawn(Node:nodeid);
native IsNodePointRoadBlock1(Node:nodeid);
native IsNodePointParking(Node:nodeid);
native IsNodePointRoadBlock2(Node:nodeid);
native GetNodePointType(Node:nodeid);
native SetNodeLink(Node:nodeid,linkid);
native GetNodeLinkAreaId(Node:nodeid);
native GetNodeLinkNodeId(Node:nodeid);

// ZMap
native ZMap_Init(mapname[]);
native Float:ZMap_GetZForCoords(Float:X,Float:Y);

// Rolls
native Float:ConvertRollToGrad(Float:roll);
native Float:ConvertGradToRoll(Float:grad);

// CPlayer structure
native GetPlayerStructureInfoByte(playerid,structure_offset);
native GetPlayerStructureInfoInt(playerid,structure_offset);
native Float:GetPlayerStructureInfoFloat(playerid,structure_offset);

// CVehicle structure
native GetVehicleStructureInfoByte(vehicleid,structure_offset);
native GetVehicleStructureInfoInt(vehicleid,structure_offset);
native Float:GetVehicleStructureInfoFloat(vehicleid,structure_offset);
// Foot sync

native GetFootSyncDataByte(playerid,offset);
native GetFootSyncDataInt(playerid,offset);
native Float:GetFootSyncDataFloat(playerid,offset);
Callbacks
复制内容到剪贴板
代码:
forward OnNPCGetDamage(npcid,playerid,Float:health_loss,bodypart);//當NPC受到傷害時(npcid,玩家ID,損失血量,擊中部位)
forward OnRecordingPlaybackEnd(npcid,reason);
forward OnNPCMovingComplete(npcid);//當NPC移動完成時
forward OnNPCSpawn(npcid);//當NPC重生時
forward OnNPCDeath(npcid,killerid,reason);//當NPC死亡時
使用方法:解壓縮後將pawno及plugins資料夾丟到你的伺服器資料夾取代
然後打開server.cfg, 在plugins後面添加CNPC

[ 本帖最后由 永恆之風 于 2011-8-8 15:48 编辑 ]
附件: 您所在的用户组无法下载或查看附件
本帖最近评分记录
  • mk124 金钱 +20 分享……老物了 2011-8-8 17:10

TOP

强大的插件

TOP

问个问题
:native一定要在前面加吗

TOP

CNPC 开源的源码仓库有两个
http://code.google.com/p/controllable-npc/
http://code.google.com/p/controllablenpc/

他们也都只支持到0.3C……看样子没人有兴趣继续开发呢
Project Shoebill MS2差不多要完工了,有着更规范的API、更健壮的系统、更清晰的框架、更强的扩展力、支持Java插件扩展开发,同时还将提供Linux版。
MkMatch(MKLMS)重新启动开发,同时计划开发着4个Shoebill插件组件:
        Auth - 通用用户验证插件,带权限和组权限功能,验证模块支持本地YAML库、MongoDB、HTTPS网页验证登陆
        MultiDialog - 状态保存式多对话框系统插件
        MultiLanguage - 多语言文本支持插件
        GuiPluginManager - Shoebill的图形化(窗口)插件管理器

TOP

引用:
原帖由 落叶、随风 于 2011-8-8 16:49 发表
问个问题
:native一定要在前面加吗
不用
用法就跟player一樣
SetNpcPos = SetPlayerPos

TOP

怎么在samp-server说载入了,在游戏却没看见

TOP

貌似很强大的样子,是不是说就可以模拟单机中的NPC一样?

TOP

看到眼花了@@

TOP

 14 12
发新话题