Operation Flashpoint Dragon Rising OFDR Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Random amount spawning

2 posters

Go down

Random amount spawning Empty Random amount spawning

Post by TheGeneral Thu 20 Dec 2012, 10:33

I have an idea for my zombie mod to do with random spawning. Problem is (as alsways I have a problem with things not doing what I want) I'm not sure how to work it out.

The spawning of units is the easy part but getting a random amount to spawn is the hard part. So for eaxmaple.

You play DRZ and enter Skoje, you have 10 zombies spawn at ten recon points in the town, fair enough you kill them but you got stabbed and you die oh well! You restart and the next time you enter skoje, the amount has either increased from ten zombies to maybe 15, or it could have been less say 6 zombies this time. But As you can see I would ideally like this to have a random spawn code for the zombies.

NFMZ1 planted the idea for this as he said you go one place you have a **** load to deal with, but then the next time you go back, you don't.

Cheers

MD.
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Random amount spawning Empty Re: Random amount spawning

Post by Guest Thu 20 Dec 2012, 20:09

Here's an idea, but since I'm not very experienced with editing, it may need some tweaking:

Code:

base_zomb = getAmmoCount("player") --this will generate a semi-random number (the ammo count of the player) --

zomb_spawn = base_zomb*10 -- this will give you a number of zombies for your horde but could be a multiple of anything (in this case 10) --

function onEnter_player_trigger(unitName, zoneName) -- the player enters the specific zone --

    spawn_prob = getSpawnProbability("smartspawn")  -- using a smart spawn, this will give you a probability of whether it will activate between 0.0 and 1.0 --
         
          if spawn_prob <= 0.5 and if zomb_spawn >=1 then
          zombie_horde = OFP:activateEntitySetAtEntityPosition("zombie", "reconpoint") -- this part spawns your zombies in a loop until the variable zomb_spawn reaches 0
          zomb_spawn = zomb_spawn -1
         
          elseif zomb_spawn = 0 then
          OFP:disableEvent("activateEntitySetAtEntityPosition")
          end
end

I hope I posted this right, and I'm sure it won't work as it is, but some of the more experienced editors may be able to do something with it. Hope it helps...
Anonymous
Guest
Guest


Back to top Go down

Random amount spawning Empty Re: Random amount spawning

Post by Guest Fri 21 Dec 2012, 03:36

Unfortunately the use of smart spawns is not possible. This is a pretty easy task to accomplish codewise though. Try something like this.

Code:


function onEnter(zoneName, unitName)

  if zoneName == "yourZoneName" then

    numberOfZombies = math.random(yourMinZombies, yourMaxZombies)

    for i = yourMinZombies, yourMaxZombies do

      ---your spawn code here

    end

  end

end


It will look something like that. I'd have to see your implementation of spawning code and how you're controlling the different locations for spawning, but that's the general gist of it.



Cheers:D
Anonymous
Guest
Guest


Back to top Go down

Random amount spawning Empty Re: Random amount spawning

Post by tjdagger Fri 21 Dec 2012, 12:08

Hey Mdog,
I just happened to working on something like what you want, putting it into a module.

This will do what you want and give you added control. It also automates despawning and entity limit checking.

Check it out here...
https://operationflashpoint.forummotion.com/t48-random-unit-spawn#138

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 48

Back to top Go down

Random amount spawning Empty Re: Random amount spawning

Post by Guest Fri 21 Dec 2012, 15:41

silent I'll get my coat... Embarassed
Anonymous
Guest
Guest


Back to top Go down

Random amount spawning Empty Re: Random amount spawning

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum