![]() |
CTP2 Bureau The Modding Knowledgebase |
|
Apolyton CTP2 forums Apolyton CTP2 archives Source Code Project SVN |
![]() |
Search the site: |
SLIC-Reference :
|
Arguments: | location, newlocation | Type: | void |
Get a random square adjacent to location and put it in newlocation |
Similar to GetNeighbor, but the direction is random. |
tested
working
SFN_ERROR Slic_GetRandomNeighbor::Call(SlicArgList *args) { if(args->Count() != 2) return SFN_ERROR_NUM_ARGS; MapPoint pos, npos; if(!args->GetPos(0, pos)) return SFN_ERROR_TYPE_ARGS; if(args->m_argValue[1].m_type != SA_TYPE_INT_VAR) return SFN_ERROR_TYPE_ARGS; SlicSymbolData *sym = args->m_argValue[1].m_symbol; sint32 d = g_rand->Next(sint32(NOWHERE)); BOOL retry = TRUE; sint32 count = 9; do { if(pos.GetNeighborPosition((WORLD_DIRECTION)d, npos)) { sym->SetPos(npos); if((g_theWorld->IsLand(pos) || g_theWorld->IsMountain(pos)) && !g_theWorld->IsWater(pos)) { if((g_theWorld->IsLand(npos) || g_theWorld->IsMountain(npos)) && !g_theWorld->IsWater(npos)) { retry = FALSE; } } else if(g_theWorld->IsWater(pos)) { if(g_theWorld->IsWater(npos)) { retry = FALSE; } } } d++; if(d >= sint32(NOWHERE)) d = 0; count--; } while (retry && count >= 0); return SFN_ERROR_OK; } |
Using this form you may add your own observations concerning the above item, e.g. additional hints for usage, limitations, oddities etc. Please note this is not the place for asking questions or carrying out discussions about modding - please refer to the Apolyton CTP2 Modification Forum on that purpose.
*) Required fields
![]() |
This site is currently maintained by: BureauBert (Webmaster) Maquiladora (Manager) Legal Notice: Legal Notice Statistics: 102514 unique users since 02.05.2004 (» Site Statistics) Hosted by: WebhostOne |