Snippet Stopping Allies Attacking each other

chewett

New Member
Reaction score
0
a form of this should be used in most games as you can have someone ruin the game by killing everyone so he can play alone

Rating: simple anyone should be able to complete

Right here is the full code that i will explain it all

Code:
Attack Initialization
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Issued order) Equal to (Order(attack))
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Quest - Display to (All players) the Hint message: ((Name of (Triggering player)) +  has attacked another Player. Their character will be paused for 10 seconds because of this)
                Unit - Pause (Triggering unit)
                Wait 10.00 seconds
                Unit - Unpause (Triggering unit)
            Else - Actions
                Do nothing

Here is what it does:
Unit - A unit Is issued an order targeting an object
this is the Event. it literally means if someone targets a unit of some kind it will run
(Issued order) Equal to (Order(attack)) This checks what the order was. if it was an attack it goes through to executing the actions

Here is the main part of the code
Code:
            If - Conditions
                ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Quest - Display to (All players) the Hint message: ((Name of (Triggering player)) +  has attacked another Player. Their character will be paused for 10 seconds because of this)
                Unit - Pause (Triggering unit)
                Wait 10.00 seconds
                Unit - Unpause (Triggering unit)
            Else - Actions
                Do nothing
we check if they are an ally of Player 1 as if they were attacking an ally of player red they would be attacking a friend
then displeys a message to everyone that they have attacked a friend
pauses unit. this is just to stop them for a bit you could remove them to an area that no one can get to as they will still recieve exp while paused

will post more next morning will clear it up a bit
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Code:
((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True

This only works for one player. Shouldn't you do (Owner of (Triggering Unit)) Is an Ally of (Owner of (Attacked Unit))? Though, I don't think Attacked Unit is MUI....
 

Sim

Forum Administrator
Staff member
Reaction score
534
I believe we already have something like this in the section.
 

Kenoriga

Ultra Cool Member
Reaction score
34
A bit late in replying... but you can remove the If/Then/Else and move all If conditions to Conditions and If actions to Actions, since there is nothing in Else?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top