Get SaintAxe&Ror SpeechMaker Now And build your conversations easily ! |
The wall - Read LUA higlighted source code
Need to share Highlighted and indented LUA source code ?
|
Posted by pyhunter101 on : 2011-11-16 16:20:02 - Last edited : 2011-11-17 19:39:15
Defend Script
This script will spawn pla at a certain distance away from the player echelon in a random direction then make their way towards the player echelon.
All you need to do is:-
1. Put player echelon in group "us1"
2. Put enemy echelon in group "pla" and entityset "ent1"
3. Put a waypoint in entityset "way"
All you need to do is:-
1. Put player echelon in group "us1"
2. Put enemy echelon in group "pla" and entityset "ent1"
3. Put a waypoint in entityset "way"
function onMissionStart() spncnt = 0 spntim = 4000 -- spawn timer in seconds*1000 maxent = 40 -- maximum entity size maxspn = 90 -- maximum times to spawn maxdis = 1500 -- maximum distance before destroying set radius = 400 -- spawn distance from player echelon OFP:addTimer("enemy","1000") end function onTimer_enemy() size = OFP:getGroupSize("pla") dist = OFP:getDistance("pla","us") x,y,z = OFP:getPosition("us") degrees = math.random(1,360) radians = math.rad(degrees) x2 = (radius * math.cos(radians)) + x z2 = (radius * math.sin(radians)) + z y2 = y; if size < maxent and spncnt < maxspn then wp = OFP:spawnEntitySetAtLocation("way", x,y,z) spawn = OFP:spawnEntitySetAtLocation("ent1", x2,y2,z2) wpoint = OFP:getNearestWaypoint("us") spncnt = spncnt + 1 end if dist > maxdis then OFP:destroyEntitySet("spawn") end OFP:removeTimer("enemy") OFP:addTimer("enemy",spntim) end function onSpawnedReady_ent1( setName, setID, tableOfEntities, errorCode ) OFP:move("pla",wpoint,"OVERRIDE") OFP:destroyEntitySet("wp") end
