Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==================================================================
- function getWayPointlist(%trigger)
- {
- %waypointlist = new arrayobject();
- %probabilityMark = 0;
- for (%i=0;%i<8;%i++)
- {
- if (isObject(%trigger.waypoint[%i]))
- {
- %waypoint = %trigger.waypoint[%i];
- %probabilityMark += %trigger.probability[%i];
- %waypointlist.add(%waypoint,%probabilityMark);
- }
- else
- {
- %waypointlist.add(-1,0);
- }
- }
- return %waypointlist;
- }
- function AIPlayer::pickWayPoint(%this,%trigger)
- {
- %waypointlist = getWayPointlist(%trigger);
- //roll on the resulting WayPoint-'table'
- %count = %waypointlist.count();
- %roll = getRandom()*100;
- %ourPos = %this.getWorldBoxCenter();
- %enemyDist = 99999;
- if (isObject(%this.enemy))
- %enemyDist = %this.getDistanceBias(%this.enemy);
- for (%i=0; %i<%count; %i++)
- {
- if (%waypoint $= "")
- {
- if (%roll <= %waypointlist.getValue(%i))
- {
- %waypoint = %waypointlist.getKey(%i);
- %waypointPos = %waypoint.getWorldBoxCenter();
- %waypointDist = VectorDist(%waypointPos, %ourPos);
- if (%waypointDist/10000<%enemyDist)
- {
- %this.setPathDestination(%waypoint.getPosition());
- %this.nextCommandTime = $Sim::Time + %waypointDist*$botStateDuration[$botstate_WaypointMove]/10000;
- }
- return;
- }
- }
- }
- if (%waypoint $= "")
- %this.PathToNearest();
- }
- function NavTrigger::onEnterTrigger( %this, %trigger, %obj)
- {
- if (%obj.isBot)
- {
- %obj.pickWayPoint(%trigger);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement