CMD_SET_WANTED_MAX_SPEED doesn't work

CMD_SET_WANTED_MAX_SPEED doesn't work

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

CMD_SET_WANTED_MAX_SPEED doesn't work

Post by tow_dragon »

I've a problem with command CMD_SET_WANTED_MAX_SPEED. Spring ignores this command. Is it supported?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I havent seen anything save scripts make use of it.

Instead try looking at the parameters your passing to it and checking against the code in spring that makes use of it.
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

Post by tow_dragon »

I tried, but Spring doesn't use maxWantedSpeed variable (this is the variable Spring is saving value from GiveOrder to). I checked Spring 0.72b1 and SVN trunk version, both have the same code.
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

I found that the only ai using CMD_SET_WANTED_MAX_SPEED is OTAI. Although noone knows if it worked. You can look at its source here: http://www.fileuniverse.com/?p=showitem&ID=2993.
It is no longer developed since 0.71b1 so you probably won't be able to compile it.

Also look at Simple Formation AI. It doesn't use CMD_SET_WANTED_MAX_SPEED, but it keeps its units moving together somewhat.
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

Post by tow_dragon »

OK, so now I have next question:
What we get in UnitDamaged function call as float3 dir?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

it's a normalized direction.

aka instead of giving the actual location from whcih the shot was fired, it instead gives a set of co-ordinates showing what direction it came from, aka a vector.

The location is:

damagedunitlocation + dir*TimeToTravelToTarget

the problem is the time value has to be guessed or approximated/predicted.

It's main use was like in OTAI where it was multiplied by 300 then subtracted from the units position resulting in the unit being told to move in the opposite direction of the shot to run away.
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

It is a normalized vector that basically should show direction towards location from which the shot was fired, but the way it is implemented means that instead it shows direction toward actual position of the shooter.
AF wrote:The location is:

damagedunitlocation + dir*TimeToTravelToTarget

the problem is the time value has to be guessed or approximated/predicted.
Time, eh??

The enemy location is:
damagedunitlocation + dir * DistanceToEnemy

And the distance is the thing which needs to be guessed/approximated/predicted.
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

about Set_Max_speed

Post by alik83 »

I made a patch on the mailing list (1 line of code) for this command to work and included it with SelectedUnitsAI.cpp so that CTRL-Move makes them move at the same speed, Ctrl-Move-Drag makes them move at same speed and form a front (like drag-move).
The only(BIG) problem I didn't fix is how to make them resume their usual speed after command is finished.
I also changed it so when you move-drag the spacing between units takes into account unit sizes, and if a front is big the units spread to fill the whole front, not gather in the middle like it is now. Non of the developers however answered to my post on the mailing list...(changed files are in the attachment on the mailing list)
Alik
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

Wouldn't CMD_SET_WANTED_MAX_SPEED with Speed = UnitDef->MaxSpeed resume the original speed?

Also don't send whole modified files, make a patch which contains only modified parts of code and is easier to review. Use "Create Patch" button in your SVN client (if you have one already).
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

ok

Post by alik83 »

thanks for telling me how to make a patch.
Wouldn't CMD_SET_WANTED_MAX_SPEED with Speed = UnitDef->MaxSpeed resume the original speed?
Yes, it would, but you would need to give this command when units finish moving/or stopped/or given another command. I tried pushing the set_max_speed(original max speed) to the end of the unit's command que (unit->commandAI-commandQue.push_back(command)) but it didn't work, besides it's not a very good solution in case units will be stopped/given another command(stopped again). I was suggesting also making update() function in selectedUnitsAI.cpp which could allow advanced formations(without GroupAI) and could be used to solve the setting-back speed problem...
[/quote]
Post Reply

Return to “AI”