TD need technical help

Hello everyone.
TD TOPIC(Castle siege / tower defense module - #3 by lord_XD)
I will ask questions / if you want you can help me
rough plan
1)make the trigger work (100%)
2) create a system of purchases and prices (0%)
3)create user interface(30%)
4) create a system of dialogues (50% done).
5) create an event system (5% done).
6) The concept of the module is a more beautiful map.
7)Tests and verification of dialogs and events
8) balancing enemies and units (40%)
9) the path of enemies-95%.
10) checking everything

1 Like

I am currently working on a trigger for my tower module.
I need a trigger to prevent friendly NPCs from leaving a certain zone (fighters can defend the zone, but if the enemy left it, they remain in their zone)

i tried to use trigger but it doesn’t work as it should.
does anyone know how to fix this?
The maximum skill I got was for the warriors to react 1 time, but when the battle starts, it is reset (does not work).

here my generic trigger script

void main()
{
 object oEnter = GetEnteringObject();
object osWP1 = GetWaypointByTag("WP_stayhere");

    if (!GetIsPC(oEnter) && GetTag(oEnter) == "r_guard")
       	AssignCommand(oEnter, ClearAllActions(TRUE));
	DelayCommand(0.2, AssignCommand(oEnter,ActionForceMoveToObject(osWP1, 1, 1.0f, 10.0f)));
}

Just speculating now…Maybe use JumpToObject instead of ActionForceMoveToObject? It may not look as good but I’ve many times found jumping to be more reliable than moving when it comes to scripts.

2 Likes

Hi andgalf ,it’s just that this one even starts up, but it’s only very unreliable in battle.

use JumpToObject
Initially, I used it, but it does not work for me. by the way, I don’t know what I did wrong here, but here’s the script.(i put it into onEnter generic trigger)

void main()
{
    object oEnter = GetEnteringObject();    
  if( GetIsEnemy(oEnter  ))	// if the entering object is  a Enemy, 
	return;  

    if(GetIsFriend(oEnter)==TRUE)
    { AssignCommand(oEnter, ClearAllActions(TRUE));
        AssignCommand(oEnter, ActionJumpToLocation(GetLocation(GetObjectByTag("GET_AWAY"))));
        
    }
    else if(GetIsPC(oEnter)==TRUE)
    {             
        AssignCommand(oEnter, ClearAllActions(TRUE));
        DelayCommand(0.1, AssignCommand(oEnter, ActionJumpToLocation(GetLocation(GetObjectByTag("GET_AWAY")))));
    }


	
}

only in this variation, I still forbade the PC to leave this zone, I have not yet decided how I will implement it.

I’m sorry, but I don’t understand this sentence. Maybe you could rephrase that?

I’ve never used GetIsEnemy before, but according to your script, it seems that it checks if it’s a friend or an enemy of oEnter which is the entering object. Do you really want that?

1 Like

you genius…i never think about it before.
I figured out .it turns out the trigger is also a faction, well then everything is clear
see example here code doesn’t works on friendly npc .

void main()
{
    object oEnter = GetEnteringObject();    
  if( GetIsEnemy(oEnter  ))	// if the entering object is  a Enemy, 
	return;  
 if(GetIsFriend(oEnter)==TRUE)
    { AssignCommand(oEnter, ClearAllActions(TRUE));
        AssignCommand(oEnter, ActionJumpToLocation(GetLocation(GetObjectByTag("WP_stayhere"))));
        
    }

	
}

why? its because trigger is fraction 1=enemy
and trigger see enemy as his friends/and if we have
if( GetIsEnemy(oEnter )) // if the entering object is a Enemy,
return;
friendly creatures wont be moved on location-stay here but enemy will be

here right examle how it should be if you want move frienly creatures/iwill post video later

void main()
{
    object oEnter = GetEnteringObject();    

 if(!GetIsFriend(oEnter)==TRUE)
    { AssignCommand(oEnter, ClearAllActions(TRUE));
        AssignCommand(oEnter, ActionJumpToLocation(GetLocation(GetObjectByTag("WP_stayhere"))));
        
    }

	
}

Now the trigger works correctly. finally wow! :sweat_smile:

Now I need to make a system for receiving money, it sounds cool, but I think it will just be a couple of scripts. (If someone doesn’t have better ideas) in general, everything seems to be clear, but how to balance prices and create some kind of dynamics?

Right now, I’ll study it myself a little to clarify the situation.
(I’m sorry that I’m not a game designer ok, let’s try)

Aren’t there any commands without “Action” in NWN2? to avoid the command stack.Such as

// Jump to oToJumpTo (the action is added to the top of the action queue).
void JumpToObject(object oToJumpTo, int nWalkStraightLineToPoint=1)

@Mmat Yep, there are commands without Action. I suggested to lord_XD to use JumpToObject as you can see in one of my previous posts, but he/she decided to use ActionJumpToLocation which is just another way of doing things. I don’t think (but I might be wrong here) that this particular thing differs from NWN1.
However, I think that JumpToObject is still considered an action that is part of the action queue, but now we’re into a territory where I’m not that knowledgable. In any case, I think NWN2 and NWN1 are the same with all this.

1 Like

sentinel creatures are fighting and I need to interrupt all
their attempts to leave the area to which they are supposed to guard.
so just adding another action to the queue is not sure if that will help. I’m trying to use the most reliable option.

actually I’m a man.
To be honest, I don’t see much difference between
JumpToLocation\JumpToObject
I just use what I’m used to

ran into a small problem with the enemy path script (can anyone suggest how to optimize the script or even shorten it)
I have a script for moving enemy creatures
1.part move to the first gate (works well)
part 2 check how many creatures are in the gate area
if there are 0 creatures then move on
otherwise fight for 2 minutes / when they pass move on
3) repeat for the next gate until you reach the final gate.

I have an option how to calculate the number
creatures around the gate - but it looks clumsy.
I can try to iterate over all the creatures around (kind of expensive)
waypoint, or is it better to just try using a trigger with variables (when a creature spawns in a zone or is in it, the number of variables increases by 1, and by default the variable is 0)
does anyone know how to simplify this?

//rough sketh probably it shoulbe works/i wil try it -paste updated code later
int a=120;
int b=GetLocalInt(OBJECT_SELF,“counter”);
oMonster= = OBJECT_SELF;

if( nEnemy > 0){
if(a>b)
AssignCommand(oMonster, ActionAttack(oGuard));
else
AssignCommand(oTarg,ActionForceMoveToObject(osWP3 1, 1.0f, 10.0f));
}

my walk scripts before sketh

void main()
{
object oTarg = OBJECT_SELF;
//object oGuard = OBJECT_SELF;

object osWP1 = GetWaypointByTag("WP_croll_01");
object osWP2 = GetWaypointByTag("WP_croll_02");
object osWP3 = GetWaypointByTag("WP_croll_03");
AssignCommand(oTarg,ActionForceMoveToObject(osWP1, 1, 1.0f, 10.0f));
AssignCommand(oTarg,ActionForceMoveToObject(osWP2, 1, 1.0f, 10.0f));
AssignCommand(oTarg,ActionForceMoveToObject(osWP3, 1, 1.0f, 10.0f));

}

If you assing specific tag to creatures you can count creatures with that tag and HP greater than zero?

1 Like