• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Best way to do random encounter

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

In many games with overworlds, there is a random encounter mechanic where every so often enemies will suddenly attack the player. I am not going to move the player to a separate area to do the battle--instead the enemies will just appear in some range around the player.

I think the catalyst should be whenever the player moves, so I am assuming there is TriggerRegisterPlayerUnitEvent(..., PLAYER_UNIT_MOVE_EVENT) that detects whenever one of the players units moves or is ordered to move.

The next issues are handling running away--what do I do with those creeps? Or do I make them follow the player forever? Or disappear after an amount of time.

And then also making sure I don't spawn more creeps if the player is moving around in a battle--it would quick snowball. But I do not, REPEAT, do not want to make use of a battle detection system (e.g. tell whether a player is under attack or in battle).

I need to also control the frequency of encounters to make sure they happen often enough, but not too frequent to tire the player.

Also, for spawning the creeps, I guess I can just pick a random point that is within some distance of the player?

For different regions (and different creeps) I suppose I can use flags that tell me what "region" a player is in, so I know what creep tables to use.

Any suggestions?
 
CreateTimer(), TimerStart(), PauseTimer(), DestroyTimer(), GetExpiredTimer()

If you use Vexorian's Table you can easily

global HandleTable x -> HandleTable.create()

set x[any handle including timer] = <any integer including struct instance>

Bribe's Table obviously would have a similar method for storing data in a timer instance
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Bribe's Table has the disadvantage of only allowing integer in [], so you basically have to manually inline HandleTable's [] call, because that also calls GetHandleId()

also, if you start timer as periodic(TimerStart(..., true, ..., ...)), and you PauseTimer(), you better just call TimerStart again, because if you ResumeTimer() the periodicity of timer is lost, sad bug
 
Status
Not open for further replies.
Top