| 10-07-2003, 02:14 AM | #1 |
Im trying to make an RPG, just because i can, and i want there to be creeps spawning so theres always something to kill, but i dont want them to overload in one region, like say you havent killed anything in a region for an hour, it wouldnt spawn 600 guys, it would respawn up to a certain amount and stop until some more died. Also i dont want them to respawn the second one dies, like maybe 3 mins after 1 dies, a new would respawn. How would i go about doing this :dance: :thrust: |
| 10-07-2003, 02:24 AM | #2 |
Check if region contains amount of creeps... |
| 10-07-2003, 03:17 AM | #3 |
I know of a few ways to do creep respawn using no regions at all: (extremely desirable because you can change the creep camps whenever you want) The really simple: Event: Unit owned by neutral hostile dies. Actions: Wait 30 seconds Create 1 (unittype of dying unit) for (neutral hostile) at (position of dying unit) This doesn't work if the corpse gets destroyed, by black arrow or raise dead, for example. It also doesn't work for units that leave no corpses, like spirit pigs. You'll probably want to throw a check in for nearby players units. If you want to use this method it would be a good idea to add other triggers to create new creeps over time, because the creep populations will get depleted. The slightly better: Event: Unit owned by neutral hostile dies. Condition: Dying unit is summoned equal to false Actions: Create 1 (unittype of dying unit) for (neutral hostile) at (position of dying unit) Hide (last created unit) Pause (last created unit) Then have another trigger which unhides and unpauses the "ghost" units when noone is nearby. Done poorly this method results in scads of lag. If you neglect to add the "is summoned" check then REALLY BAD THINGS MIGHT HAPPEN. Like creep camps getting HUGE as summoned units get respawned too. The truly l337: Store the type and location (point) of every creep on the map at the start in arrays. Also store the current creep in an array. Then iterate through the array[s], if the current creep is not alive (and noone is near the location), then create a new creep getting the type from the unittype array and the location from the unitlocation array, then assign (last created unit) to CurrentCreep array. The interesting thing about this system is it has no "unit dies" event at all, you can also do absolutely anything you want with neutral hostile (if you spawn new units with triggers, they wont be revived, unless you add them to the arrays) It is also causes no lag at all if properly optimized and there is A LOT of room for opitmization if you have some programming knowledge. Finallly it brings back creep camps looking exactly like they were before being creeped. I'm making an OpenRPG and I use an array based creep respawn system which does a lot more, including causing creeps to come back as stronger versions of their ancestors. (ie Prawn -> Maruka Prawn -> Maruka Snapper -> Tidal Lord). It's an obscenely long and complicated trigger with all the lag optimization and I put quite a lot of work into it so I wont be posting it, altough if you are interested I might whip up a simplified minimal version of array based creep respawn which you can just drop straight in your map. |
| 10-07-2003, 03:37 AM | #4 |
No, it does work if you use black arrow. If you use black arrow the unit still "dies", but just get ressurected, no problems. Grater, your such a trigger god omfg!!! [/sarcasm] |
| 10-07-2003, 03:54 AM | #5 |
stfu and go play an old version of silvers open rpg which used the first trigger I listed (silvers more current versions still do, but with black arrow removed, hahah) The reason it doesn't work, AFAIK, is when the corpse gets destroyed the unit no longer exists, which means that the "Unittype of dying unit" will be null, and hence no unit is created. At the exact moment of the unit dying the unit does still exist, so you can use unit-type at the start of the trigger, but not after a wait. This is why the "ghost creep" version works, and also in principle you should be able to write a trigger based on the 1st version, but where the unit type and unit location are stored in local variables at the start of the trigger. edit: just to clarify, the entire last paragraph is ONLY relevant for when the unit is killed by black arrow, doom etc or if it's corpse is consumed by raise dead etc or if the corpse has decayed naturally. Some creeps leave an invisible corpse for a while, such as golems, meaning even tho you might expect the first trigger to not work properly on them, it does. |
| 10-07-2003, 05:16 AM | #6 |
Then for black arrow use a trigger spell. Unit dies Create skeletons at the dieing unit blah blah |
| 10-07-2003, 05:20 AM | #7 |
wtf are you on? Black arrow WORKS, but the creep DOESN'T RESPAWN. Thats the problem. |
| 10-07-2003, 06:33 AM | #8 |
actually i use the trigger event- unit dies condition- owner of unit equal to neutral hostile action- wait 30 seconds(or however long) create unit type of dying unit it works...what are you talking about? |
| 10-07-2003, 07:00 AM | #9 |
If any of these conditions are true the unit will not respawn: The unit is killed by black arrow, orb of darkness, doom, and prehaps some other skills. The unit does not leave a corpse when killed (ie spirit pig, skeletons) The corpse is consumed by a hungry ghoul, raise dead, revive dead, etc or simply decays before the trigger gets around to raising it. The unit is charmed or possessed. If all those conditions are irrelevant, or nearly irrelevant, then you can get away with such a simple trigger. Otherwise you should save the unit type in a local variable before the wait action, or use an array based system. The other alternative is to simply create a lot of new creeps with triggers as the game progresses, so it doesn't matter if some never respawn. This is a trigger that uses local variables, it happily respawns spirit pigs and units slain with black arrow. Code:
Simple reliable creep respawn
Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
((Dying unit) is Summoned) Equal to False
Actions
Custom script: local location temploc = GetUnitLoc(GetDyingUnit())
Custom script: local integer temptype = GetUnitTypeId(GetDyingUnit())
Wait 60.00 game-time seconds
Custom script: call CreateNUnitsAtLoc( 1, temptype, Player(PLAYER_NEUTRAL_AGGRESSIVE), temploc, bj_UNIT_FACING ) |
| 10-07-2003, 12:35 PM | #10 |
position of dying unit can have some undesired effects. I prefer to store the creeps in unit groups and call them to thier respective regions for respawn. Depends on the map, but position of dying unit will make them spawn where they die and not always where they spawned, so if someone runs away , and it dies away from the spawn point, you don't want them to respawn where they died. |
| 10-07-2003, 01:58 PM | #11 |
Aye, it is for that exact reason (mainly multiple creep groups merging into one as they "call for help") that I vastly prefer using arrays. (I absolutely refuse to add respawn regions... it's an ineffecient use of time) With my respawn system I have type(UnitType), location(Point), owner(Player) and currentCreep(Unit) arrays. The reason for owner is so I can easily extend the respawn trigger to respawn units for other players (ie Guards guarding a town). Two other variables are NumberOfCreeps(Integer) and RespawnToken(Integer) The 1st trigger sets up the arrays by picking every unit on the map at map init belonging to any "neutral/creep" player, for each unit, it assigns the relevant array variables then increments NumberOfCreeps. In effect it takes a snapshot of the starting units on the map. The 2nd trigger is a periodic (every 1 second) checks isAlive(CurrentCreep[RespawnToken]) = false If the unit is not alive, it first checks for the presence of nearby player units, if none are nearby it creates a new unit, taking the type, location and owner from the arrays and assigning the freshly created unit to CurrentCreep[Token] It then increments RespawnToken (resets to 0 if RespawnToken > NumberOfCreeps) so the next time the trigger runs, it works on the next unit in the array. Thats how the most simple yet fully featured version works, my version has evolved into a more complicated beast that tries to absolutely minimize the number of checks for nearby player units (this is a big cause of lag in poorly designed OpenRPG's) by ensuring that creeps in a camp are all consequtive in the array, so that for example, if I check a creep, and notice there are nearby player units, the trigger automatically skips all remaining creeps in the camp. And if there are no players around, the whole camp will be respawned in one go. I should probably tidy up the triggers (or rewrite using custom text more) and release them in the hope of saving even one OpenRPG from the curse of shonky respawn triggers. My next little project will be trying to make a JASS function that takes a unittype and returns a simialler, but stronger unittype (ie gnoll->gnoll brute). |
| 10-09-2003, 07:15 PM | #12 |
could you just make a trigger on a map and let me copy it, itll save me time, im just trying to make a local rpg, which probably wont be posted, and i just want to finish it. |
| 10-10-2003, 03:01 AM | #13 |
Grater you crackhead. Dieing unit doesn't refer to a corpse, it refers to a unit dieing. Wtf r u on, man. And for your array thing, why make it so it respawns when noone is around? This just means you have to leave and come back, makes it more annoying to creep spawn camp or whatever As for your respawn trigger... Events: Unit owned by neutral hostile dies. Conditions: (dying unit) equal to summoned false Actions: Wait 30 seconds Create 1 (unittype of dying unit) for (neutral hostile) at (position of dying unit) This will respawn every creep 30 seconds after it dies. |
| 10-10-2003, 03:15 AM | #14 |
The question is more of what your on. If it goes to check what unit dies 30 seconds later (or whatever) and the corspse is gone, guess what, it cant check it! it just says "Hey there is no unit, wtf are you talking about?". |
| 10-10-2003, 03:16 AM | #15 |
you sure that will work though? crappy ruele open rpg had respawn at position of dying unit and everytime the corpse was removed it wouldnt respawn :thrust: |
